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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Can I set filter on CMS page before it loads?


Reply

5 Posts   1327 Views

Avatar
zim

12 November 2009 at 5:38am Community Member, 135 Posts

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?

Avatar
Double-A-Ron

15 November 2009 at 9:16pm Community Member, 604 Posts

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

Avatar
UncleCheese

16 November 2009 at 5:31am 4085 Posts

If you're going to force the filter, why use a dropdown filter? Why not just use the filter clause in the DOM constructor?

Avatar
Double-A-Ron

16 November 2009 at 9:42am (Last edited: 16 November 2009 9:53am), Community Member, 604 Posts

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

Avatar
zim

23 November 2009 at 12:29pm Community Member, 135 Posts

Thanks for advice.. I had to change my model in the end and do things differently. BUt thanks