nblgeoweb VIP
Total posts: 178
17 Apr 2014 16:20

I'm playing with a Cobalt project where I am not using categories and instead just relying on filters to navigate through records. There are 3 content types. They are similar enough that I can make a record list template to display them all in the same listing.

One thing that could be quite interesting is that if I apply a content type filter, I would like to switch record list templates to one that is more specific to the type selected. Of course this would only work if I have only selected one content type in my filter. I can probably code up a template that checks the filter and value to change the way the list looks but it would be nice if this was built in to Cobalt. Maybe it can be done already and I just haven't figured out how?

Last Modified: 20 Apr 2014


nblgeoweb VIP
Total posts: 178
17 Apr 2014 16:35

I've been playing with the default record list template and it almost gives me what I need... It only displays columns in the list table for fields that exist in the content types being displayed. Using that I just need to exclude all but certain fields for a record list when no content type filter is selected but include certain fields depending on what content type filter is being used. Do you have a suggestion for how to do that?


pepperstreet VIP
Total posts: 3,837
17 Apr 2014 18:08

This feature is available for Categories. Each category has a respective template parameter. And you can switch the display accordingly. So, you should consider to use "categories" instead. Simply limit/force 1 type to submit in a certain category. You can also filter by category. Actually everything you need is build-in.

(What was your main reason to choose type as filter?)


nblgeoweb VIP
Total posts: 178
18 Apr 2014 00:11

I started with categories but I want to be able to have the ability to have different "views" of the categories - change which ones are visible depending on the type of user is viewing the data. Each type of user would see a subset of the categories (and their subcategories) - essentially filtering categories. There wasn't a way to do it with categories (already discussed in an earlier thread) but with filters I seem to be able achieve the same results by using fields in records that I filter. Then a user can select which "view" of the available data they want by selecting one of my filter links.

In looking at the code for the template, it looks like I could just check which content type is specified in the filter and modify the exclude list via PHP. Doesn't look very hard actually. It's a bit of a workaround but it doesn't require any core changes.


Sergey
Total posts: 13,748
18 Apr 2014 03:51

I will not be able to immplement it into Cobalt. But here is best way to achieve this.

You have to edit and create new markup template.

  1. Add new parameters to markup template XML file into general fields group any fieldset in it.
<field label="Template for type 1" name="tmpl_list_1" type="mersubtmpls" multi="1" default="default" tmpltype="itemlist"/>

Each ror every type. Change name for every parameter. For easy to use you can use _1 in paramter name equal to type ID.

We have to useit because every template also accept set of parameters along with it. And this element will add special button to configure template look.

  1. Now in template you can access this parameter through $markup->get('general.tmpl_list_1').

  2. In markup php file find line 665 <?php echo $this->loadTemplate('list_'.$this->list_template);?>. All you have to do not is to check if type filter is on and change it to <?php echo $this->loadTemplate('list_'.$markup->get('general.tmpl_list_'.$type_id));?>

  3. how to you get $type_id? Use $this->worns. This is an array of all applied filter.

foreach($this->worns AS $worn)
{
    if($worn->name = 'filter_type')
    {
        $type_id = array_shift($worn->value);
    }
}

nblgeoweb VIP
Total posts: 178
20 Apr 2014 02:03

Thanks for the ideas, Sergey. I'll give it a try and see what I can come up with.

Powered by Cobalt