Sackgesicht VIP
Total posts: 1,636
25 Feb 2013 20:49

There might be times, when you want to shorten the article title.

Example --> relation (child/parent) list template.

Adding the following code will solve this - it will display the shortened title in full in a tooltip. The number of characters can be changed in the template parameter.

Add parameter to XML

            <field name="title_char" label="Number of Title Characters" type="text" size="3" default=""  />    

Replace line 309-315 in advanced table template

                                        <?php if(in_array($params->get('tmpl_core.item_link'), $this->user->getAuthorisedViewLevels() ) ) :?>

                                            <a     <?php echo ($params->get('tmpl_core.title_char') && (strlen($item->title) > $params->get('tmpl_core.title_char') ) ? 'rel="tooltip" data-original-title="'.$item->title.'"': NULL)?> 

                                                <?php echo $item->nofollow ? 'rel="nofollow"' : '';?> href="/<?php echo JRoute::_($item->url);?>"

                                            >

                                            <?php if ($params->get('tmpl_core.title_char') ) :?>

                                                <?php echo substr($item->title,0,$params->get('tmpl_core.title_char') ).(strlen($item->title) > $params->get('tmpl_core.title_char') ? "..." : NULL);?>

                                            <?php else:?>

                                                <?php echo $item->title?>

                                            <?php endif;?>

                                            </a>



                                        <?php else :?>

                                            <?php if ($params->get('tmpl_core.title_char') ):?>

                                                <span <?php echo ($params->get('tmpl_core.title_char') && (strlen($item->title) > $params->get('tmpl_core.title_char') ) ? 'rel="tooltip" data-original-title="'.$item->title.'"': NULL)?>>

                                                <?php echo substr($item->title,0,$params->get('tmpl_core.title_char') ).(strlen($item->title) > $params->get('tmpl_core.title_char') ? "..." : NULL) ;?>

                                                </span>

                                            <?php else:?>

                                                <?php echo $item->title?>

                                            <?php endif;?>

                                        <?php endif;?>    

Last Modified: 02 Mar 2014


Sergey
Total posts: 13,748
26 Feb 2013 09:05

Dou you mean that you want to hide rest of the title? I mean you want only one line of the title to be in the table? i think it is possible to make with custom css parameter in markup template. Since TD with title has special class

.has-context div h2 {

       white-space: nowrap;

    width: 100%;

    overflow: hidden;

    text-overflow: ellipsis;

}

I think you someone add this then title will be hidden according free space with ... as hide indicator. Of course h2 have to be the teg set for titles in template parameters. I think it is even simpler method.

Would you still vote for template parameter?


Sackgesicht VIP
Total posts: 1,636
26 Feb 2013 17:26

i use it for a relation list template (not the main list template) to shorten the name of a company (parent field) .. sometimes the name is very long. Since i know which company name was shortened, i display the full company name in a tooltip, so that i have still the full information in the list view.

See example:

I will look into your css solution ..


Sergey
Total posts: 13,748
26 Feb 2013 23:35

I will look into your css solution ..

I think this solution wil apply to parent title as well. So it will not work as expected.

I added parameter to next version.

Powered by Cobalt