Jump to content

alter title


everlifefree

Recommended Posts

Ok I don't know if this is possible through either php or javascript or anything really but what I was hoping for was a way to alter the title of my site depend on what is in the frame sorta thing.

 

Ok to give you a little background my site run with a frame sorta thing going on. there is a frame.tpl file where you pretty much set the header and footer for the site. Then there is a whatever.tpl for each page that has your body content.

 

 

Here's what I was thinking you could maybe do:

 

Frame.tpl: Has the main head tags with the title

<title>Site Name - {new.title}</title>

 

page.tpl: Has something that you put what you want {new.title} to be changed to.

<NewTitle>whatever you wanted</New Title>

 

Or something similiar...

Link to comment
Share on other sites

Sorry for the bump.  I know that becuase I know php and I've worked a lot with tpl files in phpbb.  It's not complicated, just takes a while to learn.  If I'm interpretting your question right, then what I said before should help you out.  We aren't just going to tell you waht to do though becuase then you don't learn.

Link to comment
Share on other sites

Ok, but I have tried several different ways... Heres the one I think I got closest on:

 

I put this in my index.php

 

"pageName"=>$second_title,

 

On my frame.tpl I put:

 

<title>{siteName} - {pageName} </title>

 

 

And Last of all I on my home.php I put:

 

$second_title = "Sub Page";

 

But all I ended up with was "Spade Space - "

 

would it be better to add the <?php $second_title = "Sub Page"; ?> to my home.tpl Or is there another way to do this...

 

Link to comment
Share on other sites

In all of my scripts lately, I gather the data together into a variable, and output them into a HTML document, which is located in another folder.

To do this, I use sprintf() a lot.

 

This way, I can easily modify headers and stuff before anything is really sent to the user, plus I get an easy-to-change layout. :)

 

So, in relation to your question, I can define $title whenever I like. The final result will be outputted along with the rest of the stuff, and will be filled into the pre-made template document.

Link to comment
Share on other sites

Second_title MUST be set before it is called, otherwise it will be echoed as an empty variable.  If you're using a tpl file, then you shouldn't need to edit the tpl, index, AND home pages.  My guess is that index.php calls up home.php, which sets certain variables, then index.php takes care of the template.

 

Try setting second_title on the index page.

Link to comment
Share on other sites

Ok, I tried putting it on the index.php file and it still didn't work.

PLEASE HELP!!

 

I put this in my index.php

 

$second_title = "Sub Page";

 

~~before~~

 

"pageName"=>$second_title,

 

On my frame.tpl I put:

 

<title>{siteName} - {pageName} </title>

 

But all I ended up with was "Spade Space - "

Link to comment
Share on other sites

You could do this

 

add the title.php as a include ( include "title.php"; )

 

and in title.php:

Website Name :: <?php
    switch ($title) {
       case 'home':
            echo "Home";
            break;
   case 'login':
            echo "Login";
            break;
   case 'register':
            echo "Register";
            break;
   case 'spay':
            echo "Start Playing";
            break;
    }
?>

 

index.php or what ever you want:

$title="home"; 
<title><?php include ("title.php"); ?> </title>

 

-Any Help?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.