7921 Posts in 1359 Topics by 933 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Can I set filter on CMS page before it loads?
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1154 Views |
-
Can I set filter on CMS page before it loads?

12 November 2009 at 5:38am
I have installed DataObjectManager and am storing Image, title, URL and Category. this resource is available on every page, so amended page.php with necesary code to create BannerResource Tab in CMS.
I am doing this for banners so I am setting the categories to Home, News, CaseStudies.
I would like that when I go to a case studies page in CMS and then click on BannerResources TAB then only the images which have been marked as CaseStudies for category will show up. I can do this once I have entered page as I have a drop down on the resources page created with
$manager->setFilter(
'Category', // The field we're filtering
'Filter by Category', // The label for the filter field
array(
'Home' => 'Home',
'CaseStudies' => 'CaseStudies',
'News' => 'News',
'Portfolio' => 'Portfolio'
) // The dropdown map of values => display text. The values will be matched against the Author field.
);But I want it to filter on load of page in CMS automatically. Does this make sense?
Can it be doen?
-
Re: Can I set filter on CMS page before it loads?

15 November 2009 at 9:16pm
Hi Zim,
I don't quite follow you sorry. Mainly because I don't understand your model for this.
Is Banner a DataObject? If so, can you post the code for this and the getCMSFields code for your Page.php?
Aaron
-
Re: Can I set filter on CMS page before it loads?

16 November 2009 at 5:31am
If you're going to force the filter, why use a dropdown filter? Why not just use the filter clause in the DOM constructor?
-
Re: Can I set filter on CMS page before it loads?

16 November 2009 at 9:42am Last edited: 16 November 2009 9:53am
Hi Zim,
What UC means is there is a filter clause when you create the DOM in your getCMSFields method.
Like this:
// Setup the Options table Dataobject manager
$options = new DataObjectManager(
$this,
'Banners',
'Banner',
array('Name' => 'Banner Name'),
'getCMSFields_forPopup',
"Category = '$this->Category'", // Here is the filter - Get a category from the page, and filter Banners by that Category only
'SubscriptionTerm ASC'
);
$options->setAddTitle('Pricing Option');Or something along those lines. (Sorry for lake of indentation - for the life of me I can't get indents to preseve when I submit posts)
Aaron
-
Re: Can I set filter on CMS page before it loads?

23 November 2009 at 12:29pm
Thanks for advice.. I had to change my model in the end and do things differently. BUt thanks
| 1154 Views | ||
|
Page:
1
|
Go to Top |


