I have a field collection item field named field_base_feature and it has two field repeated as much as needed. title and body. I want to wrap the field collection items in a custom div <div id="slider-item"></div> when the title has a value slider-item. So I have a following array of field_base_feature fc items.

field_base_feature = array(
    0 => array(
           'title' => 'contact'
           'body' => 'contact information' 
    1 => array(
           'title' => 'subscribe block'
           'body' => 'subscribe information' 
    2 => array(
           'title' => ' miscellaneous block'
           'body' => 'misc information' 
    3 => array(
           'title' => 'slider-item'
           'body' => '<img src="some.jpg">' 
    4 => array(
           'title' => 'slider-item'
           'body' => '<img src="some1.jpg">' 
    5 => array(
           'title' => 'slider-item'
           'body' => '<img src="some2.jpg">' 


So for the above one, what I would like is, to render it normally but when during the loop condition where title == 'slider-item' is TRUE then I would to wrap the slider items in a parent div wrapper. So it should render as.

  //Condition where title == slider-item is TRUE

 <div id="slider-item">

     <img src="some.jpg"> //item with slider-item as title
     <img src="some1.jpg"> //item with slider-item as title
     <img src="some2.jpg"> //item with slider-item as title


I tried the preprocess_field, and changing the template but I still didn't manage to get what I wanted. Hope the question is clear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.