|
Forums ⇒ Miscellaneous ⇒ Search Engines ⇒ A Meta Tags enhancement I made for news
A Meta Tags enhancement I made for newsQuestions and issues with search engines, SEO, bots, meta tags.
Go to page Previous 1, 2
|
View previous topic :: View next topic |
| Author |
Message |
spacebar Dragonfly addicted


Offline Joined: Sep 28, 2005 Posts: 413 Location: Providence
|
Posted: Sat Feb 02, 2008 3:22 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
Yes, article.php is in the news module.
Backup your files before you ever add a change like this.
_________________

spacebar's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Unix / 2.0.46 (Red Hat) / 0.9.7a / 4.1.9-standard / 4.3.2 / 9.0.6.1
|
|
| Back to top |
|
 |
3DdesktopsUK Silver Supporter


Offline Joined: Mar 22, 2005 Posts: 195 Location: Surrey - UK
|
Posted: Tue Jun 03, 2008 10:01 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
Hi all and great post!!
Been looking for something like this for ages regarding Pages with duplicate meta descriptions that google keeps complaining about in my webmaster tools.
Can this be implemented on any module? specifically coppermine? Encouraging to hear spacebars experience of better SERP's too after doing it!! Interesting to know if this could be rolled out site wide using some kind of include file and how much of a job that will be?
Wish there were more great SEO tips and hacks like this, besides, that's what we all want isn't it? more traffic!!
love to hear your thoughts
_________________ Need a new 3D Desktop wallpaper? 3D Wallpapers UK - Original 3D Digital Wallpapers
3DdesktopsUK's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Windows 2003 Server / Apache / MySQL 5.0.41 / PHP Version 4.4.7 / CMS Version 9.1.2.1
|
|
| Back to top |
|
 |
layingback Forum Admin


Offline Joined: Apr 19, 2004 Posts: 1040
|
Posted: Thu Jun 12, 2008 12:26 am Post subject: Re: A Meta Tags enhancement I made for news |
|
spacebar, Thanks for this. I've added to my copy of Pro_News, and will wait to see the results. Thanks for posting!
_________________ Pro_News: The complete module for Dragonfly - now available as version 3.3
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) 2.6 - 3.6 / 1.3.42 - 2.2.12 / 5.0.92 - 5.1.37 - 5.1.54 / 4.4.49 - 5.2.17 - 5.3 / 9.2.1
|
|
| Back to top |
|
 |
3DdesktopsUK Silver Supporter


Offline Joined: Mar 22, 2005 Posts: 195 Location: Surrey - UK
|
Posted: Sun Jul 06, 2008 9:37 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
| Quote:: |
Been looking for something like this for ages regarding Pages with duplicate meta descriptions that google keeps complaining about in my webmaster tools.
Can this be implemented on any module? specifically coppermine? Encouraging to hear spacebars experience of better SERP's too after doing it!! Interesting to know if this could be rolled out site wide using some kind of include file and how much of a job that will be? |
* BUMP *
Google is penalising me because of all this duplicate - Please any help would probably save my site.
Thanks
_________________ Need a new 3D Desktop wallpaper? 3D Wallpapers UK - Original 3D Digital Wallpapers
3DdesktopsUK's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Windows 2003 Server / Apache / MySQL 5.0.41 / PHP Version 4.4.7 / CMS Version 9.1.2.1
|
|
| Back to top |
|
 |
NanoCaiordo Developer


Offline Joined: Jun 29, 2004 Posts: 3878 Location: Melbourne, AU
|
Posted: Sun Jul 06, 2008 10:02 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
bookmarked
_________________ .:: I met php the 03 December 2003 :: Unforgettable day! ::.
Linux 64bit / Apache 2.2 / PHP 5.4 / MySQL 5.5.22 / v9, v10
Linux 32bit / Apache 2.2 / PHP 5.3.10 / MySQL 5.5.22 / v9, v10
Windows 64bit / IIS 7.5 / PHP 5.3.10 / MySQL 5.5.22 / v9, v10
NanoCaiordo's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) mixed
|
|
| Back to top |
|
 |
Berty Newbie


Offline Joined: Aug 14, 2008 Posts: 30 Location: South of Spain
|
Posted: Sun Sep 21, 2008 1:44 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
I made a few fixes to it to suit my needs:
| PHP: |
<?php //Generate dynamic description $order = array("\r\n", "\n", "\r"); $replace = ' '; // Processes \r\n's first so they aren't converted twice. $new_desc = str_replace($order, $replace,strip_tags($hometext)); $order = array('"'); $replace = ' '; // Processes " so tags work. $new_keywords = str_replace($order, $replace,$new_desc);
$METATAGS['description'] = substr($new_keywords,0,255); $echoar=$new_keywords; //Generate dynamic keywords $new_keywords = " ".$new_keywords." "; $new_keywords = mb_strtolower("artículo noticias noticia historia " . $story['cattitle'] . " " . $story['title'] . " " . $new_keywords);
//Remove punctuation, etc $order = array(" "," ","[","]","}","{",",",".",":",":","!","(",")"); $new_keywords = str_replace($order, " ",$new_keywords);
//Remove common words $order = array_merge(array(" a "," about "," after "," against "," all "," almost "," also "," am "," an "," and "," another "," any "," are "," around "," as "," at "," b "," be "," because "," been "," before "," behind "," being "," both "," but "," by "," c "," came "," come "," comes "," could "," d "," did "," do "," does "," done "," e "," each "," either "," etc "," ever "," every "," example "," f "," few "," for "," from "," g "," go "," h "," had "," has "," have "," here "," how "," however "," i "," if "," ii "," iii "," in "," include "," included "," including "," into "," is "," it "," its "," iv "," ix "," j "," just "," k "," l "," m "," many "," may "," midst "," might "," my "," n "," nbsp "," neither "," never "," next "," no "," nor "," not "," now "," o "," of "," often "," on "," once "," or "," other "," others "," our "," over "," p "," put "," q "," r "," s "," same "," shall "," should "," since "," so "," some "," something "," sometimes "," soon "," such "," t "," than "," that "," the "," their "," them "," then "," there "," these "," they "," this "," those "," through "," to "," too "," toward "," u "," under "," underneath "," until "," us "," use "," used "," uses "," using "," usually "," v "," very "," vi "," vii "," viii "," w "," was "," we "," went "," were "," what "," when "," where "," whether "," which "," while "," who "," why "," with "," within "," without "," would "," x "," xi "," xii "," xiii "," xiv "," xix "," xv "," xvi "," xvii "," xviii "," xx "," y "," you "," your "," z "), array( " un ", " aqui ", " alli ", " aquí ", " allí ", " acerca ", " dejo ", " salido ", " atte ", " atentamente ", " buen ", " bueno" , " después ", " despues ", " hace ", " todo ", " casi ", " largo ", " montón ", " monton", " también ", " tambien", " soy ", " un ", " y ", " respuesta ", " cualquier ", " cualquiera ", " cualesquiera ", " lugar ","no son ", " son ", " alrededor ", " como ", " preguntar ", " preguntado ", " en ", " mal ", " ser ", " porque ", " sido ", " antes ", " siendo ", " mejor ", " mejores ", " entre ", " grande ", " por las dudas ", " pero ", " por ", " puede ", " no puede ", " venir ", " podría ", " no podría ", " día ", " dias ", " hizo ", " no hizo ", " hacer ", " hace ", " no hace ", " no ", " bajo ", " cada ", " etc ", " alterno ", " sino ", " aun ", " nunca ", " cada ", " cada uno ", " cada cual ", " todos ", " lejos ", " encontrar ", " para ", " encontrado ", " de ", " obtener ", " ir ", " yendo ", " ido ", " bueno ", " tener ", " tenido ", " tuve ", " he tenido ", " tengo ", " no tengo ", " teniendo ", " su ", " aqui ", " sus ", " hogar ", " cómo ", " cuándo ", " href ", " yo ", " si ", " ini ", " dentro ", " es ", " no es ", " esto ", " sólo ", " saber ", " gran ", " menos ", " como ", " parecido ", " pequeño ", " mirando ", " mirar ", " mirado ", " mirando ", " mucho ", " talvez ", " muchos ", " mi ", " más ", " mayor ", " demasiado ", " debe ", " no debe ", " mío ", " cerca ", " necesito ", " nunca ", " nuevo ", " noticias ", " no ", " ninguno ", " nada ", " ahora ", " fuera ", " a menudo ", " viejo " , " sobre ", " una vez ", " solamente ", " oops ", " o ", " otro ", " nuestro ", " nuestros ", " afuera ", " sobre ", " página ", " por favor ", " poner ", " pregunta ", " preguntas ", " preguntado ", " cita ", " preferir ", " realmente ", " reciente ", " dijo ", " vió ", " dicho ", " ella ", " ver ", " debería ", " sitios ", " chico ", " así ", " algún ", " algo " , " a veces ", " acullá ", " pronto ", " tomar ", " que ", " verdad ", " gracias ", " el ", " alli ", " ellos ", " luego ", " entonces ", " esos ", " estos ", " aquellos ", " pienso ", " travéz ", " fecha ", " fechas ", " para ", " demasía ", " bajo ", " hasta ", " incierto ", " arriba ", " hasta ", " use ", " usuarios ", " versión ", " muy ", " vía ", " querer ", " fué ", " camino ", " nosotros ", " bien ", " fueron ", " fuimos ", " no fuimos ", " cuando ", " dónde ", " cual ", " quién ", " quienes ", " porque ", " ancho ", " con ", " sin ", " palabra ", " malo ", " peor ", " podría ", " escrito ", " www ", " yes ", " ya ", " tu ", " tú ", " tus ", " AFAIK ", " IIRC ", " LOL ", " ROTF ", " ROTFLMAO ", " YMMV ") ); $replace = ' '; $new_keywords = str_replace($order, $replace,$new_keywords);
//remove duplicate words $new_keywords = preg_replace("/([,.?!])/"," \\1",$new_keywords); $parts = explode(" ",$new_keywords); foreach ($parts as $p){ if(strlen($p)>3){ $unique[] = $p; } } $unique = array_unique($unique); $unique = implode(" ",$unique); $unique_keywords = preg_replace("/\s([,.?!])/","\\1",$unique);
//make CSV list $order = " "; $replace = ','; $unique_keywords = str_replace($order, $replace,$unique_keywords); $unique_keywords = str_replace(",,", ",",$unique_keywords);
if (substr($unique_keywords,0,1) == ",") { $unique_keywords = substr($unique_keywords,1); }
if (strlen($unique_keywords) > 5) { $METATAGS['keywords'] .= $unique_keywords; } ?>
|
Well i basically changed "strtolower" to "mb_strtolower" as spanish characters like "ó, í, etc didn't showed the ? character. I also put part the removes the punctuation before the one that removes the common words as words that appeared with a dot at the end weren't deleted (for example "I will see this soon." -- soon wouldn't be deleted).
In addition, I put a minimum of characters for the keywords:
| PHP: |
<?php foreach ($parts as $p){ if(strlen($p)>3){ $unique[] = $p; } ?>
|
Also, for spanish speakers I have included the stopwords list of phpbb (+ a few others i needed in my website).
Hope it helps
Berty's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) WinXP Pro SP2/Apache ver. 2.2.8./MySQL 5.0.51b-community-nt (client: 5.0.51b)/PHP ver. 5.2.5/Dragonfly ver 9.2.1
|
|
| Back to top |
|
 |
Berty Newbie


Offline Joined: Aug 14, 2008 Posts: 30 Location: South of Spain
|
Posted: Sun Sep 21, 2008 1:51 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
Sorry for double post (I don't undestand why you have edit disabled for registered users...).
What file is available in ALL modules (even the ones I create myself)?
I would like to make a "Global function" for meta tag generation.
Berty's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) WinXP Pro SP2/Apache ver. 2.2.8./MySQL 5.0.51b-community-nt (client: 5.0.51b)/PHP ver. 5.2.5/Dragonfly ver 9.2.1
|
|
| Back to top |
|
 |
Phoenix • Many Posts •


Offline Joined: Apr 19, 2004 Posts: 8799 Location: Netizen
|
Posted: Sun Sep 21, 2008 2:13 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
edit is disabled because certain members in this community behave dishonestly - we're sorry that affects the genuine ones, but it's the unfortunate state of the internet these days.
_________________ • DonationsPro for DragonflyCMS, SMF, MyBB, vBulletin •
Phoenix's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
|
|
| Back to top |
|
 |
Berty Newbie


Offline Joined: Aug 14, 2008 Posts: 30 Location: South of Spain
|
Posted: Sun Sep 21, 2008 4:41 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
Ok I understand.
So, in which file should I put the function for the metatag generation so that it is available on all modules?
Berty's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) WinXP Pro SP2/Apache ver. 2.2.8./MySQL 5.0.51b-community-nt (client: 5.0.51b)/PHP ver. 5.2.5/Dragonfly ver 9.2.1
|
|
| Back to top |
|
 |
Phoenix • Many Posts •


Offline Joined: Apr 19, 2004 Posts: 8799 Location: Netizen
|
Posted: Sun Sep 21, 2008 5:13 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
I can't answer that because I haven't been through the posts, but you might consider this mod by BrokenCrust
» dragonflycms.org/Diges...ils/id=46/
Phoenix's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
|
|
| Back to top |
|
 |
Berty Newbie


Offline Joined: Aug 14, 2008 Posts: 30 Location: South of Spain
|
Posted: Sun Sep 21, 2008 5:43 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
I just need to know in which file I can put a function so that the function is sure to be available on all my modules.
Berty's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) WinXP Pro SP2/Apache ver. 2.2.8./MySQL 5.0.51b-community-nt (client: 5.0.51b)/PHP ver. 5.2.5/Dragonfly ver 9.2.1
|
|
| Back to top |
|
 |
Berty Newbie


Offline Joined: Aug 14, 2008 Posts: 30 Location: South of Spain
|
Posted: Sun Sep 21, 2008 6:18 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
Sorry for jumping in again.
Well I created a function (well its basically to generate the meta tags. I found out that the best file to have this function defined is in index.php (copy this code without the <?php ?> at the end of the file, just before:
| Code:: |
if (defined('HEADER_OPEN')) { require_once('footer.php'); } |
| PHP: |
<?php function metatags_gen($description,$data){ global $METATAGS; //Process Meta Tags //Created by spacebar //Updated by Berty //09/21/2008
//Generate dynamic description $order = array("\r\n", "\n", "\r"); $replace = ' '; // Processes \r\n's first so they aren't converted twice. $new_desc = str_replace($order, $replace,strip_tags($description)); $order = array('"'); $replace = ' '; // Processes " so tags work. $new_keywords = str_replace($order, $replace,$new_desc);
$description_output = substr($new_keywords,0,255); $echoar=$new_keywords; //Generate dynamic keywords $new_keywords = " ".$new_keywords." "; $new_keywords = mb_strtolower($data . " " . $new_keywords);
//Remove punctuation, etc $order = array(" "," ","[","]","}","{",",",".",":",":","!","(",")"); $new_keywords = str_replace($order, " ",$new_keywords);
//Remove common words $order = array(" a "," about "," after "," against "," all "," almost "," also "," am "," an "," and "," another "," any "," are "," around "," as "," at "," b "," be "," because "," been "," before "," behind "," being "," both "," but "," by "," c "," came "," come "," comes "," could "," d "," did "," do "," does "," done "," e "," each "," either "," etc "," ever "," every "," example "," f "," few "," for "," from "," g "," go "," h "," had "," has "," have "," here "," how "," however "," i "," if "," ii "," iii "," in "," include "," included "," including "," into "," is "," it "," its "," iv "," ix "," j "," just "," k "," l "," m "," many "," may "," midst "," might "," my "," n "," nbsp "," neither "," never "," next "," no "," nor "," not "," now "," o "," of "," often "," on "," once "," or "," other "," others "," our "," over "," p "," put "," q "," r "," s "," same "," shall "," should "," since "," so "," some "," something "," sometimes "," soon "," such "," t "," than "," that "," the "," their "," them "," then "," there "," these "," they "," this "," those "," through "," to "," too "," toward "," u "," under "," underneath "," until "," us "," use "," used "," uses "," using "," usually "," v "," very "," vi "," vii "," viii "," w "," was "," we "," went "," were "," what "," when "," where "," whether "," which "," while "," who "," why "," with "," within "," without "," would "," x "," xi "," xii "," xiii "," xiv "," xix "," xv "," xvi "," xvii "," xviii "," xx "," y "," you "," your "," z ", " LOL ", " ROTF ", " ROTFLMAO ", " YMMV "); $replace = ' '; $new_keywords = str_replace($order, $replace,$new_keywords);
//remove duplicate words $new_keywords = preg_replace("/([,.?!])/"," \\1",$new_keywords); $parts = explode(" ",$new_keywords); foreach ($parts as $p){ if(strlen($p)>3){ $unique[] = $p; } } $unique = array_unique($unique); $unique = implode(" ",$unique); $unique_keywords = preg_replace("/\s([,.?!])/","\\1",$unique);
//make CSV list $order = " "; $replace = ','; $unique_keywords = str_replace($order, $replace,$unique_keywords); $unique_keywords = str_replace(",,", ",",$unique_keywords);
if (substr($unique_keywords,0,1) == ",") { $unique_keywords = substr($unique_keywords,1); }
if (strlen($unique_keywords) > 5) { $keywords_output = $METATAGS['keywords'].$unique_keywords; } return array('description'=>$description_output, 'keywords'=>$keywords_output); } ?>
|
On article.php you will have to put (just before "require_once('header.php');"):
| PHP: |
<?php $METATAGS = metatags_gen($hometext, $story['title'].' '.$story['cattitle']); ?>
|
You can put this on all the modules you want. You just have to put:
| PHP: |
<?php $METATAGS = metatags_gen("Description", "keyword1 keyword2 keyword3"); ?>
|
Berty's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) WinXP Pro SP2/Apache ver. 2.2.8./MySQL 5.0.51b-community-nt (client: 5.0.51b)/PHP ver. 5.2.5/Dragonfly ver 9.2.1
|
|
| Back to top |
|
 |
fishingfan Newbie


Offline Joined: Aug 19, 2008 Posts: 7
|
Posted: Mon Mar 02, 2009 4:31 pm Post subject: Re: A Meta Tags enhancement I made for news |
|
My version changed from previous to limit the number of keywords to the most common ones.
| PHP: |
<?php function metatags_gen($description,$data){ global $METATAGS; //Process Meta Tags //Created by spacebar //Updated by Berty //09/21/2008 //Hacked about by FishingFan //to return up to 6 most common keywords //23/02/2009
//Generate dynamic description $order = array("\r\n", "\n", "\r"); $replace = ' '; // Processes \r\n's first so they aren't converted twice. $new_desc = str_replace($order, $replace,strip_tags($description)); $order = array('"'); $replace = ' '; // Processes " so tags work. $new_keywords = str_replace($order, $replace,$new_desc);
$description_output = substr($data,0,255); $echoar=$new_keywords; //Generate dynamic keywords $new_keywords = " ".$new_keywords." "; $new_keywords = mb_strtolower($data . " " . $new_keywords);
//Remove punctuation, etc $order = array(" "," ","[","]","}","{",",",".",":",":","!","(",")"); $new_keywords = str_replace($order, " ",$new_keywords);
//Remove common words $order = array(" a "," about "," after "," against "," all "," almost "," also "," am "," an "," and "," another "," any "," are "," around "," as "," at "," b "," be "," because "," been "," before "," behind "," being "," both "," but "," by "," c "," came "," come "," comes "," could "," d "," did "," do "," does "," done "," e "," each "," either "," etc "," ever "," every "," example "," f "," few "," for "," from "," g "," go "," h "," had "," has "," have "," here "," how "," however "," i "," if "," ii "," iii "," in "," include "," included "," including "," into "," is "," it "," its "," iv "," ix "," j "," just "," k "," l "," m "," many "," may "," midst "," might "," my "," n "," nbsp "," neither "," never "," next "," no "," nor "," not "," now "," o "," of "," often "," on "," once "," or "," other "," others "," our "," over "," p "," put "," q "," r "," s "," same "," shall "," should "," since "," so "," some "," something "," sometimes "," soon "," such "," t "," than "," that "," the "," their "," them "," then "," there "," these "," they "," this "," those "," through "," to "," too "," toward "," u "," under "," underneath "," until "," us "," use "," used "," uses "," using "," usually "," v "," very "," vi "," vii "," viii "," w "," was "," we "," went "," were "," what "," when "," where "," whether "," which "," while "," who "," why "," with "," within "," without "," would "," x "," xi "," xii "," xiii "," xiv "," xix "," xv "," xvi "," xvii "," xviii "," xx "," y "," you "," your "," z ", " LOL ", " ROTF ", " ROTFLMAO ", " YMMV "); $replace = ' '; $new_keywords = str_replace($order, $replace,$new_keywords);
//remove duplicate words $new_keywords = preg_replace("/([,.?!])/"," \\1",$new_keywords); $parts = explode(" ",$new_keywords); foreach ($parts as $p){ if(strlen($p)>3){ $unique[] = $p; } } //rank the keywords!!! $rank = array_count_values(array_map('strtolower', $unique)); arsort($rank); // $un = array_keys($rank); //return up to 6 keywords $n=1; $words = ""; $max = sizeof($un);
while ($n < $max && $n < 6) { $words = $words.",".array_shift($un); $n++; } //print_r("KEYS:\n".$words."\n"); if (strlen($words) > 5) { $keywords_output = $METATAGS['keywords'].$words; } return array('description'=>$description_output, 'keywords'=>$keywords_output); } //END OF META HACK!
|
fishingfan please enter your server specs in your user profile!
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|