Add meta keywords to your categories in sNews 1.7
filed under: sNews CMS / Hacks & Mods
This is a simple mod that you can use to add a keywords meta field to your categories. I have implemented it on my own site here for the last several days and it's working well. This is a fairly easy mod, however, make sure to follow the instructions well, don't use a different field name due to conflicts with existing fields, otherwise you'll have to re-write many existing queries.
To begin, we need to add the field to your categories table.
ALTER TABLE categories ADD keywords_m VARCHAR(255) AFTER description;
Now, as always, back-up your snews.php and work off of a copy.
Around line 172, add the keywords_m field to the selection.
$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,c.keywords_m as keywords_m
FROM '._PRE.'categories'.' AS x
Around line 198, add the keywords_m field to the selection.
$R = mysql_fetch_assoc($Try_Page);
if (!$R) {
$MainQuery ='SELECT
id AS catID, name, description, keywords_m
FROM '._PRE.'categories'.' AS c
Around line 232, add the keywords_m elseif condition.
if(!empty($R['keywords_meta'])) $_KEYW = $R['keywords_meta']; elseif(!empty($R['keywords_m'])) $_KEYW = $R['keywords_m'];
Around line 1763, within function form_categories, add the highlighted line.
$frm_description = $r['description'];
$frm_keywords = $r['keywords_m'];
$frm_publish = $r['published'] == 'YES' ? 'ok' : '';
Around line 1789, within function form_categories, add the highlighted line.
echo html_input('text', 'description', 'desc', $frm_description, l('description'), '', '', '', '', '', '', '', '', '', '');
echo html_input('text', 'keywords_m', 'keywords_m', $frm_keywords, l('a_keywords'), '', '', '', '', '', '', '', '', '', '');
if (empty($sub_cat)) {
echo '<p>'.l('subcategory').': <br />'; category_list($categoryid); echo '</p>';
}
Around line 2568, within function processing, add the highlighted line.
$keywords_meta = entity($_POST['keywords_meta']);
$keywords_m = entity($_POST['keywords_m']);
$display_title = $_POST['display_title'] == 'on' ? 'YES' : 'NO';
Around line 2768, within function processing, add the highlighted code to the add and edit processes.
case(isset($_POST['add_category'])):
$catorder = mysql_fetch_array(mysql_query(
"SELECT MAX(catorder) as max
FROM "._PRE.'categories'." WHERE subcat = $subcat"));
$catorder = $catorder['max'] + 1;
mysql_query("INSERT INTO "._PRE.'categories'."
(name, seftitle, description, keywords_m, published, catorder, subcat)
VALUES('$name', '$seftitle', '$description', '$keywords_m', '$publish_category', '$catorder','$subcat')");
break;
case(isset($_POST['edit_category'])):
$catorder = mysql_fetch_array(mysql_query(
"SELECT MAX(catorder) as max
FROM "._PRE.'categories'." WHERE subcat = $subcat"));
$catorder = isset($_POST['catorder']) ? $_POST['catorder'] : $catorder['max'] + 1;
mysql_query("UPDATE "._PRE.'categories'." SET
name = '$name',
seftitle = '$seftitle',
description = '$description',
keywords_m = '$keywords_m',
published = '$publish_category',
subcat='$subcat',
catorder='$catorder'
WHERE id = $id LIMIT 1");
That should do it, upload your snews.php and now you should be able to add meta keywords to your categories. These keywords will be displayed once you've added them, until then, it will use the site default. As always, if something is screwy, let me know and I'll have a look.
19 comments
Add a new comment »Categories
Recent Entries
Recent Comments
- Redbeard (I managed to get Vampire: The Masquerade - Bloodlines ...)
- Tina (Installed this today and working like a charm :) Thanks!)
- Tina (Thanks for this great mod :) Working on my site for quite a ...)
- konga (Hi Matt, if you plan to update it, please have a look into ...)
- David (Yo Matt, I have a problem, when I use this mod. ...)
- Dave (Have a Toshiba NB305. Win7 starter would not do screen ...)
- Daichisan (Howdy Matt, I dont really get it, whats ...)
- Matt (Mine is just customized further, that's all :) It just spits ...)
- Matt (David, Do you own or admin the server? Do you have exec ...)
Popular Entries
- Compact archives for sNews 1.7 (5/5)
- Light-weight related articles mod for sNews 1.7 (4.78/5)
- SEF / SEO search for your sNews website (4.75/5)
- 1024x600 netbook wallpapers of Evangeline Lilly (4.67/5)
- An improved tag cloud for sNews 1.7 (4.67/5)
- Gravatar mod for sNews 1.7 (4.67/5)
- Image / math hybrid captcha version 2, vastly improved (4.64/5)
- Related Articles mod for sNews CMS, public beta release (4.6/5)
- An easy mod to create custom break titles for your sNews articles (4.6/5)
Mar 27th, 2010 at 5:44 am
Oumpf! Took me 5 minutes. Where's the karma button?
Oh yes! On the forum. See you there.
Mar 30th, 2010 at 4:09 pm
Excellent. Thanks a million Matt :)
Apr 3rd, 2010 at 8:58 pm
Thank you very much for your contribution about snews, you are a nice guy !
karma button is to click on his Ads :)
Apr 5th, 2010 at 7:16 am
Thanks Thom, Tina, & Sven!
Apr 7th, 2010 at 6:24 am
You're right Thom. Except I don't see any ads.
Apr 7th, 2010 at 11:31 am
Hmmm, are you using adblock extension maybe? Or perhaps the ads aren't relevant, in which case I have Google not serve anything and fold the space up.
No matter anyways, I wouldn't encourage clicking for the sake of clicking, Google is pretty smart in that regard.
Sometimes I think about removing adsense altogether, most months it pays for hosting, but that's about it. I think most folks are ad-blind these days :)
Apr 7th, 2010 at 12:19 pm
"I wouldn't encourage clicking for the sake of clicking, Google is pretty smart in that regard."
I know you are fair Matt.
I just went on another page about gaming and saw and ad. So it works. You gonna be a millionaire soon. ;-)
Apr 12th, 2010 at 8:56 am
Is it necessary for what purposes?
Apr 12th, 2010 at 9:00 am
It's not "necessary" really, Different, it's just another way to fine-tune SEO.
The default sNews will show the generic site settings keywords on categories, this allows you to have category specific keywords.
Apr 22nd, 2010 at 9:48 am
Hi Matt...
and sub-categories?
Do you think it worth it?
Apr 22nd, 2010 at 9:51 am
Sven,
I believe the above does work with sub-categories? Unless I forgot to document a step or something.
Apr 22nd, 2010 at 10:08 am
Does it?
Here no. Nothing is stored in the DB on my side.
Apr 22nd, 2010 at 10:27 am
Hmmm, something is odd then, because a sub-category is simply a category below another, everything else is the same.
You're saying that the sub-category keywords don't get inserted into the DB, but a regular category's keywords do?
Apr 22nd, 2010 at 11:44 am
Hum...
I think I got a bug somewhere locally in the DB...
waitee waitee...
I got some issues to fix and I'll be back tomorrow.
May 15th, 2010 at 4:03 am
I just remember I had an issue there. ;-)
Hi Matt
I gave another try this morning: keywords are stored into the DB. That's good news.
There are printed too into the meta keywords. But I don't use this meta which is deprecated by search engines. I thought I would find them into the meta tags, bout no: even in the administration panel I can't see them printed.
Thats' my bug in fact.
Jul 5th, 2010 at 9:36 pm
Hii Mad, how I can make urls in plain text and replace < with true tag in comment and article post, please teach me, thanks
Jul 19th, 2010 at 8:01 am
Hi Abdul,
There exists a small line within the comment function to convert the commenter's website url to a link, use can just use that convert plain text links within the comment text.
I'm not really sure what you mean about true tags?
Jul 19th, 2010 at 2:57 pm
information is very helpful...!
how its application on blogspot..?
Thanks
Gheevara
Jul 19th, 2010 at 3:57 pm
Hi ghee, I would have no idea how to implement on blogspot, I've never used it.
I think blogspot is a hosted application anyways, so it's probably a featured the developers themselves would have to add.