Results 1 to 11 of 11

Thread: Trim Title

  1. #1
    Join Date
    Feb 2008
    Posts
    23

    Default Trim Title

    Hello,

    My directory categories have some very long titles. Does anyone how i can trim the title to lets stay 15 characters?

    Regards,

  2. #2
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    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.

  3. #3
    Join Date
    Aug 2008
    Location
    Paris, France
    Posts
    46

    Smile It is not very easy but feasible

    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

  4. #4
    Join Date
    Aug 2008
    Location
    Paris, France
    Posts
    46

    Default A few things more

    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

  5. #5
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    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.

  6. #6
    Join Date
    Aug 2008
    Location
    Paris, France
    Posts
    46

    Smile At least, works in 1.x

    Just checked it.

    Have a nice day
    Gus

  7. #7
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    Good to know though

  8. #8
    Join Date
    Feb 2008
    Posts
    23

    Default

    I had problem with Gus solution, but i found a workaround with the truncate option.

    Thank you guys!

  9. #9
    Join Date
    May 2007
    Location
    NJ, United States
    Posts
    1,651

    Default

    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

  10. #10
    Join Date
    Feb 2008
    Posts
    23

    Default

    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.

  11. #11
    Join Date
    Jun 2002
    Location
    Winnipeg Canada
    Posts
    4,913

    Default

    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

Similar Threads

  1. Replies: 5
    Last Post: 08-09-2008, 01:23 PM
  2. title
    By Hart_House in forum Tutorials, Hints & Tips
    Replies: 2
    Last Post: 12-31-2005, 04:42 AM
  3. %title% = %url%???
    By persut in forum v5.x
    Replies: 3
    Last Post: 08-17-2003, 10:05 PM
  4. title
    By gukkemben in forum v5.x
    Replies: 1
    Last Post: 02-05-2002, 05:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •