FORUMS CLOSED DUE TO SPAM. YOU STILL CAN ADD POST!

Anyone give me a hand? Please?

Feed 2 posts, 2 voices

Avatar
1 posts

Hey Guys,

I’m new to this forum and am also relatively new to PHP and mySQL Development, i have dabbled in the past with it. I am currently trying to use Frog CMS to provide a new method of getting my designs out there in an easy manor for my clients that allows them to update the site content on their own.

I am trying to make a template that will handle itself and the creation of sub-menus, however have hit a snag. The submenu will work using the following:

<div class="submenu">
   <ul>
     <?php foreach($this->find($this->slug())->children() as $menu): ?>
 	<li><?php echo $menu->link(); ?></li>
	<?php endforeach; ?>
   </ul>
</div>

However once i get move from the first level pages to the second level (ie. /page/secondpage/) i get the following error: Fatal error: Call to a member function children() on a non-object in /home/ap/public_html/UniPress/frog/app/frontend/classes/Page.php(330) : eval()‘d code on line 8

Could any one give me a hand please? It would be greatly appreciated :D

Cheers
Pottsy

 
Avatar
651 posts

The error message is due to the fact that your attempt to $this->find() some page didn’t work. Check if the find() action returned an actual object before trying to access its children() funtion.

Mind you… you don’t actually need to find the page since $this already refers to the current page. You can also use childrenCount() to check the number of children a page has.

i.e. try something like:

<div class=“submenu”>
  <ul>
  <?php
  $children = $this->children();
  <?php foreach($children as $menu): ?>  <li><?php echo $menu->link(); ?></li>  <?php endforeach; ?>  </ul>
</div>
 
Avatar
1 posts

Brilliant, Thanks very much mate!