Jump to content

some aspirins please


sakkoulas
 Share

Recommended Posts

hi again,
 can anyone help me please because my mind will explode..
i have a page with children and i want to create a bootstrap slider with the last 5 page->children that have a specific field page tag.

so i have stuck with this ...

                                 <?php
                                     $i = 1;
                                     $tax = $pages->find("template=taxonomy, title=1293|1292");
                                     $slider = $pages->get("/last-news/")->children("$tax, limit=5");
                                    
                                    foreach ($slider as $s){
                                    $thumb = $s->images->first();
                                    $activeClass= '';        
                                            if ($i === 1) $activeClass = 'active';
                                               echo "<div class='item $activeClass'>
                                                    <img src='{$thumb}' alt='$s->description'>
                                    <div class='carousel-caption'>
                                    <h4>Second Thumbnail label</h4>
                                    <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
                                    </div>         
                                      
                                      </div>";
                                        $i++;
                                        }
                                ?>

this code returns
1 image
and 4 empty images src
???

thanks

Link to comment
Share on other sites

Here is an example function to render a bootstrap carousel.  Using a repeater field called slider with title and image fields assigned.  The image->summary  is used for the optional caption.  Also added a checkbox field to control the display called slider_visible. This should get you going. 

EDITED - moved source to gist.

https://gist.github.com/netdoctor/b6f3694c6c472084d467

Link to comment
Share on other sites

 
$tax = $pages->find("template=taxonomy, title=1293|1292");
 
I'm confused about the line above, because the 'title' is numbers like you would usually see as a page ID. Can you confirm that your page titles literally are these numbers?
<img src='{$thumb}' alt='$s->description'>

The above line should instead be this:

<img src='$thumb->url' alt='$thumb->description' />
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...