|
mod for shorter url and title October 22, 2007 08:19AM |
Registered: 6 years ago Posts: 129 |
if ($_max_len_title==""{ $_max_len_title=40; } if ($_start_char_title==""
{ $_start_char_title=18; } if ($_end_char_title==""
{ $_end_char_title=7; } if ($_max_len_url==""
{ $_max_len_url=35; } if ($_start_char_url==""
{ $_start_char_url=18; } if ($_end_char_url==""
{ $_end_char_url=10; }
/** * Limit number of characters to show on title and url */ fwrite($fhandle, "\n\n// Max length of title to show on result the page.\n" fwrite($fhandle,"$"."max_len_title = ".$_max_len_title. ";"
; fwrite($fhandle, "\n\n// Max length of url to show on result the page.\n"
; fwrite($fhandle,"$"."max_len_url = ".$_max_len_url. ";"
; /** * Show x characters at beginning and at the end */ fwrite($fhandle, "\n\n// Number of characters to show at beginning of title.\n"
; fwrite($fhandle,"$"."start_char_title = ".$_start_char_title. ";"
; fwrite($fhandle, "\n\n// Number of characters to show at end of title.\n"
; fwrite($fhandle,"$"."end_char_title = ".$_end_char_title. ";"
; fwrite($fhandle, "\n\n// Number of characters to show at beginning of url.\n"
; fwrite($fhandle,"$"."start_char_url = ".$_start_char_url. ";"
; fwrite($fhandle, "\n\n// Number of characters to show at end of url.\n"
; fwrite($fhandle,"$"."end_char_url = ".$_end_char_url. ";"
;
<!-- Max length of title on result page - added by Diego --> <tr> <td class="left1"><input name="_max_len_title" type="text" value= "<?php print $max_len_title;?>" id="max_len_title" size="5" maxlength="2"> </td> <td>Max length of title to show on result the page.</td> </tr> <!-- Number of characters to show at beginning of title on result page - added by Diego --> <tr> <td class="left1"><input name="_start_char_title" type="text" value= "<?php print $start_char_title;?>" id="start_char_title" size="5" maxlength="2"> </td> <td>Number of characters to show at beginning of title on result page.</td> </tr> <!-- Number of characters to show at end of title on result page - added by Diego --> <tr> <td class="left1"><input name="_end_char_title" type="text" value= "<?php print $end_char_title;?>" id="end_char_title" size="5" maxlength="2"> </td> <td>Number of characters to show at end of title on result page.</td> </tr> <!-- Max length of url on result page - added by Diego --> <tr> <td class="left1"><input name="_max_len_url" type="text" value= "<?php print $max_len_url;?>" id="max_len_url" size="5" maxlength="2"> </td> <td>Max length of url to show on result the page.</td> </tr> <!-- Number of characters to show at beginning of url on result page - added by Diego --> <tr> <td class="left1"><input name="_start_char_url" type="text" value= "<?php print $start_char_url;?>" id="start_char_url" size="5" maxlength="2"> </td> <td>Number of characters to show at beginning of title on result page.</td> </tr> <!-- Number of characters to show at end of url on result page - added by Diego --> <tr> <td class="left1"><input name="_end_char_url" type="text" value= "<?php print $end_char_url;?>" id="end_char_url" size="5" maxlength="2"> </td> <td>Number of characters to show at end of url on result page.</td> </tr>
if ($title=='')
$title = $sph_messages["Untitled"];
/**
* Show shorter title - added by Diego
*/
while( substr( $title, -$end_char_title, 1) !=' ' && $end_char_title < strlen($title) - $start_char_title - 3 ){
$end_char_title++;
}
while( substr( $title, $start_char_title, 1) !=' ' && $start_char_title < strlen($title) - $end_char_title - 3 ){
$start_char_title++;
}
$title = strlen($title) > $max_len_title ? substr($title, 0, $start_char_title)."...".substr($title, -$end_char_title):$title;
$url2 = $url;
/**
* Show shorter url - added by Diego
*/
if (strlen($url2) > $max_len_url) {
$url2 = substr($url2, 0, $start_char_url)."...".substr($url2, -$end_char_url) ;
}
/*
if (strlen($title) > 80) {
$title = substr($title, 0,75)."...";
}
*/
That all.
|
Re: mod for shorter url and title October 27, 2007 05:17AM |
Registered: 5 years ago Posts: 3 |
|
Re: mod for shorter url and title October 27, 2007 06:42AM |
Registered: 6 years ago Posts: 129 |