LemonStand Forum: Can someone explain to me why there are no subpages being returned? - LemonStand Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Can someone explain to me why there are no subpages being returned?

#1 User is offline   IIzzII 

  • Member
  • Group: Members
  • Posts: 14
  • Joined: 08-March 12

Posted 23 March 2012 - 10:27 AM

Here is the code

$profile_page = Cms_Page::create()->find_by_url('/profile');
$pages = $profile_page->navigation_subpages();


I have a page with the url '/profile' and if I run something like $profile_page->title it returns the correct information so I know that it's getting the right page. However the $pages array is empty. I have my Change Password page and I set the Profile page as it's parent page. It is visible and it's assigned properly. If I use the code on this page

http://lemonstandapp...nd_breadcrumbs/

to output all the pages and their subpages then the pages appear there so I know that it's linked correctly. I want only my Profile subpages to have a menu that automatically generates the pages and it's just not working.
0

#2 User is offline   Aleksey 

  • Co-Founder
  • Group: +Administrators
  • Posts: 4,066
  • Joined: 31-October 09

Posted 25 March 2012 - 04:20 PM

Hi,

I tested your code in my installation and it worked properly. Please submit a support ticket. If there is a bug in LemonStand, we will fix and and release your support credit. If there is some configuration issue, we will help you to solve it.

Thank you

#3 User is offline   IIzzII 

  • Member
  • Group: Members
  • Posts: 14
  • Joined: 08-March 12

Posted 27 March 2012 - 10:09 AM

View PostAleksey, on 25 March 2012 - 04:20 PM, said:

Hi,

I tested your code in my installation and it worked properly. Please submit a support ticket. If there is a bug in LemonStand, we will fix and and release your support credit. If there is some configuration issue, we will help you to solve it.

Thank you


I solved the issue with help from support. It turns out the generic call I was using:

$profile_page = Cms_Page::create()->find_by_url('/profile');


will find any page with the url profile regardless of the theme being used. I was modeling my theme after the default theme so it was finding the profile page from the other theme. You need to use:

$params = array();
$profile_page = Cms_Page::findByUrl('/profile', $params);


this call will use the current theme and it worked perfectly for me.
0

#4 User is offline   Aleksey 

  • Co-Founder
  • Group: +Administrators
  • Posts: 4,066
  • Joined: 31-October 09

Posted 27 March 2012 - 01:02 PM

Hi,

Yes, that's correct. find_by_url() is a built-in ActiveRecord magic method which doesn't take into account themes. On the other hand findByUrl() is a method of Cms_Page class.

Thank you

Share this topic:


Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users