Jump to:

23370 Posts in 18160 Topics by 2864 members

General Questions

SilverStripe Forums » General Questions » Have a page as the rendering page for a specific DataObject but without a route to the page

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

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

Page: 1
Go to End
Author Topic: 598 Views
  • neros3
    Avatar
    Community Member
    51 Posts

    Have a page as the rendering page for a specific DataObject but without a route to the page Link to this post

    Hi

    Yes, the Title sounds a bit wierd.

    Im having a lot of products and I've made them DataObjects to avoid the SiteTree being filled up with items/products.
    Currently I have a Category_Controller which handles category view and product view via two routes.

    When rendering a product I would like to be able to use another page as the "rendering template". On this page I need a specific widget area that should not be shown on the category page. But since its the same controller that handles both category view and product view I can't seem to find a good solution to this.

    Any help is appreciated.

    Help:
    1. Maybe I could do with 2 widget areas? But is that possible?
    2. Also trying to set a page type on the Category object from the Category_Controller (product or category depending on wich method is fired via the routes). But it doesnt seem to be the same object I get when fetching Director::currentPage();

    Please let me know if you need further explaination as I know this all might sound a bit tricky!

    Thanks!

  • neros3
    Avatar
    Community Member
    51 Posts

    Re: Have a page as the rendering page for a specific DataObject but without a route to the page Link to this post

    I'll try to be a bit more clear...

    /products/{ProductCategory_Page}/{Product_Page}

    Both ProductCategory_Page and Product_Page are dynamic urls - but since Im using "DataObjects as pages" from ssbits.com I don't have a page for my Product in the sitetree. I only have a page for the ProductCategory. And since product category is dynamic (DataObject) I can't write a route for it (or at least I don't know that I can...).

    Makes sense anyone?

  • neros3
    Avatar
    Community Member
    51 Posts

    Re: Have a page as the rendering page for a specific DataObject but without a route to the page Link to this post

    Would it be possible to tell the ShowProduct action on ProductCategory_Controller to grab another Page and use that for the rendering?
    Of course this would require getting two pages - But could it work?

  • johannes
    Avatar
    Community Member
    20 Posts

    Re: Have a page as the rendering page for a specific DataObject but without a route to the page Link to this post

    Yesterday I worked on a project and I'm using one Page to list items and show the detail view. I don't use DataObjectAsPages, but it's a similar approach.

    I added the following code to the method fetching the data for the detail view:

    $data = DataList::create('MyDataObject')->filter('URLSegment', $url_segment)->first();

    if ($data) {
    return $this->renderWith(array('CustomTemplate', 'Page'), $data);
    } else {
    return array();
    }

    Maybe this works for you too.

    598 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.