Help printing navigation array based on pageID

Hi all

I’m working with a small snippet of code supplied via a tutorial library for a site I’m working on. The problem is, instead of printing all the navigation of the site, I just need to print the navigation based on the pageID.

Example,
The current code below displays a list of the sites navigation:
page 1
page 2
page 3
page 4
and so on…

$pageNav = new Navigation_PageNavigation();

$pageNav->printOut(array(
          // define the minimum level for navigation items, default = 1
          'min'=>1,
          // define the maximum level for navigation items, if set to default (= null)  
          // the maximum level is set to be equal to the minimum level
          'max'=>3,
          // defines if only active navigation items will be displayed, default = true 
          'activePath'=> true,
          // set true if title tag should be filled with page title, default = false
          'useTitleAlt'=> true,
          //  optional array for layout template replacements
          'additionalReplaces'=> array(),
          // defines  if also hidden pages are valid to be a neighbour sibling, 
          // default = false
          'showHidden'=> false,
          // define the active pageID,
          // if set to default (= null) or empty the current pageID is used by default 
          'page'=> null
        ));

Things are commented in the code above as you can see, though can’t understand how to build the array based on the pageID only?

I would like to show only:

Page 1
page 1 sublink
page 1 sublink2
page 1 sublink3

The sublinks are the pages nested inside the current pageIDs directory.
And $pageID prints 12.

Any help or guidance much appreciated.

Hi computerbarry,

Have you tried manually setting the ‘page’ option to the current pageID? Also, I googled the class name but couldn’t find any information… do you have a link to the documentation/source?

After chatting with a colleague, the solution I needed:

 $children = $activePage->getChildren(null,true);
    if (!empty($children)) {
    foreach($children as $child) {


<article class="<?=$child->ext_column_1 ?>">
     <a href="<?= $child->url ?>" class='article-border'>
        <img src="<?=$child->ext_column_2 ?>" alt="">
          ....

$activePage // active page is current page we see.
ext_column_1, _2, _3 are columns in the database.

My problem now is, I want to select all the values from a certain column, it being ext_column_1 or some other column.

How do I now change:

$children = $activePage->getChildren(null,true);
        if (!empty($children)) {
        foreach($children as $child) {

So I remove $activePage in the correct way so I can select all columns and not just for the pageID.
Any suggestions how I can amend the code to do this?

Thanks, Barry

Hi Barry,

Without seeing some documentation or source code for the class/library you’re using to generate the navigation, it’s impossible to say. How do you arrive at the var $activePage, where does that come from?

I’m glad that you asked, I thought I was going mad ha, I haven’t got a clue :smile:

[FYI] I’ve managed to find a solution which is working, this snippet is only for the home page ID 23, which lists a number of different articles from different categories, basically, a collection of all the latest articles in one place instead of separate pages…

if($pageID == 23): 
  // get all pages
  $pages = new TFW_Navigation($pageNav);
  $pages = $pages->getNavigation();
    foreach ($pages as $index => $topPage)
  {
  // get all child pages
  // sort, limits, check for existence of navigation extensions values
  $children = $topPage->getChildren(null,true);
  if (!empty($children)) {
    foreach($children as $child) {

One last issue if yourself fretburner, or anybody can help.
With the latest code above, I now need to organise this list of children into ascending order based on the last_modified column.

How can add this to the code above, any examples or feedback how this would work?

I was thinking something like:

foreach(usort($children as $child), 'last_modified') {

?

Thanks, Barry

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.