<? DEW-CODE.COM  
Dew-Code
Welcome, Guest
Please Login or Register.    Lost Password?
Re:SEO friendly (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:SEO friendly
#256
Dewed (Admin)
Admin
Posts: 476
graph
User Offline Click here to see the profile of this user
Dew-Code.com
Re:SEO friendly 1 Year, 9 Months ago Karma: 7  
I added the 2 new functions to inlcude/functions.php pretty mutch just as Fattymatty posted them, here they are again for convenience ... I just pasted them under the comments at the top of functions.php

Code:

///SEO goods - ADDED FOR TITLE AND KEYWORDS CUSTOMIZATION ///submitted by users of the pre-2008 dew-code.com forum function get_cat($PID){ global $tb_categories; $gc_query = sql_query(" select $tb_categories.Category as cat_name from $tb_categories where ID=$PID"); while($gc_array = sql_fetch_array($gc_query)){ $cat = $gc_array[cat_name]; } return $cat; } function get_ParentCats($PID){ global $tb_categories; $gcid = $PID; while($gcid > 0){ $query_str = "select $tb_categories.Category, $tb_categories.ID, $tb_categories.PID from $tb_categories where $tb_categories.ID = $gcid"; $mlc_query = sql_query($query_str); $mlc_array = sql_fetch_array($mlc_query); $cat_array[] = $mlc_array["Category"]; $pid_array[] = $mlc_array["ID"]; $gcid = $mlc_array["PID"]; } $count = sizeof($pid_array); for($depth=$count;$depth>=0;$depth--){ if($pid_array[$depth]){ if($PID == $pid_array[$depth]){ $htmlsrc .= ereg_replace("_"," ",($cat_array[$depth])); $htmlsrc .= ""; } else { $htmlsrc .= ereg_replace("_"," ",($cat_array[$depth])); $htmlsrc .= ", "; } } } return $htmlsrc; } //END ADDED FOR TITLE AND KEYWORD CUSTOMIZATION
Then editing the directory file, I did things abit differently. Basically the get_ParentCats function could be very CPU intensive on a deeply nested category, so I wanted to be sure I only call the function once per page view. With the output assigned to a variable, I can just print the variable when and where I want it. Around line #76, under
Code:

} else {$PID ="";}
I added the function calls to fetch the entire category trail only if the $PID was greater than 3, since the install I'm working on only has 3 top level categories... Change the "3" to the number of top level categories you have, this just ensures you dont call the more expensive get_ParentCats function unneccesarily.
Code:

if ($PID > 3){ $keywords = get_ParentCats($PID); } else { $keywords = get_cat($PID); }
Then I just print the $keyword variable within in the keyword, description and title tags
Code:

<meta name = "keywords" content = " blah blah blah <?php echo $keywords;?> <meta name = "description" content = "<?php echo $gl[SiteTitle] .'blah'.$keywords; ?> . . . . . . . . . <title> <? echo "$gl[SiteTitle]"; echo ' '. $keywords; ?>
Now I just need to write a great site all about blah !
 
Report to moderator   Logged Logged  
 
Last Edit: 2008/06/01 12:09 By Dewed.
 
Nothing to it but to Dew it !
Dew-Code.com
  The administrator has disabled public write access.
      Topics Author Date
    thread link
SEO friendly
D_Jay 2008/05/07 05:15
    thread link
thread linkthread link Re:SEO friendly
Dewed 2008/05/07 08:03
    thread link
thread linkthread linkthread link Re:SEO friendly
D_Jay 2008/05/07 08:39
    thread link
thread linkthread linkthread linkthread link Re:SEO friendly
fattymattybrewing 2008/05/17 21:10
    thread link
thread linkthread linkthread linkthread linkthread link Re:SEO friendly
fattymattybrewing 2008/05/19 21:18
    thread link
thread linkthread linkthread linkthread linkthread linkthread link Re:SEO friendly
jnasta 2008/05/20 10:21
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread link Re:SEO friendly
jnasta 2008/05/20 10:35
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Re:SEO friendly
jnasta 2008/05/20 14:24
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Re:SEO friendly
fattymattybrewing 2008/05/20 22:39
    thread link
thread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread linkthread link Re:SEO friendly
jnasta 2008/05/20 23:50
    thread link
thread linkthread link Re:SEO friendly
D_Jay 2008/05/18 06:16
    thread link
thread linkthread link Re:SEO friendly
Dewed 2008/05/21 07:27
    thread link
thread linkthread link Re:SEO friendly
D_Jay 2008/05/30 13:22
    thread link
thread linkthread linkthread link Re:SEO friendly
jnasta 2008/05/30 18:01
    thread link
thread linkthread link Re:SEO friendly
D_Jay 2008/05/31 02:54
    thread link
thread linkthread link Re:SEO friendly
Dewed 2008/05/31 13:21
    thread link
thread linkthread link Re:SEO friendly
D_Jay 2008/06/01 11:10
    thread link
thread linkthread linkthread link Re:SEO friendly
Dewed 2008/06/01 12:07
    thread link
thread linkthread link Re:SEO friendly
D_Jay 2008/06/01 17:30
    thread link
thread linkthread linkthread link Re:SEO friendly
Dewed 2008/06/01 17:51
    thread link
thread linkthread link Re:SEO friendly
D_Jay 2008/06/02 04:03
    thread link
thread linkthread linkthread link Re:SEO friendly
Dewed 2008/06/02 06:28
    thread link
thread linkthread link Re:SEO friendly
D_Jay 2008/06/02 07:04
Go to top Post Reply
get the latest posts directly to your desktop
Outsource your projects to thousands of programmers at
ScriptLance.com
Newsflash

Sign up for PayPal and start accepting credit card payments instantly.
Copyright Dew-Code 2008