Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Breadcrumbs: characters limit  (Read 2036 times)

Olle Axelsson

  • Jr. Member
  • **
  • Karma: 3
  • Posts: 71
    • Eatlon.com
Breadcrumbs: characters limit
« on: July 08, 2007, 01:33:56 pm »

Hi guys.

Simple question:
How do I insert a limit of shown characters in the breadcrumbs function, similar to (or exactly like) the one used in "New comments"?

I'll give you a concrete example.

Instead of
"Home * Category * Article-name-long-as-hell"

I would like
"Home * Category *Article-name-lo..."

Cheers!
Logged
Eatlon.com
Free XHTML/CSS templates and a bucket of webdesign resources

bramsyuur

  • Hero Member
  • *****
  • Karma: 23
  • Posts: 873
    • http://snews.vietbee.net
Breadcrumbs: characters limit
« Reply #1 on: July 08, 2007, 07:58:19 pm »

Well, try with this code :)
Replace or modify your actual function breadcrumbs with this code:
Quote
//BREADCRUMBS
function breadcrumbs($size) { // Added the red code
   $link = ''.l('home').'' : l('home');
   $categoryName = retrieve('name', 'categories', 'seftitle', $categorySEF);
   if (!empty($categoryName)) {
      echo ' '.l('divider').' '.(!empty($articleSEF) ? $link.$categorySEF.'/" title="'.$categoryName.'">'.$categoryName.'' : $categoryName);
   }
   $articleTitle = retrieve('title', 'articles', 'seftitle', $articleSEF);
   // START [MOD] Short article names in breadcrumbs by bramsyuur
   $lengt = $articleTitle;
   $lengt = strlen($lengt) > $size ? substr($lengt, 0, $size - 3).'...' : $lengt;
   $lengt = str_replace(' ...', '...', $lengt);
   //if (!empty($articleTitle)) {echo ' '.l('divider').' '.$articleTitle;}  // Original code line
   if (!empty($articleTitle)) {echo ' '.l('divider').' '.$lengt;} //Modified code line
   // END MOD
   if (check_category($categorySEF) == true && $categorySEF != $home && $categorySEF != 'administration') {echo ' '.l('divider').' '.l($categorySEF);}
}
And call this function with 20); ?>
The number "20" is the example number of characters that you want to be showed in the breadcrumbs line.
If you don't want to use a shortened article name in breadcrums with this mod, simply, put a high number like 999 in the function call (or don't use this mod! hehehe :D)
I hope that this helps... ;)
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Espaņol

Olle Axelsson

  • Jr. Member
  • **
  • Karma: 3
  • Posts: 71
    • Eatlon.com
Breadcrumbs: characters limit
« Reply #2 on: July 08, 2007, 08:33:12 pm »

Worked fine. You're the man, Bram!
Logged
Eatlon.com
Free XHTML/CSS templates and a bucket of webdesign resources

bramsyuur

  • Hero Member
  • *****
  • Karma: 23
  • Posts: 873
    • http://snews.vietbee.net
Breadcrumbs: characters limit
« Reply #3 on: July 08, 2007, 09:37:51 pm »

I'm glad to help you  ;)
Logged
La comunidad sNews en tu idioma!
Comunidad sNews en Espaņol