2

I need to display a view inside another view and I'm using Views field views module, It works well, but I need the field (view) only appears in the first row result of the view page, like the following.

  • View page - results
    • Title node 1
    • Image node 1
    • View field 1 (this should appear only here)
    • Title node 2
    • Image-node 2
2
  • is there any relationship between node and view field?
    – Aboodred1
    May 22, 2013 at 17:14
  • not really. But there is a vocabulary in nodes where each node receives a different term.
    – NataN
    May 22, 2013 at 17:40

3 Answers 3

2

I'm not sure if Views nodes split module will be useful for your situation as @DnBase mentioned.

However, because you're using Views Field View; you can follow the following steps to achieve what you're looking for:

  • Edit field view actual view (referenced view)
  • Add Global: Null from CONTEXTUAL FILTERS menu

Add contextual filters

  • From the next dialog box that appear, select Hide view from WHEN THE FILTER VALUE IS NOT AVAILABLE fieldset.

  • Then from WHEN THE FILTER VALUE IS AVAILABLE OR A DEFAULT IS PROVIDED fieldset, check Specify validation criteria and select PHP Code from validator dropdown menu

  • Then add the following code in PHP Validate code field

  • From Action to take if filter value does not validate dropdown menu select Hide view

Code:

if($argument == 1) {
  return TRUE;
} else {
  return FALSE;
}

Global null dialog box

  • Now edit the main view
  • Add Global: View result counter from FIELDS menu, then from field configuration dialog box, check Exclude from display
  • Then edit Global: View field, from field configuration dialog box, add this replacement pattern [%counter] into Contextual filters field

Global view field view

By applying these steps, you'll notice that view field will only appear on first item.

7
  • Hey, That's great! But in my case something went wrong because the result is appearing on the second line. I do not know if I did something wrong. My criterion sorting is by taxonomy term: Weight
    – NataN
    May 24, 2013 at 15:33
  • Hmm, that's weird. Try to display View result counter field and see if the first item output number 1 also make sure the View result count field is on top of the fields
    – Aboodred1
    May 24, 2013 at 15:39
  • Yes, the number 1 is first item output of View result counter field. I tried to change to 0 but it doesn't work!
    – NataN
    May 24, 2013 at 18:23
  • its showing this error message: Notice: Undefined property: views_handler_field_counter::$last_render in views_field_view_handler_field_view->get_token_value() (line
    – NataN
    May 24, 2013 at 18:24
  • have you rearranged View result counter field to be first field under Fields menu
    – Aboodred1
    May 24, 2013 at 18:29
0

I can see 2 ways to 'split' the displays in your view so far:

  1. Use an 'Attachement' display and attach it to your view.
  2. Use Views nodes split module. See lullabot's review to have an idea.

BTW you can still use a display mode to display your content type fields in your view if you want. See my post here.

edit: The second solution will work only if your display mode contains the view by using EVA or Viewfield module. So never mind but I leave it just for the Views nodes split module if you're interested. In your case the first solution will be just fine.

0

I would rather use views template file, and put some PHP scripts using flags to ensure that the view field renders only first time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.