Results 1 to 4 of 4

Thread: Appearance of title tags (HELP PLEASE !)

  1. #1
    Junior Registered
    Join Date
    Jul 2008
    Posts
    2

    Appearance of title tags (HELP PLEASE !)

    HI everyone,
    I have a classifieds website, usual sort of thing, books, dvds etc.. which all appear fine in the title tag along with my website name.

    But how can I get the title to change
    instead of saying:- Books For Sale | mywebsitename.com

    I would like it to say New and used before Books for sale, I have tried just adding that to my title tag but it just stays there all the time, and I only want it to appear when a category is chosen. I have added below what my title tag looks like, to see what I am on about
    <title><?= $catname ?> <?= $a1[CompanyName ] ?> <?= $catsl[subcatname] ?> <?= $mysubcatname ?> | Free UK classifieds Ad's in .mywebsite.com </title>

    Hope you understand what im on about

    Hope to hear off somebody soon, before my brain explodes

    Jason - jasehunt33@aol.com

  2. #2
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    If you want it to conditionally appear you need a conditional statement

    if($catname != ""){
    $title = "title with text":
    }else{
    $title = "default title";
    }

    echo "<title>".$title."</title>";

    What is does is say "if catname is not blank, it has a value, then use this title, otherwise, use this other title"
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  3. #3
    4x4
    Join Date
    Oct 2004
    Posts
    1,043

    Wink

    Quote Originally Posted by Chris View Post
    If you want it to conditionally appear you need a conditional statement

    if($catname != ""){
    $title = "title with text":
    }else{
    $title = "default title";
    }

    echo "<title>".$title."</title>";

    What is does is say "if catname is not blank, it has a value, then use this title, otherwise, use this other title"
    If you are going to do that you may as well put the variable inside the double quotes.

    Use single quotes if you don't plan to put variables inside... this tells PHP there are no variables inside (and if you put them in there it wont process them)... this is the faster way to have php process it. (Most likely negligible unless you are doing a ton of variables... none the less good tid-bit to know.) The same holds true when setting variables, etc.

    I may have to run some speed test comparisons on 1 entire page of 'echos' and var setting just to see I`m a geek!! LOL

  4. #4
    Registered deathshadow's Avatar
    Join Date
    Apr 2008
    Posts
    41
    Quote Originally Posted by ToddW View Post
    Use single quotes if you don't plan to put variables inside...
    It is traditionally faster in most interpreted languages, though I'm uncertain how much of an effect it has upon PHP - You can get the same type of boosts by not constantly popping in and out of code parsing mode by not doing the constant <?php do one thing ?><b><?php do something else ?> rubbish. (this I did my own tests and found it was inside a loop only about a 2% speed difference over 1000 iterations, but hey every little bit helps)

    I also prefer singles because I do my html attributes as doubles - therein I'm less likely to have to escape any quotes.

    Likewise I'd not drop out of the echo, because again that's a parsing mode change, so I'd do that:

    echo 'title'.($catname!='' ? 'title with text' : 'default title').'</title>';

    Unless of course there were more than two conditions, which might make a switch faster than a compare even with changing parsing mode.

Similar Threads

  1. Help with page title tags (im going mad)
    By jason1971 in forum Search Engine Optimization
    Replies: 1
    Last Post: 08-03-2008, 02:38 PM
  2. Tags vs Categories
    By Nico in forum General Management Issues
    Replies: 11
    Last Post: 08-23-2007, 12:44 AM
  3. SEO question about Title tags
    By Farmer77 in forum Search Engine Optimization
    Replies: 5
    Last Post: 11-22-2006, 08:04 AM
  4. alt and title tags?
    By Mike in forum Search Engine Optimization
    Replies: 1
    Last Post: 07-26-2003, 05:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •