Hello,
My directory categories have some very long titles. Does anyone how i can trim the title to lets stay 15 characters?
Regards,
Hello,
My directory categories have some very long titles. Does anyone how i can trim the title to lets stay 15 characters?
Regards,
The title of the page is the title of the URL (meta title).
There is no easy way that I know of to trim the title unless the following works
<%$title|truncate:15%>
But again if I remember correctly that won't work on detail pages. Detail uses
title="Detail: $page_title"
So I supposed you should try
title="Detail: $page_title|truncate:15"
But I'm 99.9% positive that won't work.
If Bruce hint does not work, I guess this will do (no time left to test it, sorry) :
- add the 4 first lines of header.html on top of detail.html :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- create a copy of header.html, let's call it headershort.html without its 4 first lines
- add this section of php code after these 4 lines in detail.html
<%php%>
/* gets page title */
$new_title = $this->get_template_vars('page_title');
/* (for 80 letters truncation) */
$new_title = substr($new_title,0,80);
/* updates page_title with the new value */
$this->_tpl_vars['page_title'] = $new_title;
<%/php%>
- replace "header.html" by "headershort.html" in the include order
Hope this will do
Gus
1/ I came from my admin panel to reply, so I did not notice that the question was for 5.x and I use 1.x. But detail.html and header.html must not be very different, I suppose.
2/ If my idea works (still no time to check), it would probably be better to replace
$this->_tpl_vars['page_title'] = $new_title;
by
$this->_tpl_vars['new_page_title'] = $new_title;
and to replace $page_title by $new_page_title in the include
So you would not modify the normal $page_title variable, but create and use a brand new one.
I'll check this tomorrow if you have not, I just go to sleep now ;o)
Gus
In 5.x header.html and detail.html use totally different methods of fetching the title tag.
The code you are suggesting probably won't work in detail.html (for 5.x), but it's worth a shot.
Just checked it.
Have a nice day
Gus
Good to know though
I had problem with Gus solution, but i found a workaround with the truncate option.
Thank you guys!
Please post your work around incase others that read this need a similar solution![]()
FSGDAG | IndexU Hosting | Owner
Website | NiceCoder Script Hosting and More! | Web4URL is For Sale!
Follow Us On Twitter | FaceBook Profile | YouTube Videos
I used the following:
<%$category_nam|truncate:20%>
and for the keywords
<%if $keywords%>
<%$keywords|truncate:100%>
<%else%>
No keywords...
<%/if%>
For the keywords the problems is that some foolish webmasters define their keywords like this
soccer,ronaldo,kluivert,nistelrooy,rijkaard,gullit ,vanbasten etc
and not soccer,ronaldo, kluivert, nistelrooy, rijkaard, gullit, vanbasten
When the detail page is displayed the complete template is messed up. So i truncate the keywords after 100 characters.
I tried give my template a max width of 500px, but it won't work. If anyone has a solution to break this text like tihs
soccer,ronaldo,kluivert,nistelrooy,
rijkaard,gullit,vanbasten etc
I would be happy to learn.
You'd have to do it in phpmyadmin, but you could replace , with , (that's a comma followed by a space).
No idea how to do it, never done it.
No you can't do it globally, you'll blow up your database. You can ONLY do it in the keywords field