View Single Post
  #3 (permalink)  
Old 12-24-2007, 12:21 AM
blaze blaze is offline
Pligg Donor
 
Join Date: Sep 2007
Posts: 184
Thanks: 7
Thanked 37 Times in 26 Posts
Note: This fix is for v 9.82 AND v 9.9.0

Ok, well here is a TEMPORARY SOLUTION that I worked on. It took me a while to figure out how to tweak this just right, but it does work. It ain't pretty to look at and it also takes a lot of work if you have lots of categories... but here goes:

In v 9.82, look for this code in index.php:

Code:
if(isset($_REQUEST['category'])){
	$thecat = $db->get_var("SELECT category_name FROM " . table_categories . " WHERE `category_safe_name` = '".urlencode(sanitize($_REQUEST['category'], 1))."';");
}
and change it to:

Code:
// find the name of the current category

if(isset($_REQUEST['category'])){
	$thecat = $db->get_var("SELECT category_name FROM " . table_categories . " WHERE `category_safe_name` = '".urlencode(sanitize($_REQUEST['category'], 1))."';");
	$main_smarty->assign('category', $thecat);
}
If you are using v 9.9.0, then find this in index.php:

Code:
// find the name of the current category
if(isset($_REQUEST['category'])){
	$thecat = get_cached_category_data('category_safe_name', urlencode(sanitize($_REQUEST['category'], 1)));
	$thecat = $thecat->category_name;
}
and change it to this:

Code:
// find the name of the current category
if(isset($_REQUEST['category'])){
	$thecat = get_cached_category_data('category_safe_name', urlencode(sanitize($_REQUEST['category'], 1)));
	$thecat = $thecat->category_name;
	$main_smarty->assign('category', $thecat);
}
Now the rest of the instructions should be the same for both versions 9.82 and 9.9.0.

Open your meta.tpl file and find this:

Code:
{if $meta_description neq ""}
<meta name="description" content="{$meta_description}" />
{else}
<meta name="description" content="Pligg Content Management System" />
{/if}

{if $meta_keywords neq ""}
<meta name="keywords" content="{$meta_keywords}, Pligg Content Management System" />
{else}
<meta name="keywords" content="Pligg Content Management System" />
{/if}
Replace with this:

Code:
{if $pagename eq "published"}
{if $category eq "Category 1"}
<meta name="description" content="My published category 1 description." />
<meta name="keywords" content="My published category 1 keywords go here" />
{elseif $category eq "Category 2"}
<meta name="description" content="My published category 2 description." />
<meta name="keywords" content="My published category 2 keywords go here" />
{elseif $category eq "Category 3"}
<meta name="description" content="My published category 3 description." />
<meta name="keywords" content="My published category 3 keywords go here" />
{elseif $category eq "Category 4"}
<meta name="description" content="My published category 4 description." />
<meta name="keywords" content="My published category 4 keywords go here" />
{else}
<meta name="description" content="My default index page (or published stories) description." />
<meta name="keywords" content="My default (index page) published content keywords go here" />
{/if}
{elseif $pagename eq "upcoming"}
{if $category eq "Category 1"}
<meta name="description" content="My upcoming category 1 description." />
<meta name="keywords" content="My upcoming category 1 keywords go here" />
{elseif $category eq "Category 2"}
<meta name="description" content="My upcoming category 2 description." />
<meta name="keywords" content="My upcoming category 2 keywords go here" />
{elseif $category eq "Category 3"}
<meta name="description" content="My upcoming category 3 description." />
<meta name="keywords" content="My upcoming category 3 keywords go here" />
{elseif $category eq "Category 4"}
<meta name="description" content="My upcoming category 4 description." />
<meta name="keywords" content="My upcoming category 4 keywords go here" />
{else}
<meta name="description" content="My default upcoming stories description." />
<meta name="keywords" content="My default upcoming stories keywords go here" />
{/if}
{elseif $pagename eq "story"}
<meta name="description" content="{$navbar_where.text2} - {$meta_description}" />
<meta name="keywords" content="{$meta_keywords}, add some extra default keywords here" />
{elseif $pagename eq "search"}
<meta name="description" content="Search Results For {$templatelite.get.search|sanitize:2|stripslashes} {$from_text} - My default search description." />
<meta name="keywords" content="{$templatelite.get.search|sanitize:2|stripslashes} {$from_text}, add some extra default keywords here" />
{elseif $pagename eq "cloud"}
<meta name="description" content="My default tag cloud description." />
<meta name="keywords" content="My default cloud keywords go here" />
{else}
<meta name="description" content="{$meta_description}" />
<meta name="keywords" content="{$meta_keywords}" />
{/if}
In the above example, you can add more categories (or subcategories) by adding as many {elseif} statements as you like (one per category or subcategory), just follow the sequential order. Also, don't forget to replace the "Category 1" "Category 2" etc. with your real category names. Obviously, replace the description tags and meta keyword tags with your own data as well.

For Unique titles, I have done the following:

open Pligg.tpl file and find:

Code:
<title>{if isset($pretitle)}{$pretitle}{/if}{#PLIGG_Visual_Name#}{if isset($posttitle)}{$posttitle}{/if}</title>
Replace with:

Code:
{if $pagename eq "published"}
{if $category eq "Category 1"}
<title>{if isset($pretitle)}{$pretitle}{/if}My Custom Published Category 1 Title</title>
{elseif $category eq "Category 2"}
<title>{if isset($pretitle)}{$pretitle}{/if}My Custom Published Category 2 Title</title>
{elseif $category eq "Category 3"}
<title>{if isset($pretitle)}{$pretitle}{/if}My Custom Published Category 3 Title</title>
{elseif $category eq "Category 4"}
<title>{if isset($pretitle)}{$pretitle}{/if}My Custom Published Category 4 Title</title>
{else}
<title>{if isset($pretitle)}{$pretitle}{/if}Good Keyword Phrase Here{if isset($posttitle)} | {$navbar_where.text1} | {$navbar_where.text2}{/if}</title>
{/if}
{elseif $pagename eq "upcoming"}
{if $category eq "Category 1"}
<title>{if isset($pretitle)}{$pretitle}{/if}My Custom Upcoming Category 1 Title</title>
{elseif $category eq "Category 2"}
<title>{if isset($pretitle)}{$pretitle}{/if}My Custom Upcoming Category 2 Title</title>
{elseif $category eq "Category 3"}
<title>{if isset($pretitle)}{$pretitle}{/if}My Custom Upcoming Category 3 Title</title>
{elseif $category eq "Category 4"}
<title>{if isset($pretitle)}{$pretitle}{/if}My Custom Upcoming Category 4 Title</title>
{else}
<title>{if isset($pretitle)}{$pretitle}{/if}My Default Upcoming Stories Title</title>
{/if}
{elseif $pagename eq "story"}
<title>{if isset($pretitle)}{$pretitle}{/if}Different Good Keyword Phrase Here | {$navbar_where.text1}  | {$navbar_where.text2}</title>
{elseif $pagename eq "search"}
<title>{if isset($pretitle)}{$pretitle}{/if}Another Good Keyword Phrase Here | Search Results For {$templatelite.get.search|sanitize:2|stripslashes} {$from_text}</title>
{elseif $pagename eq "cloud"}
<title>{if isset($pretitle)}{$pretitle}{/if}Yet Another Good Keyword Phrase Here | Most Popular Tags</title>
{else}
<title>{if isset($pretitle)}{$pretitle}{/if}{#PLIGG_Visual_Name#}{if isset($posttitle)} | {$navbar_where.text1} {/if} | {$navbar_where.text2}</title>
{/if}
Just like the description and keyword tags, you can add more {elseif} statements for more categories and/or subcategories. The above title fix gives you more control than some of the other recommended fixes throughout the forum. Again, don't forget to replace the "Category 1" "Category 2" etc. with your real category names, as well as change the titles to whatever you want.

You can, of course, tweak this code to suit your own needs if you're advanced enough to figure it out; but if used as above, they should be pretty darn good the way they are for good SEO. I hope this is helpful for some of you -- because for me, it was a relief to finally have SOME control over the meta data and titles for categories.

Duplicate content should not occur, because essentially the home page consists of ALL POPULAR STORIES , whereas the CATEGORY PAGES contain only popular pages within that one particular category, so it will show different stories in a different order, and will be updated less frequently than the home page. Think of it like being a sorting option.

But to play it safe, I would remove the sidebar modules for each of the individual published category pages and change the footer for each of the different category pages to make the layout be more UNIQUE, thereby really making it different from the home page for both search engines and humans.

Last edited by blaze; 01-24-2008 at 04:27 AM.. Reason: I edited the above code to replace two {if} statements with {elseif} statements in the Title fix.
Reply With Quote