Before I tried to also find solution to remove unwanted characters and also unwanted words from text that is fetched with function limitwords.
I found solutions for this on these three sites:
http://www.daniweb.com/forums/thread1721.html#
http://www.devdaily.com/php/php-string-
ce-numbers
http://www.experts-exchange.com/Program
46468.html
The new code for 1.8 would look like like:
Code:
//SEO stuff
function limitWords($res, $n) {
$a = explode(' ', $res);
return implode(' ', array_slice($a, 0, $n));
}
$s =strip_tags( $info['description']);
$res = preg_replace("/[^a-zA-Z0-9\s]/", "", $s);
$bad_words = explode('|', badword1|badword2|etc');
foreach ($bad_words as $naughty){
$res = eregi_replace($naughty, "", $res);
}
$res = preg_replace('/(\S ) +/', '$1', $res);
$smarty->assign('seo_desc', stripslashes($info['title']) . ' ' . $translations['jobscity']['jobs'] . ' ' . $translations['jobs']['preposition_at'] . ' ' . stripslashes($info['company']) . ' ' . $translations['jobscity']['sidebar_jobs_in'] . ' ' . stripslashes($info['location']) . '. ' . $translations['search']['default'] . ' ' . $translations['jobscity']['sidebar_jobs_in'] . ' ' . stripslashes($info['location']) . '. ' . limitWords($res, 15));
$smarty->assign('seo_keys', stripslashes($info['title']) . ', ' . stripslashes($info['title']) . ' ' . $translations['jobscity']['jobs'] . ', ' . stripslashes($info['company']) . ', ' . stripslashes($info['location']) . ', ' . stripslashes($info['location']) . ' ' . $translations['jobscity']['jobs'] . ', ' . stripslashes($info['location']) . ', ' . limitWords($res, 5));
You have to replace badword1, badword2... with words you do not want to show in your keywords.
I tested this here:
http://freejoblistings.ca/transportatio
ronto.html
For "bad words" I picked the words that have little value like the ones showing on almost every job post.
Has anyone managed to get this working on later versions? I still have jobberbase 1.6 with some parts manually updated, so I can not say for sure if this code will work on 1.8.
Also, if anyone knows a better way to do this, don't be shy.
Last edited by hobo (2010-04-23 01:56:24)