quick mod edits that add pretty keywords to your messages for SEO

Started by ladynada, May 06, 2007, 05:14:30 PM

Previous topic - Next topic

ladynada

I decided to make a new topic in case anyone would be interested in making these easy mods to their forum.  First of all, I am using a mod that is a BETA version posted in this thread:

http://www.simplemachines.org/community/index.php?topic=160779.0

Briefly, what it does is copy your entire forum messages into plain text files and stores them in an archive folder on your web server and you can direct search engine robots in the robots.txt to look there for all your messages.  It picks up the first several words in each new topic and makes them into keywords for the plain text web page of that entire topic; I modified mine as you can read on the other thread.  I have seen some of my pages rank higher with this method. also you have a backup of your messages that people will see from search engine links even when your forum might be down.  this is not for everyone so, be sure you know what you are doing, since your listings in search engines will point to these files and not necessarily directly to links on your forum; although there are direct links on the pages to your forum and even to reply, AND you can add your own html to the pages.  look at mine, I even added part of the forum menu to mine.

okay.. so below is the post I made today, because I made these little changes so that I myself can put keywords at the top of new topic postings ( I post the most on my forum right now, be aware that most members do not use this kind of feature ).  and this SEO mod picks up the keywords I put in, and I used styles.css to make it look purdy for the users... there are other benefits, if you think about it.

most people say meta keywords do not matter, but for me, maybe it is the kind of content I have, because I see niche topics from my forum rank on the first page of results on google from this.



I am back to cause people to twiddle their hair between their fingers.

Earlier I mentioned that  I want to add keywords to the top of a new topic posting.  well, here is what I done did.

in post.template.php add to the array



'kword' => array('code' => 'kword', 'before' => '[kword]', 'after' => '[/kword]', 'description' => 'Keywords'),



in your sources folder add to Subs.php after you make a backup


array(
'tag' => 'kword',
'before' => '<div class="kword">',
'after' => '</div>',
'block_level' => true,
),


make yourself a little KW button and put it in your images/bbc/ folder called kword.gif



you can use mine if you want

in your styles.css created a new class like this


.kword
{
color: #FFFF00; /* bright yellow */
font-size: medium;
text-align: center;
padding: 5px 1px 5px 1px;
background: url(images/kword.jpg) repeat;
border: inset 3px #6B4913;
background-color: #EFEBDD; /* lite tan */

}


make your self a nice graphic that is opposite your color scheme, so if you have a light scheme, make it dark back with bright letters.  its up to you  :)

so here is how it looks in the archive

http://www.heartdaughter.com/archive/antichristkingdom/smf/1178473268.shtml

here is what ends up in the html


<meta name="keywords" content="carnal death blood guts devastation mainstream media news MSM This is all about the mind and absolute BEAST within us If this does not prove to you that we needed a Saviour be renewed completely into new being then I" />


and here is how it looks on the forum



WORK for Truth, Print it, Take Time to READ ALL LINKS NOTED  click here --> The TWO Witnesses are Mom and Dad and SMF Skins

ladynada

actually, put this  in a google search to see what the seo mod does

site:heartdaughter.com

be advised, some of the stuff is not what it is like now, because all along the way, I kept modifying the code

okay
nada
WORK for Truth, Print it, Take Time to READ ALL LINKS NOTED  click here --> The TWO Witnesses are Mom and Dad and SMF Skins

ladynada

I posted a new thread related to this issue here:

How to add meta name keywords from the post that is being read in SMF

I will post the tip here, but please see that thread for warnings and other discussion:



NOTE: EDITED to fix bug at 6:27pm est may 14 2007
How to add meta name keywords from the post that is being read in SMF

First, make a backup of your Sources/Display.php
I named mine, Display_051407_1442.php

Pick the theme you want this to work for and make a backup of your
theme_dir/index.template.php
I named mine, index.template_051407_1452.php

okay now you can play.

In Display.php look for:



function Display()
{
global $scripturl, $txt, $db_prefix, $modSettings, $context, $settings;


Change to:


// The central part of the board - topic display.
function Display()
{
global $scripturl, $txt, $db_prefix, $modSettings, $context, $keywords, $settings;



Notice that all we did was add the var $keywords to the global command so that it's value will be
held between function calls.

okay we need another one, In Display.php look for:



// Callback for the message display.
function prepareDisplayContext($reset = false)
{
global $settings, $txt, $modSettings, $scripturl, $options, $user_info;


Change to:



// Callback for the message display.
function prepareDisplayContext($reset = false)
{
global $settings, $txt, $modSettings, $scripturl, $options, $keywords, $user_info;



Nice.. this is gonna be real easy to do.

next, In the bottom of Display.php look for:



return $attachmentData;
}


and then ADD AFTER the last bracket



function trunc($phrase, $max_words)
{
   $phrase_array = explode(' ',$phrase);
   $phrase = implode(' ',array_slice($phrase_array, 0, $max_words)).'';
   return $phrase;
}


Thanks go out to inthe80s who's code this is from his mod at this thread:
Create a standalone HTML version of your messageboard - beta

This function will be used to  cut the number of keywords, now set to 40.

Ok now in Dispaly.php look for:



}

// Callback for the message display.



And ADD BEFORE the closing } the following:



// Routine to prime the var $keywords with words from the message body being viewed by user
$junk = prepareDisplayContext(false);




// Replace some junky codes that end up in the keywords sometimes
$postBody = $junk['body'];
$description = trim(un_htmlspecialchars(strip_tags(htmlspecialchars($postBody))));
$description = preg_replace( '!\s*<br(\s*/)?>\s*!i', " ", $description);
$description = preg_replace( '/<[^>]+>/', '', $description);
$description = preg_replace( '!</[a-z]+>!i', '', $description);
$description = preg_replace( '/&nbsp;/', ' ', $description);
$description = preg_replace( '/&#124;/', ' ', $description);
$description = preg_replace( '/&quot;/', ' ', $description);
$description = preg_replace( '/&#039;/', '\'', $description);
$description = preg_replace( '/’/', '\'', $description);
$description = preg_replace( '/.../', '-', $description);
$keywords = $description;
$keywords = trunc($description, 40);



// RESET the message display function or else it will be blank!
$junk = prepareDisplayContext(true);



If you did it right, then the last bit of code you see, BEFORE the stuff you added is:



// Load up the "double post" sequencing magic.
if (!empty($options['display_quick_reply']))
checkSubmitOnce('register');


In the part that you added, you can EDIT the $hotKeywords string, the stuff between the apostrophe quote marks
to the best keywords for your forum.  This code is also from inthe80s' great mod.

Okay you are all done modifying Display.php.

next we edit index.template.php

Look for:



function template_init()
{
global $context, $settings, $options, $txt;


And REPLACE with:


function template_init()
{
global $context, $settings, $options, $keywords, $txt;
$keywords = 'none';



Here we added $keywords to the global command so it will not lose it's value, and gave it the initial value of 'none'.
For example, if your user clicks on SEARCH, then SMF does NOT call Display.php, and therefore the $keywords is
NOT changed, and your default keywords will be used, as normal.  So this TIP only works when Display.php is called,
AND a message is retrieved.

next edit is, again in index.template.php, look for:



function template_main_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;



REPLACE with:



function template_main_above()
{
global $context, $settings, $options, $scripturl, $txt, $keywords, $modSettings;
if ($keywords == 'none')
{
$keywords = 'RUOW,the two witnesses,who are the two witnesses,daniel,daniel\'s 70th week,revelation,ezekiel,magog,ruow,elijah,moses,antichrist,2012,conspiracy,nwo,rapture,zion,zionists,jesus christ,holy spirit,god,trinity,ladynada,me114,last days,end times,apocalypse,jews,new jerusalem,zechariah,olive trees,israel,judah,manchild,sananda,germaine,carnal,666,salvation,witnesses,enoch,heart son,father of manifestation, heart daughter,the mother,FOM';
}



That adds $keywords, and you need to put in your default keywords in there.

now look for:


<meta name="keywords" content="PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum" />


Please note, that this is the default line of code; you may have changed yours. It is usually right after this code:


<meta name="robots" content="noindex" />', '


okay, so REPLACE the one I told you to look for with:


<meta name="keywords" content="', $keywords, '" />


Believe it or not, that is it!

Now if you wanted to add the ability to post keywords at the beginning of a new topic, or anywhere in any message,
then please see my tip posted here:

quick mod edits that add pretty keywords to your messages for SEO

If you have that, and you or your users add keywords, at the BEGINNING of a message, then this new tip will pick those
up and make them the keywords in the meta name section.


regards,
nada
WORK for Truth, Print it, Take Time to READ ALL LINKS NOTED  click here --> The TWO Witnesses are Mom and Dad and SMF Skins

goitalone

I tried everthing I could think of to make this work but after clicking on Begin, a few seconds later I get this error:

Database Error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY posterTime ASC' at line 4
File: D:\Web\Server\Apache2\htdocs\protected\archive_create_datafile.php
Line: 75 

It never creates the index_include.shtml file in the archive folder and the rest of the files are empty.

I did do them one by one and it all of them worked except the boards with no posts in them, so I added some welcome posts and it worked doing them one by one afterwards.

But, like I said, just pressing begin just gives and error and I still get no index_include.shtml file.

I Sooooo wanted this to work :(

Any ideas?

Advertisement: