brianpat VIP
Total posts: 211
26 Apr 2013 09:27

Hi the great Sergey,

I have used seblod,k2,zoo, but now I am using Cobalt. I can say with confidence that Cobalt has got all the stuff which others have failed to do. I must admit that Cobalt is now the best in the CCK Market. You can do anything you want. However I have observed few things which i believe Sergey should concentrate to make it more helpful to build ur site using CCK. One of the things is search functionality. Currently mod_cobalt filter is there to do the job, but it is not a complete solution.

Currently I am facing an issue with it. I am using rocketsprocket and mod filter together for my front page search. I am not an CSS Expert of php expert. The issue I face is how can I arrange all the fields of filter module in 3 or 4 columns. Currently all the fields appear on one vertical line and also in one column. If it is a side bar, then it is ok. But if it is on home page ,one singe field in one row does not look good. Hence I want the fields be arranged on 3 columns. It will be a simple way to do, but I dont know how to do? Can you please help me telling me which file and what code whould I need to change. Can you please get me some php snippets for that?

Last Modified: 02 Mar 2014


Sergey
Total posts: 13,748
29 Apr 2013 01:44

Thank you for your prise. I very appreciate it. But it is not me along. Although it is my original idea and I have created first CCK for Joomla called JoomSuite Content. Only after 1.5 years ZOO was released. And then the rest. But the greatness of the Cobalt is the result of work of 10 different developers and ideas brain storm of oldest CCK community.

You can easily create what you want with filter module. You will have to edit module template. You wil need either create a copy of

modules/mod_cobalt_filters/tmpl/default.php

right in the same folder with different name or copy it to

templates/[template_name]/html/mod_cobalt_filters/

with the same name or any other name.

Then in module parameters in Layout chose file you have just created. And now you can edit it and not only create columns but even position filter fields implicitly.

echo $filters['gh34j2hg56h6v4k6vjhgv8jh9v9']->onRenderFilter($section, TRUE);

Where gh34j2hg56h6v4k6vjhgv8jh9v9 is the filter key. You can find key in fields list in backend.

But that is if you want to call explicitly. You can still scycle filters and just style it into 3 columns with CSS.


Sergey
Total posts: 13,748
30 Apr 2013 00:20

If you take all filters in dive and class it filter-container then every filter block you take in div and class it filter-element.

Then using CSS you can style .filter-element to width:30% and float left. This will automatically form 3 columns. But this is little bit simple way that can produce artefacts. The best way of course is to use bootstrap grid.

But if you are absolutely do not know what I am talking about, it is better you hire someone who will help you to style it as you want.


Guest
11 May 2013 16:24

echo $filters['gh34j2hg56h6v4k6vjhgv8jh9v9']->onRenderFilter($section, TRUE);

I tried this , but my page is broken.

it is throwing error message as below:

Fatal error: Call to a member function onRenderFilter() on a non-object in /modules/mod_cobalt_filters/tmpl/default.php on line 151

$cols = 3;

$rows = 3

if($rows <= 0) $rows = 0;

<?php foreach ($filters AS  $filter):?>

        <?php if(in_array($filter->key, (array)$params->get('field_id_exclude', array()))) continue;?>

<div class="row-fluid">

            <?php for($c = 0; $c < $cols; $c++):?>

        <legend>

            <?php if($params->get('show_icons', 1) && $filter->params->get('core.icon')):?>

                <span class="pull-left filter-icon"><?php echo HTMLFormatHelper::icon($filter->params->get('core.icon'));?></span>

            <?php endif;?>

            <?php echo $filter->label;?>

            <?php if($filter->params->get('params.filter_descr')):?>

                <small rel="tooltip" data-original-title="<?php echo JText::_($filter->params->get('params.filter_descr'));?>"><i class="icon-help"></i></small>

            <?php endif;?>

        </legend>

        <div class="well well-small<?php if($filter->isFilterActive()) echo ' active'?>">

            <?php if($filter->isFilterActive()):?>

                <!-- <img class="filter-close" onclick="Cobalt.cleanFilter('filter_<?php echo $filter->key?>')" rel="tooltip" data-original-title="<?php echo JText::_('CDELETEFILTER')?>" src="/<?php echo JUri::root(true)?>/media/mint/icons/16/cross-circle.png">-->

            <?php endif;?>

            <?php echo $filter->onRenderFilter($section, TRUE);?>

        </div>

</div>

    <?php endfor;?>

    <?php endforeach;?>

I am trying as above, but it does not work.


Sergey
Total posts: 13,748
11 May 2013 23:29

Please post here exact code that you used. The coe you have posted looks good and unchanged.


Guest
12 May 2013 02:36

Hi Sergey,

Thanks for your reply. I also need this feature. I think it helps lot to specify the column number in module filter backend configuration. i have tried, but not showing up. attaching the code here. i just modified little bit in the code.

<?php

/**

 * Cobalt by MintJoomla

 * a component for Joomla! 1.7 - 2.5 CMS ( http://www.joomla.org )

 * Author Website:  http://www.mintjoomla.com/ 

 * @copyright Copyright (C) 2012 MintJoomla ( http://www.mintjoomla.com ). All rights reserved.

 * @license GNU/GPL  http://www.gnu.org/copyleft/gpl.html 

 */

defined('_JEXEC') or die('Restricted access');

?>

<style>

.filter-icon {

    margin-right: 5px;

    line-height: 30px;

}

#filter-form input[type="text"][name^="filters"],

#filter-form input[type="text"][class="cdate-field"],

#filter-form select {

    width: 100%;

    box-sizing: border-box;

    margin: 0;

    min-height: 28px;

}

#filter-form select {

    margin-bottom: 5px;

}

.well.active {

    border: 3px solid;

    position: relative;

}

.well.active img.filter-close {

    position: absolute;

    top: -7px;

    right: -7px;

    cursor: pointer;

}

</style>

<form action="<?php echo JRoute::_('index.php');?>" method="post" name="filterform" id="filter-form">

    <?php if($params->get('filter_search', 1)):?>

        <div class="row-fluid <?php echo ( $state->get('records.search')? ' active' : NULL)?>">

            <input type="text" class="span12" name="filter_search" value="<?php echo $state->get('records.search');?>" />

        </div>

    <?php endif;?>

    <?php if(count($f_types) > 1):?>

        <legend>

            <?php if($params->get('show_icons', 1)):?>

                <span class="pull-left filter-icon"><?php echo HTMLFormatHelper::icon('block.png');?></span>

            <?php endif;?>

            <?php echo $params->get('type_label');?>

        </legend>

        <div class="well well-small<?php echo ( $state->get('records.type')? ' active' : NULL)?>">

            <?php if($params->get('filter_type_type') == 1):?>

                    <?php foreach ($f_types AS $type):?>

                            <label class="checkbox">

                                <input id="type-<?php echo $type->id?>" type="checkbox" name="filters[type][]" value="<?php echo $type->id?>"<?php echo $type->filter_checked?>>

                                <?php echo $type->name;?>

                            </label>

                    <?php endforeach;?>

            <?php else :?>

                <?php echo JHtml::_('select.genericlist', $f_types, 'filters[type]', null, 'id', 'name', $state->get('records.type'));?>

            <?php endif;?>

        </div>

    <?php endif;?>

    <?php if($params->get('filter_tags_type')):?>

        <legend>

            <?php if($params->get('show_icons', 1)):?>

                <span class="pull-left filter-icon"><?php echo HTMLFormatHelper::icon('price-tag.png');?></span>

            <?php endif;?>

            <?php echo $params->get('tag_label');?>

        </legend>

        <div class="well well-small<?php echo ( $state->get('records.tag')? ' active' : NULL)?>">

            <?php if($params->get('filter_tags_type') == 1):?>

                <?php echo JHtml::_('tags.tagform', $section, $state->get('records.tag'));?>

            <?php elseif($params->get('filter_tags_type') == 2):?>

                <?php echo JHtml::_('tags.tagcheckboxes', $section, $state->get('records.tag'));?>

            <?php elseif($params->get('filter_tags_type') == 3):?>

                <?php echo JHtml::_('tags.tagselect', $section, $state->get('records.tag'));?>

            <?php elseif($params->get('filter_tags_type') == 4):?>

                <?php echo JHtml::_('tags.tagpills', $section, $state->get('records.tag'));?>

            <?php endif;?>

        </div>

    <?php endif;?>

    <?php if($params->get('filter_users_type')):?>

        <legend>

            <?php if($params->get('show_icons', 1)):?>

                <span class="pull-left filter-icon"><?php echo HTMLFormatHelper::icon('user.png');?></span>

            <?php endif;?>

            <?php echo $params->get('user_label');?>

        </legend>

        <div class="well well-small<?php echo ( $state->get('records.user')? ' active' : NULL)?>">

            <?php if($params->get('filter_users_type') == 1):?>

                <?php echo JHtml::_('users.form', $section, $state->get('records.user'));?>

            <?php elseif($params->get('filter_users_type') == 2):?>

                <?php echo JHtml::_('users.checkboxes', $section, $state->get('records.user'));?>

            <?php elseif($params->get('filter_users_type') == 3):?>

                <?php echo JHtml::_('users.select', $section, $state->get('records.user'));?>

            <?php endif;?>

        </div>

    <?php endif;?>

    <?php if($params->get('filter_category_type')):?>

        <legend>

            <?php if($params->get('show_icons', 1)):?>

                <span class="pull-left filter-icon"><?php echo HTMLFormatHelper::icon('category.png');?></span>

            <?php endif;?>

            <?php echo $params->get('category_label');?>

        </legend>

        <div class="well well-small<?php echo ( $state->get('records.category')? ' active' : NULL)?>">

            <?php if($params->get('filter_category_type') == 1):?>

                <?php echo JHtml::_('categories.form', $section, $state->get('records.category'));?>

            <?php elseif($params->get('filter_category_type') == 2):?>

                <?php echo JHtml::_('categories.checkboxes', $section, $state->get('records.category'), array('columns' => 3));?>

            <?php elseif($params->get('filter_category_type') == 3):?>

                <?php echo JHtml::_('categories.select', $section, $state->get('records.category'), array('multiple' => 0));?>

            <?php elseif($params->get('filter_category_type') == 4):?>

                <?php echo JHtml::_('categories.select', $section, $state->get('records.category'), array('multiple' => 1, 'size' => 25));?>

            <?php endif;?>

        </div>

    <?php endif;?>

    $cols = 3;

    $rows = 3

    if($rows <= 0) $rows = 0;

    <?php foreach ($filters AS  $filter):?>

            <?php if(in_array($filter->key, (array)$params->get('field_id_exclude', array()))) continue;?>

    <div class="row-fluid">

                <?php for($c = 0; $c < $cols; $c++):?>

            <legend>

                <?php if($params->get('show_icons', 1) && $filter->params->get('core.icon')):?>

                    <span class="pull-left filter-icon"><?php echo HTMLFormatHelper::icon($filter->params->get('core.icon'));?></span>

                <?php endif;?>

                <?php echo $filter->label;?>

                <?php if($filter->params->get('params.filter_descr')):?>

                    <small rel="tooltip" data-original-title="<?php echo JText::_($filter->params->get('params.filter_descr'));?>"><i class="icon-help"></i></small>

                <?php endif;?>

            </legend>

            <div class="well well-small<?php if($filter->isFilterActive()) echo ' active'?>">

                <?php if($filter->isFilterActive()):?>

                    <!-- <img class="filter-close" onclick="Cobalt.cleanFilter('filter_<?php echo $filter->key?>')" rel="tooltip" data-original-title="<?php echo JText::_('CDELETEFILTER')?>" src="/<?php echo JUri::root(true)?>/media/mint/icons/16/cross-circle.png">-->

                <?php endif;?>

                <?php echo $filter->onRenderFilter($section, TRUE);?>

            </div>

    </div>

        <?php endfor;?>

    <?php endforeach;?>

    <input type="hidden" name="option" value="com_cobalt">

    <input type="hidden" name="view" value="records">

    <input type="hidden" name="section_id" value="<?php echo $section->id;?>">

    <input type="hidden" name="cat_id" value="<?php echo $cat_id;?>">

    <input type="hidden" name="user_id" value="<?php echo ($user_id ? $user_id.':admin' : 0);?>">

    <input type="hidden" name="view_what" value="<?php echo $vw;?>">

    <input type="hidden" name="task" value="records.filters">

    <input type="hidden" name="limitstart" value="0">

    <div class="form-actions">

    <button type="submit" class="btn btn-primary btn-large">

        <?php echo JText::_('CSEARCH');?>

    </button>

    </div>

</form>


Sergey
Total posts: 13,748
12 May 2013 03:50

But I still cannot find

$this->filters[$key]->onRenderFilter($section, TRUE);

Anywhere in the code. I just cannot understand what is not working?

Also note that I cannot teach you PHP. I can only tell you what to use to show Cobalt staff but not basic PHP knowledge. For example in code you posted there is

$cols = 3;

$rows = 3

if($rows <= 0) $rows = 0;

Which is PHP code but it is placed as text.


Guest
12 May 2013 15:18

maybe it can help

<?php

$data = [];

$i = 0 ;

Foreach( $data as $d){

if($i > 0 && ($i % 3)) {

Powered by Cobalt