PDA

View Full Version : Header Tags Controller



michael_s
02-28-2008, 05:21 AM
I used this function to collapse descriptions heavy with html markup into text blocks in my header_tags_fill_tags.php since even the first couple hundred characters was pulling a blank description otherwise!

function extractTextString($string)
{
if (!is_string($string))
return false;

$string = preg_replace(array('/n/', '/t/', '/r/'), ' ', trim(strip_tags($string)));
$string = preg_quote($string, '|');
$string = preg_replace('| +|', ' ', $string);
return $string;
}

I stuck this function in the top of the file and then around line 192 replaced like so:

/* if (isset($productsMetaDescLength) && (int)$productsMetaDescLength > 3 && (int)$productsMetaDescLength < strlen($products_tags['products_description']))
$desc = substr($products_tags['products_description'], 0, (int)$productsMetaDescLength);
else //length not entered or too small
$desc = $products_tags['products_description']; //so use the whole description
}
else
$desc = $products_tags['products_name'];

*/
$filtered_desc = extractTextString($products_tags['products_description']);

if (isset($productsMetaDescLength) && (int)$productsMetaDescLength > 3 && (int)$productsMetaDescLength < strlen($filtered_desc))
$desc = substr($filtered_desc, 0, (int)$productsMetaDescLength);
else //length not entered or too small
$desc = $filtered_desc; //so use the whole description
}
else
$desc = $filtered_desc;



More... (http://addons.oscommerce.com/info/207)