Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
mrix
Client


Joined: Dec 04, 2004
Posts: 757

PostPosted: Fri May 20, 2005 7:04 am Reply with quote

Hello I was looking at this forums browser titles for each topic and the title changes in the browser per topic etc which is great! how do you go about doing this as it will help so much in google as opposed to having the same site title per page.
Cheers
mrix
 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17077

PostPosted: Fri May 20, 2005 11:39 am Reply with quote

This is accomplished through the Dynamic Titles addon. Search here and/or Google for more information Smile
 
View user's profile Send private message
mrix
PostPosted: Fri May 20, 2005 12:11 pm Reply with quote

Oh its an add on great I`ll take a search around
thanks
mrix
 
mrix
PostPosted: Fri May 20, 2005 12:16 pm Reply with quote

dam every link I seem to click on for this addon in google returns a 404 page, I guess there must be a main site and its down for this addon?
Cheers
mrix
 
Raven
PostPosted: Fri May 20, 2005 3:56 pm Reply with quote

Here is mine. This goes in your includes folder - Save as includes/dynamic_titles.php. Obviously, customize for your site Smile
Code:
<?php

/********************************************************************/
/* SN Dynamic Titles Addon                                          */
/* ===========================                                      */
/* Copyright (c) 2003 by Greg Schoper                               */
/* http://nuke.schoper.net                                          */
/*                                                                  */
/* Based on code from PHP-Nuke                                      */
/* Copyright (c) 2002 by Francisco Burzi                            */
/* http://phpnuke.org                                               */
/*                                                                  */
/* This program is free software. You can redistribute it and/or    */
/* modify it under the terms of the GNU General Public License as   */
/* published by the Free Software Foundation; either version 2 of   */
/* the License.                                                     */
/********************************************************************/
/* Credit to unknown author of original forums code in              */
/* includes/dynamic_titles.php.                                     */
/********************************************************************/

if (eregi("dynamic_titles.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.html");
    die();
}

$name=ereg_replace("_", " ", "$name");

// 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";
//$newpagetitle = "phpNuke $name";
    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";
    }
    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";
    }
    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";
    }
}

// News
if($name=="News"){
global $file,$sid,$new_topic;
$newpagetitle= "$item_delim PHP Web Host - Quality Web Hosting For All PHP Applications";
    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"){
       $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";
    }
}

// Topics
if($name=="Topics"){
$newpagetitle = "$item_delim "._ACTIVETOPICS."";
}

// Downloads
if($name=="Downloads"){
global $d_op,$cid,$lid;
$newpagetitle = "$item_delim $name";
    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 = "$name $cat";
            }
            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 = "$name $parent $cat";
            }
    }
   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 = "$name $dl";
   }
}

// Web Links
if($name=="Web_Links"){
global $l_op,$cid,$lid;
$name=ereg_replace("_", " ", "$name");
$newpagetitle = " $name";     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 = "$name $cat";
            }
            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 = "$name  $parent  $cat";
            }
    }
}

// Content
if($name=="Content"){
global $pa,$cid,$pid;
$newpagetitle = "$item_delim $name";
    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 = "$name  $cat";
    }
    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 = "$page";
   }
}

// 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 = "$name $rev";
    }
}

// Stories Archive
if($name=="Stories_Archive"){
global $sa,$year,$month_l;
$name=ereg_replace("_", " ", "$name");
$newpagetitle = "$name";
    if($sa=="show_month") {
        $newpagetitle = "$name $month_l, $year";
    }
}

// Sections
if($name=="Sections"){
global $op,$secid,$artid;
$newpagetitle = "$item_delim $name";
    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 = "$name $sec";
    }
    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";
   }
}

// Catchall for anything we don't have custom coding for
if($newpagetitle==""){
    $name=ereg_replace("_", " ", "$name");
    $newpagetitle="$name";
}

// Admin Pages
if(substr($_SERVER['REQUEST_URI'], 0, 10)=="/admin.php"){
    $newpagetitle="Administration for RavenPHPScripts.Com";
}

// If we're on the main page let's use our site slogan
if($_SERVER['REQUEST_URI']=="/index.php" || $_SERVER['REQUEST_URI']=="/"){
//    $newpagetitle="$slogan";
   $newpagetitle = "PHP Web Host - Quality Web Hosting For All PHP Applications.";
}

// We're Done! Place the Title on the page
echo "<title>$newpagetitle</title>\n";

$name=ereg_replace(" ", "_", "$name");
?>

Then, in header.php, edit the function head() and modify
Code:
    echo "<title>$sitename $pagetitle</title>\n";
to
Code:
//    echo "<title>$sitename $pagetitle</title>\n";

   include("includes/dynamic_titles.php");
 
mrix
PostPosted: Sat May 21, 2005 4:36 am Reply with quote

Great many thanks Raven.
Cheers
mrix
 
aoratos
New Member
New Member


Joined: Jun 07, 2005
Posts: 3

PostPosted: Tue Jun 07, 2005 7:41 am Reply with quote

can you plz identify what are the parts to be edited according to everyones site?

i have 7.6 currently installed and my site is Only registered users can see links on this board! Get registered or login! it's greek Smile
thanks
 
View user's profile Send private message
Lucifix
Regular
Regular


Joined: Mar 11, 2005
Posts: 67

PostPosted: Sun Jun 12, 2005 10:20 am Reply with quote

Maybe u can help me.

I inserted your code:
Code:
// Forums

if($name=="Forums"){
global $p,$t,$forum,$f;
$newpagetitle = "$name";
//$newpagetitle = "phpNuke $name";
    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";
    }
(this is just part of it)

And I don't get any post object - title on top: Only registered users can see links on this board! Get registered or login!

But if you click on first post, u'll get it: Only registered users can see links on this board! Get registered or login!

Do you have any idea what could be wrong?
 
View user's profile Send private message
DraGoN
New Member
New Member


Joined: Oct 25, 2005
Posts: 14

PostPosted: Sun Nov 13, 2005 10:14 pm Reply with quote

Anyone know what needs to be changed in the code below to get this to work correctly with NSN Group Downloads?

Code:
// Downloads

if($name=="Downloads"){
global $d_op,$cid,$lid;
$newpagetitle = "$item_delim $name";
    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 = "$name $cat";
            }
            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 = "$name $parent $cat";
            }
    }
   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 = "$name $dl";
   }
}


I thought it would be as simple as pointing it to the correct Data Base tables but that didnt work.

Thanks for any help.
 
View user's profile Send private message
Admin32
Regular
Regular


Joined: Sep 14, 2003
Posts: 74

PostPosted: Thu Nov 24, 2005 4:19 pm Reply with quote

I've implemented this great modification and now looking into doing the same for the articles I write.

The article pages are php files with the <title> tags in them, so I'd like to tell dynamic_titles.php to check for these tags and use them.

I've figured that the section required to be modified is the following:

// Catchall for anything we don't have custom coding for
if($newpagetitle==""){
$name=ereg_replace("_", " ", "$name");
$newpagetitle="$name";
}


I'm just trying to figure out what exactly I need to change to get this to work.

Your help is much appreciated!

_________________
___________________
Chris Partsenidis
Founder & Senior Editor Only registered users can see links on this board! Get registered or login!
___________________ 
View user's profile Send private message Visit poster's website
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9449
Location: Arizona

PostPosted: Fri Dec 16, 2005 7:46 am Reply with quote

DraGoN wrote:
Anyone know what needs to be changed in the code below to get this to work correctly with NSN Group Downloads?


Try this instead and see if you like it:

Code:


if($name=="Downloads"){
global $d_op,$cid,$lid;
$newpagetitle = "$item_delim $name";
    if($cid) {
        $sql = "SELECT title, parentid FROM ".$prefix."_nsngd_categories WHERE cid='$cid'";
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $cat = $row[title];
        $parent = $row[parentid];
            if($parent=="0"){
                $newpagetitle = "$name $cat";
            }
            else{
                $sql = "SELECT title FROM ".$prefix."_nsngd_categories WHERE cid='$parent'";
                $result = $db->sql_query($sql);
                $row = $db->sql_fetchrow($result);
                $parent = $row[title];
                $newpagetitle = "$name $parent $cat";
            }
    }
   if($d_op=="getit") {
       $sql = "SELECT title FROM ".$prefix."_nsngd_downloads WHERE lid='$lid'";
      $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
      $dl = $row[title];
      $newpagetitle = "$name $dl";
   }
}


In reality, I rreally do not like how the variables in this script are not checked for input and intval'd, etc., and I may re-write this to be more GoogleTap'ish to make it really easy for folks to add new "DTs". Some day....

Regards

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
DraGoN
PostPosted: Fri Dec 16, 2005 5:07 pm Reply with quote

Thanks it works partially which is better than what I could get it to do. It still doesn’t list the downloads name in the title bar when you view the downloads description.
 
montego
PostPosted: Fri Dec 16, 2005 5:21 pm Reply with quote

Yes, I noticed that too, but also noticed that the base Downloads one (for core nuke) did not as well?? I just didn't have time to include it as yet. If I do, I will post it here again. Of course, if you get their first, please post it back here for the general community.

Cheers
 
guynuked
Hangin' Around


Joined: Jan 11, 2004
Posts: 37

PostPosted: Sun Dec 31, 2006 5:58 am Reply with quote

Dang, I love how it does for my Forum titles, but when I use sweetphp.com events calendar, the title for each calendar I created there disappears...

Gosh, how do I start explaining to author of the calendar for the code change suggestion in order to get the code change suggestion? Send him/her link to this topic?

It's a great modification.
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

View next topic
View previous topic
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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©