| View previous topic :: View next topic |
| Author |
Message |
Colocation Site Admin

Joined: Jan 07, 2004 Posts: 412
|
Posted: Fri Jun 11, 2004 9:28 pm Post subject: Creating Dynamic Titles With phpnuke |
|
|
Here is the code for dynamic titles, this is in a file called dynamic_titles.php which sits in the includes folder.
| Code: |
// Web Links
if($name=="Web_Links"){
global $l_op,$cid,$lid;
$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 ";
}
}
} |
This present the title as: Web_Links - Site Slogan
How then can we convert this to read:
Title of Weblink - Site Slogan
I have tried varibales such as $title or $displaytitle
Do we need more code to extract the title first? |
|
| Back to top |
|
 |
Humpa Site Admin

Joined: Feb 05, 2004 Posts: 23
|
Posted: Mon Jun 14, 2004 11:56 am Post subject: |
|
|
At the begining is this:
// Web Links
if($name=="Web_Links"){
global $l_op,$cid,$lid;
$newpagetitle = "$name $item_delim $slogan";
You don't need to add another variable, you need to get rid of one.
The variable $name contains Web_Links, but you want it to read Weblink
So, just replace $name with Weblink .. it is as simple as that.
// Web Links
if($name=="Web_Links"){
global $l_op,$cid,$lid;
$newpagetitle = "Weblink $item_delim $slogan"; |
|
| Back to top |
|
 |
Colocation Site Admin

Joined: Jan 07, 2004 Posts: 412
|
Posted: Tue Jun 15, 2004 12:13 am Post subject: Titles Pulled From Database |
|
|
That's neat.
Now suppose each web link entry has a unique title... in the weblinks code itself modules/Web_Links/index.php it is defined as $displaytitle:
| Code: |
echo "<br>";
OpenTable();
echo "<center><P><font class=\"option\"><b>"._LINKPROFILE.": <h1><i>$displaytitle</i></h1></b></font><br>";
linkinfomenu($lid, $ttitle); |
How do we get this $displaytitle pulled from the database to work here:
| Code: |
// Web Links
if($name=="Web_Links"){
global $l_op,$cid,$lid;
$newpagetitle = "Weblink $item_delim $slogan"; |
|
|
| Back to top |
|
 |
Humpa Site Admin

Joined: Feb 05, 2004 Posts: 23
|
Posted: Wed Jun 16, 2004 12:43 am Post subject: |
|
|
There are many different pages that can be displayed for WebLinks.
To see them all, just look at all the different "cases" defined at the end of the modules/Web_Links/index.php
In your Web Links dynamic title code you only have a condition for when $l_op is "viewlink". That is just one "case" of what $l_op can be.
For a WebLinks page where a link is displayed, $l_op is going to be "viewlinkdetails".
So, I added a condition to your dynamic titles to take into accout for $l_op="viewlinkdetails"
You might find that you want to add in one or more contions for some other $l_op cases. Let me know.
| Code: |
// Web Links
if($name=="Web_Links"){
global $l_op,$cid,$lid;
$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") {
$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";
}
} |
|
|
| Back to top |
|
 |
Colocation Site Admin

Joined: Jan 07, 2004 Posts: 412
|
Posted: Wed Jun 16, 2004 12:56 am Post subject: Treats |
|
|
| Champion! |
|
| Back to top |
|
 |
|