Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
storebuilder
PHP-Portal Project



Joined: Mar 09, 2004
Posts: 169
Location: Telford UK

PostPosted: Sun Jul 11, 2004 10:54 am Reply with quote

I am trying to modify some code to make proper page titles on my site to work with googletap - I'm not looking for the solution (if I might be so brave) but I'm looking to understand how the solution is worked out so that I can customise the page titles.

I know very little about php programming but being as I am potentially going to be reusing this code again and again I would really like to understand how this works. If you think it is beyond me then please tell me that you think so.

I have lifted this code from "dynamic-titles.php" and this is my model.

What I want to do is to use the include file above and be able to modify the page titles depending on the operator.

here is the code that I have modified for the content module which works perfectly:

Code:


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


Here is my exegesis:
Code:


if($name=="Content"){
(Declare a variable $name that matches the content module.)
global $pa,$cid,$pid;
(Declare global variables - do these have to be specific? or are they supposed to match what you are pulling from the database?
$newpagetitle = "$name";
(So now, newpagetitle is the name of the module.)
    if($pa=="list_pages_categories") {
(This is the "operator", what comes after the modules.php?op=)
        $sql = "SELECT title FROM ".$prefix."_pages_categories WHERE cid='$cid'";

(So now we access the database and select the title from the category ID?)
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        $cat = $row[title];
        $newpagetitle = "$name  $cat";
    }

(So now we have a new title of $name which is the module title and $cat which I see that we get from $result, $row)
    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";
   }
}

No - after an hour of looking at this I just don't have what it takes to make it happen.

This is the code that I have generated so far - which is obviously going to be complete bollocks and that is why it doesn't work!


Code:
//MReviews

if($name=="MReviews"){
global $cid, $rid;
$newpagetitle = "Storebuilder - All of your favourite software reviews.";
if($cid=="list_revs") {
       $sql = "SELECT title FROM ".$prefix."_MReviews_cats WHERE cid='$cid'";
       $result = $db->sql_query($sql);
       $row = $db->sql_fetchrow($result);
       $newpagetitle = "$cid";
}
elseif($rid=="show") {
       $sql = "SELECT cid, pagename FROM ".$prefix."_MReviews WHERE rid='$rid'";
       $result = $db->sql_query($sql);
       $row = $db->sql_fetchrow($result);
       $sql = "SELECT title FROM ".$prefix."_MReviews_cats WHERE cid='$row[cid]'";
       $result2 = $db->sql_query($sql);
       $row2 = $db->sql_fetchrow($result2);
    $newpagetitle = "$row2 $row";
}


I Answered my own question about understanding how it works because clearly I don't understand it. Can somebody please point me in the direction of a programmer that would be happy to do these type of mod's for me? Obviously I am prepared to pay but it's just bib's and bob's work until the site is making money.

Thanks

Tony
 
View user's profile Send private message Visit poster's website MSN Messenger
gormnass
New Member
New Member



Joined: Feb 14, 2005
Posts: 1

PostPosted: Mon Feb 14, 2005 7:47 am Reply with quote

Idea Try to past this code in to your dynamic_titles.php
Code:


//MReviews
if($name=="MReviews"){
global $cid,$rid,$scid;
$newpagetitle = "Reviews";
    if($cid) {
       $sql = "SELECT title FROM ".$prefix."_MReviews_cats WHERE cid='$cid'";
       $result = $db->sql_query($sql);
       $row = $db->sql_fetchrow($result);
       $newpagetitle = "- Reviews $item_delim $row[title]";
}
if($rid) {
       $sql = "SELECT cid, pagename FROM ".$prefix."_MReviews WHERE rid='$rid'";
       $result = $db->sql_query($sql);
       $row = $db->sql_fetchrow($result);

       $sql = "SELECT title FROM ".$prefix."_MReviews_cats WHERE cid='$row[cid]'";
       $result2 = $db->sql_query($sql);
       $row2 = $db->sql_fetchrow($result2);
    $newpagetitle = "- Reviews $item_delim $row2[title] $item_delim $row[pagename]";
}
if($scid) {
       $sql = "SELECT cid, sub_title FROM ".$prefix."_MReviews_sub_cats WHERE scid=$scid";
       $result = $db->sql_query($sql);
       $row = $db->sql_fetchrow($result);

       $sql = "SELECT title FROM ".$prefix."_MReviews_cats WHERE cid='$row[cid]'";
       $result2 = $db->sql_query($sql);
       $row2 = $db->sql_fetchrow($result2);
    $newpagetitle = "- Reviews $item_delim $row2[title] $item_delim $row[sub_title]";
}
}


hope this helps you Smile

Regards Gorm
Only registered users can see links on this board! Get registered or login!

-------------------------------
 
View user's profile Send private message
storebuilder







PostPosted: Mon Feb 14, 2005 8:11 am Reply with quote

Wow! Thanks. Patience is a virtue Wink. Just what was required!
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

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 ©