Jump to content

newbie Question


bbeer
 Share

Recommended Posts

Hi all

I have a newbie question concerning the listing of some child element in an overview. It all works well as long as I have only sub category.

In one case I am getting a level deeper, so I only get the first child listet.

like

trip Overview (Listing all trips)

       Flying (Lists all children of Lying

       Biking (Lists all Children ob biking)

       Holidays (should list the content of its children's children but does not)

               Italy

                     child 1

                     child 2

               Spain

                     child 1

               Croatia

                     child 1

See my code below.

   

<?php 
$p_id = $page->id;

$reisen = $page->find("parent_id=$p_id, sort=reise_abfahrt");

//gets the ID of the page I am on and lists the children

echo "id: $p_id";
?>

<dl class="travelList">
<?php
foreach ($reisen as $reise) { ?>
   
     <dt><a href="<?php echo $reise->url;?>" title="Detailansicht" class="tripDetail"><?php echo $reise->reise_abfahrt;?>   <?php echo $reise->longtitle; ?></a></dt>
      <?php
if($reise->reise_flyer != ""){
?>
<dd class="tripRoute">
<a href="<?php echo $reise->reise_flyer->url;?>" title="Flyer als PDF laden" target="_blank" class="tripFlyer">Flyer</a></dd>
<?php
}?>
   
   <?php } ?>
</dl>
 

Is there any way I could handle this in the same template as above or do I have to create a special template only for the listing of Holidays?

Your help is much appreciatetd.

Link to comment
Share on other sites

$p_id = $page->id !== (hollidays id) ? $page->id : $page->children;
 

 Written on the browser and not tested, but theoretically this should work. This is what it does:

If we are not on the "hollidays", page parent is this same page, if we are on the "hollidays" page, parents will be all it's children ( $page->children will output something like this: 342|654|877|998 )
Link to comment
Share on other sites

bbeer, I was in a hurry and didn't explain something. You don't have to use the IDs in this case. Same thing could be achived by:

$parents = $page !== $page->get('/holidays/') ? $page : $page->children;

and, in the selector;

$reisen = $page->find("parent=$parents, sort=reise_abfahrt");

Just for reference :)

  • Like 2
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...