Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

WebService: SiteTree::get_by_link not working.


Go to End


5 Posts   1379 Views

Avatar
sherlack

Community Member, 10 Posts

2 June 2015 at 1:58am

Hi,

i'm developing a silverstripe / angularjs application. I made a controller that works as a web service that given a resource url it returns all related data to that resource.

The problem i'm having is that if I set off the property of "show in menus" the SiteTree::get_by_link($segment) function stops working. Is there away to fix this? or an alternative? My whole application depend on this function :'(

Thanks

Avatar
JonoM

Community Member, 130 Posts

2 June 2015 at 5:29am

Hi sherlack,

If you look at the get_by_link function you can see that the "Show in Menus" setting shouldn't make any difference. Is the page you're trying to retrieve definitely published?

Avatar
sherlack

Community Member, 10 Posts

2 June 2015 at 7:20am

Hi JonoM,

your right the get_by_link still working. The problem comes when accessing the Children() function.

Example:
$page = SiteTree::get_by_link($segment);

foreach($page->Children() AS $p) {
// Here is where i'm not getting the children page that have the "show in menu" false.
}

Sorry for the miss comunication. :)

Avatar
JonoM

Community Member, 130 Posts

2 June 2015 at 7:38am

Ah that's an easy fix then - you can use AllChildren() instead of Children() to include those not in menus.

Avatar
sherlack

Community Member, 10 Posts

2 June 2015 at 7:49am

That worked!!!!!! Thank you sir!