Headliner: an SEO Mod for sNews

Par
Philippe Le Mesle
Publié le Classé dans COSE Lien permanent de l'article Tags : SEO ~ HTML5 ~ details ~ codeCommentaires (1)

A content search engine optimization (C.O.S.E.) script to maximize the volume or quality of traffic to a Web site (or a blog) from search engines via natural search results. It adds an headline in which you'll place synonyms related to the title of your page that will convince search engine spiders that you're the best!

Main goal of this Mod is to reinforce the semantics of a page/article by adding more informations for bots.

More of that, it can be useful for human readers too, depending on the way you gonna use it. This Mod has been made for my COSE-MS based on the v1.7 sNews and the idea can be adapted to others (some does already have this feature).

So if you want to increase the prominence of a webpage within the search results, this is a way to do it. • • •

What it does? When creating a page or article you will have a new field in the dark side of the sNews backend. This new field will be used (in this example) to add and extra H1 which can be displayed on the top of your page.
So (but it depends on how your template or Core is configured) you will have :

  1. H1: a summary/lead/headline of the article
  2. H2: the genuine title which goes with the META Title of the document
Is it clear? No?
Okey: have a look to this screenshot: L'histoire du Web Or have a look to the code there: L'Histoire du Web.
Still don't get it? Well, you probably don't need it.

SEO for content: just call it COSE

SEO Add-on script for sNews to get better rankinks

The Mod itself is pretty simple.
Although you'll need to change the database, to add a language variable, then to change the CORE and add a new function somewhere (better over the rainbow), so there are a few steps to go through.
READY?
STEADY:
First, backup your DB and sNews files!
GO!

The HOWTO

  1. Change the database. You can do make this change in various ways but the easiest is to use phpMyAdmin to add a field somewhere in the articles table with the following values (field, type, collation, null):
    h1_title, varchar(255), utf8_unicode_ci, null
  2. Next, open your EN.php language file located in the "lang" folder, find the # ADMINISTRATION LANGUAGE VARIABLES block and add the following line at the end of that block:
    $l['h1_title'] = 'H1 Title';
    That line will be the label for the input field in the admin panel.
    From this point, all changes are in snews.php.
  3. Look for:
    // Query for  / Category / subcategory / article /
    and add the text in red:
    if ($articleSEF && substr( $articleSEF, 0, 2) != l('paginator') && substr( $articleSEF, 0, 2) != l('comment_pages')) {
    $MainQuery = 'SELECT
    a.id AS id, title, position, description_meta, keywords_meta, h1_title,
    c.id AS catID, c.name AS name, c.description, x.name AS xname
    FROM '._PRE.'articles'.' AS a,
    '._PRE.'categories'.' AS c
    LEFT JOIN '._PRE.'categories'.' AS x
    ON c.subcat=x.id
    WHERE a.category=c.id
    '.$pub_a.$pub_c.$pub_x.'
    AND x.seftitle="'.$categorySEF.'"
    AND c.seftitle="'.$subcatSEF.'"
    AND a.seftitle="'.$articleSEF.'"
    ';
    }
    // Two queries for / Category / subcategory  /  OR   / Category / article /
    elseif ($subcatSEF  && substr( $subcatSEF, 0, 2) != l('paginator') && substr( $subcatSEF, 0,2) != l('comment_pages')) {
    $Try_Article = mysql_query('SELECT
    a.id AS id, title, position, description_meta, keywords_meta, h1_title,
    c.id as catID, name, description, subcat
    FROM '._PRE.'articles'.' AS a
    LEFT JOIN '._PRE.'categories'.' AS c
    ON category =  c.id
    WHERE c.seftitle = "'.$categorySEF.'"
    AND a.seftitle ="'.$subcatSEF.'"
    '.$pub_a.$pub_c.'
    AND subcat = 0
    ');
    $R = mysql_fetch_assoc($Try_Article);
    // query  for / category / article /
    if(empty($R)) {
    $MainQuery = 'SELECT
    c.id AS catID, c.name AS name, c.description, c.subcat,
    x.name AS xname
    FROM '._PRE.'categories'.' AS x
    LEFT JOIN '._PRE.'categories'.' AS c
    ON  c.subcat = x.id
    WHERE x.seftitle = "'.$categorySEF.'"
    AND c.seftitle = "'.$subcatSEF.'"
    '.$pub_c.$pub_x ;
    }
    } else {
    switch(true):
    case (substr( $categorySEF, 0, 2) == l('paginator')) :
    break;
    case (false !== strpos($categorySEF, 'rss-')) :
    die(rss_contents($categorySEF, $articleSEF));
    // Two queries for  / Category / OR  /Page/
    default:
    $Try_Page = mysql_query('SELECT
    id, title, category, description_meta, keywords_meta, position, h1_title,
    FROM '._PRE.'articles'.' AS a
    WHERE seftitle = "'.$categorySEF.'"
    '.$pub_a.'
    AND position = 3');
    // query  for category
    $R = mysql_fetch_assoc($Try_Page);
    if (!$R) {
    $MainQuery ='SELECT
    id AS catID, name, description
    FROM '._PRE.'categories'.' AS c
    WHERE seftitle = "'.$categorySEF.'"
    AND subcat = 0
    '.$pub_c;
    }
    endswitch;
    }
  4. Further down now, go to:
    if(!empty($R['description_meta']))  $_DESCR = $R['description_meta']; else $_DESCR = $R['description'];
    and paste below this line:
    if (!empty($R['h1_title'])) $h1_title = $R['h1_title'];
  5. Now, in // ARTICLES FORM find:
    echo html_input('text', 'title', 'at', $frm_title, l('title'), '',
    'onchange="genSEF(this,document.forms['post'].seftitle)"',
    'onkeyup="genSEF(this,document.forms['post'].seftitle)"
    ', '', '', '', '', '', '', '');
    Above it, paste this line:
    
    // COSE MOD#1
    	echo html_input('text', 'h1_title', 'at', $frm_h1_title, l('h1_title')
     ', '', '', '', '', '', '', '');
    //
  6. Further down find:
    $frm_action = _SITE.'?action=process&task=admin_article&id='.$id;
    Under it, paste this line:
    // COSE MOD#1
    	$frm_h1_title = $_SESSION['temp']['h1_title'
     $_SESSION['temp']['h1_title'] : $r['h1_title'];
    //
  7. Now in PROCESSING (CATEGORIES, CONTENTS, COMMENTS), find:
    $description = clean(entity($_POST['description']));
    and paste under it, this one:
    // COSE MOD#1
    	$h1_title = clean(entity($_POST['h1_title']));
    //
  8. Still in processing() function, find and add the text in red:
    case (isset($_POST['add_article'])):
    mysql_query("INSERT INTO "._PRE.'articles'."
    title, seftitle, text, date, category,
    position, extraid, page_extra, displaytitle,
    displayinfo, commentable, published, description_meta,
    keywords_meta, credits, show_on_home, show_in_subcats, artorder, h1_title)
    VALUES('$title', '$seftitle', '$text', '$date', '$category',
    '$position', '$def_extra', '$page', '$display_title',
    '$display_info', '$commentable', '$publish_article',
    '$description_meta', '$keywords_meta', '$cred', '$show_on_home',
    '$show_in_subcats', '$artorder', '$h1_title')");
  9. Now we need to add the function to display this H1_title somewhere in your article. You can add it into the Core or in an extra php file, the one where you store some Mods.
    // COSE MOD#1 (H1 TITLE FUNCTION)
    function page_description() {
    	global $categorySEF, $_DESC, $_TITLE, $h1_title;
    	if ($h1_title && check_category($categorySEF) == false) {
    		return $h1_title;
    	}
    	// UNCOMMENT IF YOU WANT H1 TO BE DISPLAYED ON PAGES
    	//elseif (check_category($categorySEF) == true ) {
    		//$default_pages = array('archive','sitemap','contact'); 
    		//if (in_array($categorySEF, $default_pages)) {
    			//$h1_title = l($categorySEF);
    		//}
    	//} elseif (!$categorySEF) {
    		//$h1_title = s('website_description');
    	//}
    	//return $h1_title;
    }
  10. Now the last part: the use. Just paste this instruction into your template:
    <?php if (page_description()) : ?>
    <h1><?php echo page_description(); ?></h1>
    <?php endif; ?>
    or in you CORE (in function articles())
    if (page_description()) :
    echo '<h1>'.$h1_title.'</h1>';
    endif;
    if (page_description()) condition will check the DB for the h1_title and if none, no extra title will be printed.

That's all folks

With these changes and additions you'll get a new text field in the Customize Panel when you create or edit an article. There you can put any text in, limited by default to 255 characters (if you need more chars then change the value in your DB settings).
This Mod wouln't have been released without the help of nukpana. All karmas should be delivered to him.

Note

On this blog coded in HTML5 code this function has been managed differently. As you can see (just below in the infoline) there's a new link provided. It opens the details HTML5 tag and delivers the content of the field in the database. So this Mod is versatile: you can use it as an headline, for a different title from the meta, or as a lead-in.
I hope you'll enjoy spiders with this feature and get better rankings for your articles in SERPs.




Commentaires :

Copywriting||#1
Copywriting
It was very useful. It gives additional tips on my copywriting skills in SEO. Thanks folk!

Les commentaires pour ce billet sont fermés