Guest
22 Apr 2014 13:45

Hi there

Cobalt running great!

I am strugling to figure out, how (in article list) I can get the data sorted by pressing the column title / label. This is on my custom fields. As I can't find anything in the settings, I assume I have to mess with the template. My php skills are very limited though! To me it looks like it's this code I want to fiddle with (in particular the 4th line):

        <?php foreach ($this->total_fields_keys AS $field):?>
            <?php if(in_array($field->key, $exclude)) continue; ?>
            <th width="1%" nowrap="nowrap">
                <?php echo JText::_($field->label);?></th>
        <?php endforeach;?>

Will I have to put in an if statement to check whether my field is sortable and then create a link or something? Or do I need to hardcode each column?

I want a very simple design on my page and have therefore removed the adminform and search field, hence sorting on the title will be ideal.

A few minor questions related to this: Is it possible to get a different label than the field name or make a description come up when mouse is hovering over label? If I want a field before the title, should I hardcode this in and then exclude it in settings? Is it possible NOT to have a label (again without hardcoding all of it), as some info is self-explanatory, e.g. a logo?

Thanks in advance if anyone can help:)

Regards

Ove

Last Modified: 23 Apr 2014


Sergey
Total posts: 13,748
23 Apr 2014 06:29

We do not call template modifications - hardcode. Because, Cobalt templates are made so it is always softcode. I mean it always preserve all your changes on next update. Just do not forget to create copy of the template before you start editing it.

You can also read this article on how to manage with custom templates.

To enable ordering by field, you have to turn ordering parameter inside the field. You can order only by fields that have this parameter.

order

Then in template you have to change

<?php echo JText::_($field->label);?>

And you are right. The snippet your showed is exactly where it is. Change it to.

<?php if($field->params->get('params.sortable')): ?>
    <?php echo JHtml::_('mrelements.sort', JText::_($field->label), FieldHelper::sortName($field), @$this->ordering_dir, @$this->ordering); ?>
<?php else: ?>
    <?php echo JText::_($field->label);?>
<?php endif; ?>

And I do not know how to add tooltip to ordering link generated by Joomla.

Also note that there is ordering menu contorl.

ordermenu


Guest
23 Apr 2014 12:30

Works like a charm! Thank you very much Sergey! Would have taken me a year to figure out the syntax!

Powered by Cobalt