MB Publishing Webmaster Resource ::
View previous topic :: View next topic
Author
Message
Colocation Site Admin Joined: Jan 07, 2004 Posts: 404
Posted: Thu Nov 11, 2004 9:16 am Post subject: Category Titles
How can we create dynamic titles for urls such as:
article-category-45.html
This is the includes/dynamic_titles.php file:
Code:
// Item Delimeter
$item_delim = "-";
$newpagetitle = "";
global $name;
include ("config.php");
include("db/db.php");
// Forums
if($name=="Forums"){
global $p,$t,$forum,$f;
$newpagetitle = "$name $slogan";
if($p) {
$sql = "SELECT post_subject, post_id FROM ".$prefix."_bbposts_text WHERE post_id='$p'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$title = $row[post_subject];
$post = $row[post_id];
$newpagetitle = "$title $item_delim Post $post";
}
if($t) {
$sql = "SELECT topic_title, forum_id FROM ".$prefix."_bbtopics WHERE topic_id='$t'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$title = $row[topic_title];
$forum = $row[forum_id];
$sql = "SELECT forum_name FROM ".$prefix."_bbforums WHERE forum_id='$forum'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$forum = $row[forum_name];
$newpagetitle = "$title $item_delim $name $item_delim $forum";
}
elseif($f) {
$sql = "SELECT forum_name FROM ".$prefix."_bbforums WHERE forum_id='$f'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$forum = $row[forum_name];
$newpagetitle = "$forum $item_delim $name";
}
}
// News
if($name=="News"){
global $file,$sid,$new_topic;
$newpagetitle= "$name $item_delim";
if ($new_topic==""){
$sql = "SELECT topictext FROM ".$prefix."_topics WHERE topicid='$new_topic'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$top = $row[topictext];
$newpagetitle= "$top";
}
if ($file=="article" OR $file=="friend"){
$sql = "SELECT title, topic FROM ".$prefix."_stories WHERE sid='$sid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$art = $row[title];
$top = $row[topic];
$sql = "SELECT topictext FROM ".$prefix."_topics WHERE topicid='$top'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$top = $row[topictext];
$newpagetitle= "$art $item_delim $top";
}
}
// Topics
if($name=="Topics"){
$newpagetitle = ""._ACTIVETOPICS."";
}
// Downloads
if($name=="Downloads"){
global $d_op,$cid,$lid;
$newpagetitle = "$name $item_delim $slogan";
if($d_op=="viewdownload") {
$sql = "SELECT title, parentid FROM ".$prefix."_downloads_categories WHERE cid='$cid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$cat = $row[title];
$parent = $row[parentid];
if($parent=="0"){
$newpagetitle = " $cat $item_delim $name ";
}
else{
$sql = "SELECT title FROM ".$prefix."_downloads_categories WHERE cid='$parent'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$parent = $row[title];
$newpagetitle = "$parent $item_delim $cat $item_delim $name";
}
}
if($d_op=="viewdownloaddetails" || $d_op=="getit") {
$sql = "SELECT title FROM ".$prefix."_downloads_downloads WHERE lid='$lid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$dl = $row[title];
$newpagetitle = "$dl $item_delim $name";
}
}
// Web Links
if($name=="Web_Links"){
global $l_op,$cid,$lid, $selectdate;
$newpagetitle = "$name $item_delim $slogan";
if($l_op=="viewlink") {
$sql = "SELECT title, parentid FROM ".$prefix."_links_categories WHERE cid='$cid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$cat = $row[title];
$parent = $row[parentid];
if($parent=="0"){
$newpagetitle = "$cat $item_delim $name";
}else {
$sql = "SELECT title FROM ".$prefix."_links_categories WHERE cid='$parent'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$parent = $row[title];
$newpagetitle = "$parent $item_delim $cat $item_delim $name ";
}
}elseif($l_op=="viewlinkdetails" OR $l_op=="viewlinkeditorial" OR $l_op=="ratelink" OR $l_op=="rateinfo") {
$sql = "SELECT title FROM ".$prefix."_links_links WHERE lid='$lid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$link_title = $row[title];
$newpagetitle = "$link_title $item_delim $slogan";
}elseif($l_op=="outsidelinksetup") {
$sql = "SELECT title FROM ".$prefix."_links_links WHERE lid='$lid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$link_title = $row[title];
$newpagetitle = "Promote - $link_title $item_delim $slogan";
}elseif($l_op=="AddLink") {
$newpagetitle = "Add A Link $item_delim $slogan";
}elseif($l_op=="NewLinks") {
$newpagetitle = "New Links $item_delim $slogan";
}elseif($l_op=="MostPopular") {
$newpagetitle = "Most Popular Links $item_delim $slogan";
}elseif($l_op=="TopRated") {
$newpagetitle = "Top Rated Links $item_delim $slogan";
}elseif($l_op=="RandomLink") {
$newpagetitle = "Random Link $item_delim $slogan";
}elseif($l_op=="NewLinksDate") {
$show_date = date("F j, Y", $selectdate);
$newpagetitle = "New Links for Date: $show_date $item_delim $slogan";
}
}
// Content
if($name=="Content"){
global $pa,$cid,$pid;
$newpagetitle = "$name $item_delim $slogan";
if($pa=="list_pages_categories") {
$sql = "SELECT title FROM ".$prefix."_pages_categories WHERE cid='$cid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$cat = $row[title];
$newpagetitle = "$cat $item_delim $name";
}
if($pa=="showpage") {
$sql = "SELECT title, cid FROM ".$prefix."_pages WHERE pid='$pid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$page = $row[title];
$cid = $row[cid];
$sql = "SELECT title FROM ".$prefix."_pages_categories WHERE cid='$cid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$cat = $row[title];
$newpagetitle = "$cat $item_delim $page $item_delim $name ";
}
}
// Reviews
if($name=="Reviews"){
global $rop,$id;
$newpagetitle = "$name";
if($rop=="showcontent") {
$sql = "SELECT title FROM ".$prefix."_reviews WHERE id='$id'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$rev = $row[title];
$newpagetitle = "$item_delim $name $item_delim $rev";
}
}
// Stories Archive
if($name=="Stories_Archive"){
global $sa,$year,$month_l;
$name=ereg_replace("_", " ", "$name");
$newpagetitle = "$name $item_delim $slogan";
if($sa=="show_month") {
$newpagetitle = "$name $item_delim $month_l, $year";
}
}
// Sections
if($name=="Sections"){
global $op,$secid,$artid;
$newpagetitle = "$name $item_delim $slogan";
if($op=="listarticles") {
$sql = "SELECT secname FROM ".$prefix."_sections WHERE secid='$secid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$sec = $row[secname];
$newpagetitle = "$sec $item_delim $name";
}
if($op=="viewarticle") {
$sql = "SELECT title, secid FROM ".$prefix."_seccont WHERE artid='$artid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$art = $row[title];
$cid = $row[secid];
$sql = "SELECT secname FROM ".$prefix."_sections WHERE secid='$cid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$sec = $row[secname];
$newpagetitle = "$art $item_delim $sec";
}
}
// Catchall for anything we don't have custom coding for
if($newpagetitle==""){
$name=ereg_replace("_", " ", "$name");
$newpagetitle="$name $item_delim $slogan";
}
// Admin Pages
if(substr($_SERVER['REQUEST_URI'], 0, 10)=="/admin.php"){
$newpagetitle="Administration";
}
// If we're on the main page let's use our site slogan
if($_SERVER['REQUEST_URI']=="/index.php" || $_SERVER['REQUEST_URI']=="/"){
$newpagetitle="$slogan $item_delim News";
}
// We're Done! Place the Title on the page
echo "<title>$newpagetitle</title>\n";
Do we add lines to this file?
Back to top
Humpa Site Admin Joined: Feb 05, 2004 Posts: 23
Posted: Thu Nov 11, 2004 10:50 am Post subject:
Not sure .. that file generates titles based on the nuke url. I'm not sure what the nuke url is for article-category-45.html, but whatever it is it needs to be added to the appropriate part of that dynamics title file (the News part).
Back to top
Colocation Site Admin Joined: Jan 07, 2004 Posts: 404
Posted: Thu Nov 11, 2004 10:54 am Post subject: Url
This is a nuke category url:
Quote:
http://widjet.org/modules.php?name=News&file=categories&op=newindex&catid=3
Back to top
Colocation Site Admin Joined: Jan 07, 2004 Posts: 404
Posted: Sat Jan 29, 2005 7:19 pm Post subject: Code for categories
OK so we have the nuke url and here is the "news" part of the dynamic titles code:
Code:
// News
if($name=="News"){
global $file,$sid,$new_topic;
$newpagetitle= "$name $item_delim";
if ($new_topic==""){
$sql = "SELECT topictext FROM ".$prefix."_topics WHERE topicid='$new_topic'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$top = $row[topictext];
$newpagetitle= "$top";
}
if ($file=="article" OR $file=="friend"){
$sql = "SELECT title, topic FROM ".$prefix."_stories WHERE sid='$sid'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$art = $row[title];
$top = $row[topic];
$sql = "SELECT topictext FROM ".$prefix."_topics WHERE topicid='$top'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$top = $row[topictext];
$newpagetitle= "$art $item_delim $top";
}
}
What should be added?
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum