Assign a page to two parents/links Silverstripe
-
27-10-2019 - |
문제
I'm using Silverstripe to display product items, and sometimes one product item belongs to two different categories/pages. Is it possible to assign a page to two parents? If not is it possible to use a link for the product item and link it to two different categories/pages? That is something like this:
category/page: Breakfast
subpages: ----------------------bread
------------------------------------cereal
category/page: Lunch
subpages: -----------------------bread
-------------------------------------pasta
Is it possible to create one page called bread in the admin section of Silverstripe but it will be under two pages (eg breakfast and lunch).
If assigning one page to two parents not possible, can I use a link for page bread to two pages(breakfast and lunch)? How do I go with it? Any tutorials or modules?
Any help is appreciated.
Thanks, Sam :)
해결책
If I understand you correctly, you want to have pages with N (1 .. *) parents. However pages have exactly one parent (except for the root page). Take a look at the underlying code: All pages inherit from sapphire/core/model/SiteTree.php
. In $extensions
you can see the link to sapphire/core/model/Hierarchy.php
where you have the has_one
defined for the parent page. While you could extend SiteTree, the CMS couldn't handle this, so you would also need to rework part of the CMS. I don't think that's what you want.
I think what you are looking for are DataObjects as pages. Take a look at http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/ which describes this. You'll need to add many_many
relationships and everything else you need on your "pages", but you'll have all the flexibility you want.
Feel free to post any follow-up questions.