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.

Themes /

Discuss SilverStripe Themes.

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

Dynamic Blocks depending the Parent


Reply


911 Views

Avatar
LokNessMobster

Community Member, 1 Post

14 July 2009 at 6:28am

I have searched and I don't see any mention of this, I may be searching for the wrong words too so sorry if this has been covered. I am a little weary of posting since I feel like someone would of wanted to know about this by now.

Either way, I have basically two parents that have the same child pages beneath them, they are operating as store locations so they have their own blogs, events, etc.. My theme has two blocks in the header of each child page that contains the latest news and upcoming events. I made these blocks in the controller and have it returning what i need and it works how I want but I feel like their may of been an easier way and if not then this will maybe help someone else doing the same thing.

Either way I got a DataObjectSet of the information I need by querying with a Where clause using the pages ParentID for the blog container. Only problem is that I had to manually make defines for each sections BlogHolder ID to use in the ParentID comparison. I feel like their might be a better way to get only the content I need from anywhere within the child pages that doesn't involve me having to make defines for the ID's. I know that it is unlikely that they will change but it seems wrong to have hand typed those.

I switched to SS recently and loving it so far but before this I used primarily CodeIgniter, CakePHP, and Drupal so it might just be that i am used to building it from scratch myself and with Drupal I am used to everything being the way Drupal does it, which I don't particularly care for :) Either way, great CMS and I can see what the community is growing over here.

Any ideas or suggestions would be appreciated.

Thanks
Tom