Documentation

Light-weight, fast, simple and powerful!
 
Translations of this page?:

findById()

The findById() function allows you to retrieve a set of page objects using a page's id as the search term.1) This function works in the same way as the find() function; consult its entry for more discussion.

See also: linkById(); urlById() gives information about using a variable for the ID.

Example

You can use the id of page to construct a basic menu of child pages. This can be helpful in cases where the slugs or location of a parent page might change (“4” is the id of the “articles” page in a default installation of Wolf):

<?php $children = $this->findById(4)->children(); ?>
<ul>
  <?php foreach ($children as $child) : ?>
  <li><?php echo $child->link(); ?></li>
  <?php endforeach; ?>
</ul>
1) See the "id" documentation on how to find the ID of any given page.
 
functions/findbyid.txt · Last modified: 2012-06-04 16:12 by David
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 wolfcms.org / design by yello studio / Wolf CMS Inside