Ivan Gretsky Posted May 26, 2016 Share Posted May 26, 2016 Hallo! Is it possible to create such a thing? To pass it to SimpleMarkupNavigation for example? Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 26, 2016 Share Posted May 26, 2016 PageArray's (as well as it's parent class WireArray) can only hold one dimensional data on their own. You could however try using a WireArray to hold multiple PageArrays. 2 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted May 26, 2016 Author Share Posted May 26, 2016 That is 2 levels maximum... I am sure there could be multiple usages for a "Shadow PageTree" kind of thing. Maybe there is a way to alter PageTree in-memory object? Whatever it is (my knowledge is limited here). Link to comment Share on other sites More sharing options...
LostKobrakai Posted May 27, 2016 Share Posted May 27, 2016 I'd really like to see a PageTree object, which can hold a (whole or partial) page tree in memory. This would allow for testing stubs and similar or the api creation of a whole tree branch at once. But sadly the PageFinder class is often dependent on mysql functionality, which by now does not have feature parity with the in memory selector engine. Also a page tree object is not really like a multidimensional array, but rather a array of pages, which optionally hold another array of children. The concept this is more like e.g. the pw form api does work with it's fieldgroups. I could imagine something like this: class Tree extends WireArray{ public function isValidItem($item) { return $item instanceof Branch; } […] } class Branch extends Wire{ protected $page; /** @var Tree $children */ protected $children; function hasChildren(){}; function getChildren(){}; function addChild(){}; […] } Edit: Really nice could also be a base Tree class, which both a PageTree as well as e.g. the Forms API could inherit from. This would also allow for easy implementation of other (custom?) tree based constructs. Nested comments for example just came to my mind. 3 Link to comment Share on other sites More sharing options...
Robin S Posted May 27, 2016 Share Posted May 27, 2016 To pass it to SimpleMarkupNavigation for example? If you literally want to pass it to MarkupSimpleNavigation you don't need a multidimensional PageArray. You just need a normal PageArray of root pages and MSN takes care of the recursion from the root pages. Link to comment Share on other sites More sharing options...
kongondo Posted May 27, 2016 Share Posted May 27, 2016 (edited) If you literally want to pass it to MarkupSimpleNavigation you don't need a multidimensional PageArray. You just need a normal PageArray of root pages and MSN takes care of the recursion from the root pages. I am guessing that what Ivan is after is a Menu Builder MSN combo....as per the conversation we had....starting from here...and culminating with a PageArray here..If there was a possibility to do an in-memory $page->child = myOtherPage...(without saving)...hence assign non-native/natural children to parent menu items....that would probably solve his problem (the multidimensional bit) ...but that is not possible, If it were, don't know if getting in-memory children would work though... Edited May 27, 2016 by kongondo 2 Link to comment Share on other sites More sharing options...
Robin S Posted May 27, 2016 Share Posted May 27, 2016 I am guessing that what Ivan is after is a Menu Builder MSN combo....as per the conversation we had....starting from here...and culminating with a PageArray here..If there was a possibility to do an in-memory $page->child = myOtherPage...(without saving)...hence assign non-native/natural children to parent menu items....that would probably solve his problem (the multidimensional bit) ...but that is not possible, If it were, don't know if getting in-memory children would work though... Okay, makes more sense now. @Ivan: Seems like it would be easier to leave MSN and Menu Builder out of it. If you know the page structure you want just build a normal PHP multi-dimensional array of page IDs or page paths, then turn these IDs/paths into page objects as you iterate over the array and output the necessary markup. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now