jimie VIP
Total posts: 531
28 Apr 2014 18:15

Hello

Can you help me with an idea of how can I be able to display some informations inside a modules based on the filters applied on the viewed section ?

For example I`m talking of:

When filter country = France display some informations inside that module about that country When filter city = Paris display some informations inside that module about that city

And also both in the same time like:

When filter country = france and filter city = paris display informations about country and city

Could you help me with that ?

rgds

Last Modified: 11 Dec 2014


Sergey
Total posts: 13,748
29 Apr 2014 14:02

Does the module shows records from the save section where those filters applied?


jimie VIP
Total posts: 531
29 Apr 2014 14:09

No, that modules is supposed to make some sql queries on some db tables where we will gonna store the informations about the country and city

Or do you suggest it would be better to add those informations in Cobalt as another section ?

rgds


Sergey
Total posts: 13,748
01 May 2014 16:07

If it is your tables with data stored your way, then it should be your writted code to retrive it and display.


jimie VIP
Total posts: 531
01 May 2014 16:27

But how do I find what filters are applied on the page using that module ?

rgds


Sergey
Total posts: 13,748
05 May 2014 03:34

This is very complicated system. In fact it is build so that you can apply different filters for every category. So you not always can get filters for section becuase it depends on filter mode.

But jenerally you can get them from state.

$filters = JFactory::getApplication()->setUserState('com_cobalt.section' . $key );

Where $key in most cases is a section ID. But sometimes may contain category ID, user ID, user category ID and other.


jimie VIP
Total posts: 531
05 May 2014 05:48

Hello

I gived a try for that but not sure it works for me, I`ve looked more inside Cobalt files and I found this:

<?php if($markup->get('filters.worns') && count($this->worns)):?>
<div class="filter-worns">
        <?php foreach ($this->worns AS $worn):?>
                <div class="alert pull-left">
                        <button type="button" class="close" data-dismiss="alert" onclick="Cobalt.cleanFilter('<?php echo $worn->name?>')" rel="tooltip" data-original-title="<?php echo JText::_('CDELETEFILTER')?>">
                        <img alt="X" src="/<?php echo JURI::root(TRUE)?>/media/mint/icons/16/cross.png"></button>
                        <div><?php echo $worn->label?></div>
                        <?php echo $worn->text?>
                </div>
        <?php endforeach;?>
        <?php if(count($this->worns) > 1): ?>
                <button onclick="Joomla.submitbutton('records.cleanall');" class="alert alert-error  pull-left">
                        <div><?php echo JText::_('CORESET'); ?></div>
                        <?php echo JText::_('CODELETEALLFILTERS'); ?>
                </button>
        <?php endif;?>

        <div class="clearfix"></div>
</div>
<br>
<?php endif;?>

Do you think I can use a records module and copy part of this code in the template used.

I see it renders the filter label name with:

label?>

and filter value with:

text?>

then maybe apply something like:

if $worn->lablel == 'country' {

     do this query and show informations for '$worn->text'

}

Dont know just my idea :)

rgds


jimie VIP
Total posts: 531
06 May 2014 10:32

What do you think Sergey will this be possible ?

Rgds


Sergey
Total posts: 13,748
06 May 2014 11:16

$this->worns is not part of the module. It is only in markup and articles list templates. I do not think it will work.


jimie VIP
Total posts: 531
06 May 2014 11:20

So what do you think is the solution here, we really need to find a way to do this

rgds


Sergey
Total posts: 13,748
06 May 2014 16:36

Try this

$filters = JFactory::getApplication()->setUserState('com_cobalt.section' . $key );
var_dump($filters);

Where $key is section ID. You will see if you have filters or not. Just make sure some filters are applied to the section.


jimie VIP
Total posts: 531
06 May 2014 17:43

I just did this:

$key = '1';
$filters = JFactory::getApplication()->setUserState('com_cobalt.section' . $key );
var_dump($filters);

But nothing displayed on the var_dump, just a NULL result


Sergey
Total posts: 13,748
07 May 2014 05:20

Did you apply filters for section ID 1?


jimie VIP
Total posts: 531
07 May 2014 05:24

Hello Sergey

Yes I applied some filters for that section, filters that as you know I`m displaying them with cobalt filters module.

I've tested that code in the list records page before starting the list records, could it be that the problem ? Should i use it on a php module instead ?

rgds


Sergey
Total posts: 13,748
08 May 2014 11:01

This part of the code could be used anywhere to ged section state and then there you can find filters and othr things.


jimie VIP
Total posts: 531
09 Dec 2014 12:15

Hey Sergey I really need your help with this.

So I`ve applied a country filter on the section with ID = 1

I`m using:

$key = '1';
$filters = JFactory::getApplication()->setUserState('com_cobalt.section' . $key );
var_dump($filters);

When i apply that filter, the result in the var_dump shows NULL, am I doing something wrong ?

I just want to find the name of the country selected in the filter I`ve applied

So then I can use the country name on a custom module

Rgds


Sergey
Total posts: 13,748
10 Dec 2014 03:09

Where you want to get access to the applied filters? In module template or markup template? In what file?


jimie VIP
Total posts: 531
10 Dec 2014 06:12

I`ve used that on a cobalt section statistics, for which I made a custom template and there I placed that code

Rgds


Sergey
Total posts: 13,748
11 Dec 2014 03:33

You mean module?

Try this

$filters = JFactory::getApplication()->setUserState('com_cobalt');
var_dump($filters);

And look what is inside. Sometimes key is not only section ID. Someitmes it is also category ID and other things.


jimie VIP
Total posts: 531
11 Dec 2014 06:25

Result is NULL

Sergey, really 2 days I`m waiting here, can you please test locally that before replying atlast ? or if not possible to help with I'd preffer to hear that.

Thanks

Powered by Cobalt