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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Parents and children query in the new SS Version 3 Beta 3


Go to End


5 Posts   2409 Views

Avatar
Besstel

Community Member, 1 Post

1 June 2012 at 2:16am

Edited: 01/06/2012 2:17am

I wrote a module that has a bit of a complicated structure with parents and children to be created in the site tree.

All worked fine in the previous version of Silverstripe, but the new one (version 3) is giving me the following error...

Any help from you guys?

ERROR [Warning]: Invalid argument supplied for foreach() IN GET /index.php/admin/pages/treeview Line 2388 in /home/website/public_html/itela.org/cms/code/model/SiteTree.php Source ====== 2379: * Returns an array of the class names of classes that are allowed 2380: * to be children of this class. 2381: * 2382: * @return array 2383: */ 2384: function allowedChildren() { 2385: $allowedChildren = array(); 2386: $candidates = $this->stat('allowed_children'); 2387: if($candidates && $candidates != "none" && $candidates != "SiteTree_root") { * 2388: foreach($candidates as $candidate) { 2389: // If a classname is prefixed by "*", such as "*Page", then only that 2390: // class is allowed - no subclasses. Otherwise, the class and all its subclasses are allowed. 2391: if(substr($candidate,0,1) == '*') { 2392: $allowedChildren[] = substr($candidate,1); 2393: } else { 2394: $subclasses = ClassInfo::subclassesFor($candidate); Trace ===== SiteTree->allowedChildren() CMSMain.php:364 CMSMain->SiteTreeHints() ViewableData.php:366 ViewableData->obj(SiteTreeHints,,,1) ViewableData.php:443 ViewableData->XML_val(SiteTreeHints,,1) call_user_func_array(Array,Array) SSViewer.php:130 SSViewer_Scope->__call(XML_val,Array) SSViewer.php:461 SSViewer_DataPresenter->__call(XML_val,Array) .cache.cms.templates.Includes.CMSMain_TreeView.ss:78 SSViewer_DataPresenter->XML_val(SiteTreeHints,,1) .cache.cms.templates.Includes.CMSMain_TreeView.ss:78 include(/tmp/silverstripe-cache-home-besstel-public_html-itela.org/.cache.cms.templates.Includes.CMSMain_TreeView.ss) SSViewer.php:778 SSViewer->includeGeneratedTemplate(/tmp/silverstripe-cache-home-besstel-public_html-itela.org/.cache.cms.templates.Includes.CMSMain_TreeView.ss,CMSPagesController,,Array) SSViewer.php:844 SSViewer->process(CMSPagesController,) ViewableData.php:335 ViewableData->renderWith(Array) CMSMain.php:647 CMSMain->treeview(SS_HTTPRequest) Controller.php:195 Controller->handleAction(SS_HTTPRequest) RequestHandler.php:168 RequestHandler->handleRequest(SS_HTTPRequest,DataModel) Controller.php:149 Controller->handleRequest(SS_HTTPRequest,DataModel) LeftAndMain.php:336 LeftAndMain->handleRequest(SS_HTTPRequest,DataModel) AdminRootController.php:88 AdminRootController->handleRequest(SS_HTTPRequest,DataModel) Director.php:281 Director::handleRequest(SS_HTTPRequest,Session,DataModel) Director.php:112 Director::direct(admin/pages/treeview,DataModel) main.php:126 require_once(/home/website/public_html/itela.org/framework/main.php) index.php:63

Avatar
camfindlay

Forum Moderator, 267 Posts

18 February 2016 at 10:52am

Can you let me know what you mean by "SS Version 3 Beta 3" we use semantic versioning now so the version will be in the format "x.y.z" eg 3.2.1

It would be useful if you posted the code that generates this stack trace as without any context on what you're doing it's hard to suggest a course of action for you.

Avatar
BigD1214

Community Member, 24 Posts

15 March 2016 at 4:58am

Edited: 15/03/2016 5:02am

Im having the same issue, I get an Warning saying i have invalid arument in SiteTree.php, I installed the new version 3.3.1 and have no access to pages anymore. Please help!
Here is the exact error
PHP Warning: Invalid argument supplied for foreach() in /cms/code/model/SiteTree.php on line 2692

Avatar
XorPush

Community Member, 10 Posts

29 April 2016 at 7:20pm

Edited: 29/04/2016 7:48pm

BigD1214
Did You find what was the problem? I have the very same problem as You.
Ok, after I removed 'none' => 'none' from $allowed_children from a custom page the problem was solved.
I have found this:
https://github.com/silverstripe/silverstripe-framework/issues/5171

Avatar
BigD1214

Community Member, 24 Posts

10 May 2016 at 1:06am

The Warning I get only really happens when I first load the pages section in the Admin. If i click it again it loads just fine.