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

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


Go to End


4 Posts   1887 Views

Avatar
neros3

Community Member, 51 Posts

22 May 2012 at 10:27am

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!

Avatar
neros3

Community Member, 51 Posts

23 May 2012 at 7:01am

Edited: 23/05/2012 7:10am

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?

Avatar
neros3

Community Member, 51 Posts

23 May 2012 at 7:07am

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?

Avatar
johannes

Community Member, 20 Posts

23 May 2012 at 8:39pm

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.