add page title to the browser title

Discussion in 'General Support' started by ianhaney, May 18, 2013.

  1. ianhaney

    ianhaney New Member

    Joined:
    Apr 30, 2013
    Messages:
    59
    Likes Received:
    0
    Hi

    I have managed to edit my title in global_header.tpl so it looks like the following

    Code:
    <title>{PAGE_TITLE} - list your artwork without large fees - Basildon - Essex</title>
    How do I add the page name into the title, at the moment it looks like the following

    Sellyourownart.com - list your artwork without large fees - Basildon - Essex

    Say if I am on the contact page, Is it possible and if so how to have it look like the following

    Contact Us - Sellyourownart.com - list your artwork without large fees - Basildon - Essex

    I am using 1.0.6

    Kind regards

    Ian
     
  2. Box Lot

    Box Lot Super Moderator Staff Member Developer

    Joined:
    Dec 18, 2008
    Messages:
    2,621
    Likes Received:
    165
    See if this helps.
     
  3. ianhaney

    ianhaney New Member

    Joined:
    Apr 30, 2013
    Messages:
    59
    Likes Received:
    0
    Hi Box Lot

    I think I tried that but didn't work but will try again today

    Kind regards

    Ian
     
  4. ianhaney

    ianhaney New Member

    Joined:
    Apr 30, 2013
    Messages:
    59
    Likes Received:
    0
    Hi

    I tried the coding in the link above Box Lot and didn't work, it just added text at the very top of the page

    I need the page title to appear in the browser title in the tab if that makes sense

    Regards

    Ian
     
  5. nay27uk

    nay27uk Super Moderator Staff Member

    Joined:
    Nov 24, 2009
    Messages:
    5,572
    Likes Received:
    547
    Ian do a search for ifpage= its some dead simple php code you put in each php file but I don't remember exactly what. I think its for tabs but maybe you can alter it for the address bar just google "php code to make a tab active" it works by an IF in the actual header then a THIS in the actual page its very similar to the code boxlot posted but the actual page also has some code in it. in boxes example index.php somewhere at the top would have a THIS PAGE="index.php" or something simlar
     
    Last edited: May 19, 2013
  6. Box Lot

    Box Lot Super Moderator Staff Member Developer

    Joined:
    Dec 18, 2008
    Messages:
    2,621
    Likes Received:
    165
    I don't know how you've built your contact page but I'll presume contact.php. The last ELSE just catches pages you haven't specifically noted and it will just display what you already built.

    In your themes global_header.tpl:

    <head>
    <!-- IF PAGE_NAME eq 'contact.php' -->
    <title>Contact Us {PAGE_TITLE} - list your artwork without large fees - Basildon - Essex</title></title>
    <!-- ELSEIF PAGE_NAME eq 'register.php' -->
    <title>Register {PAGE_TITLE} - list your artwork without large fees - Basildon - Essex</title></title>
    <!-- ELSE -->
    <title>{PAGE_TITLE} - list your artwork without large fees - Basildon - Essex</title>
    <!-- ENDIF -->


    ...............rest of your header stuff
    </head>

    Of course this is after you've made the noted additions to header.php to grab the current page name. No reason is shouldn't still work in the current version. Check your work and try again.

    Nay's note may work but it is not part of my procedure. Only the files I mentioned in the linked post need to be edited and not each file you want a title on, the header does that.

    By the way, that page title is quite long, many search engines will cut it off. You may want to consider putting your locations in the metas.
     
    Last edited: May 19, 2013
  7. ianhaney

    ianhaney New Member

    Joined:
    Apr 30, 2013
    Messages:
    59
    Likes Received:
    0
    Ok cool will try that Box Lot and will post the outcome of it here

    Hopefully will be ok
     
  8. ianhaney

    ianhaney New Member

    Joined:
    Apr 30, 2013
    Messages:
    59
    Likes Received:
    0
    Works perfect now, thank you so much for all the help, appreciate it

    Just need to find out how to add each category name to the browser title

    Think I got a rough idea on how to do it

    Kind regards

    Ian
     
  9. Xeonn

    Xeonn New Member

    Joined:
    Dec 15, 2011
    Messages:
    371
    Likes Received:
    55
  10. Box Lot

    Box Lot Super Moderator Staff Member Developer

    Joined:
    Dec 18, 2008
    Messages:
    2,621
    Likes Received:
    165
    If it is not already set in the current version (should be in some fashion, may just be able to add to an existing query) then you will need to pull the category name in browse.php and set the variable.

    "cat_title_name" for example.

    Once that’s done:

    <!-- IF PAGE_NAME eq 'browse.php' -->
    <title>{CAT_TITLE_NAME} {PAGE_TITLE} - list your artwork without large fees - Basildon - Essex</title>




    I always opt for non-scripted solutions whenever possible to keep the "weight" lighter.
     
  11. ianhaney

    ianhaney New Member

    Joined:
    Apr 30, 2013
    Messages:
    59
    Likes Received:
    0
    Hi Box Lot

    I tried

    <!-- ELSEIF PAGE_NAME eq 'browse.php' -->
    <title>{CAT_TITLE_NAME} - {PAGE_TITLE} - list your artwork without large fees - Basildon - Essex</title>

    and it comes up like the following in the browser title

    - Sellyourownart.com - list your artwork without large fees - Basildon - Essex

    It don't seem to be reading the category name for some reason
     
  12. Box Lot

    Box Lot Super Moderator Staff Member Developer

    Joined:
    Dec 18, 2008
    Messages:
    2,621
    Likes Received:
    165
    As I said, you have to set that variable in the php file, did you? I just made up a name for example sake. Read the post again.
     
  13. ianhaney

    ianhaney New Member

    Joined:
    Apr 30, 2013
    Messages:
    59
    Likes Received:
    0
    Ooops sorry missed reading that bit, where do I put the variable in browse.php, I got the file open now
     
  14. Box Lot

    Box Lot Super Moderator Staff Member Developer

    Joined:
    Dec 18, 2008
    Messages:
    2,621
    Likes Received:
    165
    Sorry, maybe someone else can jump in with detailed help.

    I would have to get up to speed and review the files again and I'm buried in other site builds right now. Plus my current version is quite old so I would have to upgrade and no way I have time for that at the moment. Sorry.

    Do you have any knowledge of PHP? If so take a look at that file to see if the categories names are pulled from the database in some form already.



    Hey Nay, feel like trying your hand at a generalized tutorial on setting variables and using them in a template for the frequently asked questions?
    I actually think there is a posting (might have been mine? I'll look later if I get a chance) about it. Hard one to generalize but core to working with the package and always comes up when basic procedure is mentioned.
     
  15. ianhaney

    ianhaney New Member

    Joined:
    Apr 30, 2013
    Messages:
    59
    Likes Received:
    0
    Hi Box Lot

    To be honest am not sure on how to set the variable in the browse.php file and could not see how the category names are pulled from the database in that file

    Kind regards

    Ian
     
  16. nay27uk

    nay27uk Super Moderator Staff Member

    Joined:
    Nov 24, 2009
    Messages:
    5,572
    Likes Received:
    547
    Ok ian let me try and explain this, you may have this already but here goes.

    In header.php find on line 28 code

    PHP:
    $page_title = (isset($page_title)) ? ' ' $page_title ''
    Directly bellow on a new line add code

    PHP:
    function curPageName() { return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1); } 
    Next on line 64 find code

    PHP:
     'B_BOARDS' => ($system->SETTINGS['boards'] == 'y')
    Replace with code

    PHP:
    'B_BOARDS' => ($system->SETTINGS['boards'] == 'y'),
    'PAGE_NAME' => curPageName(),
     
    Save and close header.php and re upload.

    Now for the theme variable

    In your contactus.tpl or whatever .tpl runs the contact us page add the following code

    PHP:
    <!-- IF PAGE_NAME eq 'contactus.php' -->
    <
    title>{CAT_TITLE_NAME} - {PAGE_TITLE} - list your artwork without large fees Basildon Essex</title>
    <!-- ENDIF --> 
    It should then work however I have not tested it.




    Yes box drop me a quick PM to explain a bit more and I will see what I can put together are we talking something like this post I already made a long time ago
     
    Last edited: May 21, 2013
    ishahin likes this.
  17. ianhaney

    ianhaney New Member

    Joined:
    Apr 30, 2013
    Messages:
    59
    Likes Received:
    0
    Hi Nay

    Ok cool done all that but is just not displaying the category name in the browser title

    I added the following to the browse.tpl file thinking it might work but did not

    <!-- IF PAGE_NAME eq 'http://sellyourownart.com/browse.php?id=2' -->
    <title>{CAT_TITLE_NAME} - {PAGE_TITLE} - list your artwork without large fees - Basildon - Essex</title>

    Not sure what else to try really
     
  18. Xeonn

    Xeonn New Member

    Joined:
    Dec 15, 2011
    Messages:
    371
    Likes Received:
    55
    {CAT_STRING} not CAT_TITLE_NAME

    or add in template vars :
    PHP:
    'TOPCATSPATH' => ($system->SETTINGS['extra_cat'] == 'y' && isset($_SESSION['browse_id']) && $_SESSION['browse_id'] == $auction_data['secondcat']) ? $secondcat_value $cat_value,
            
    'CATSPATH' => $cat_value,
            
    'SECCATSPATH' => $secondcat_value,
            
    'CAT_ID' => $auction_data['category'],
    and in php file :
    PHP:
    // build bread crumbs
    $query "SELECT left_id, right_id, level FROM " $DBPrefix "categories WHERE cat_id = " $auction_data['category'];
    $res mysql_query($query);
    $system->check_mysql($res$query__LINE____FILE__);
    $parent_node mysql_fetch_assoc($res);

    $cat_value '';
    $crumbs $catscontrol->get_bread_crumbs($parent_node['left_id'], $parent_node['right_id']);
    for (
    $i 0$i count($crumbs); $i++)
    {
        if (
    $crumbs[$i]['cat_id'] > 0)
        {
            if (
    $i 0)
            {
                
    $cat_value .= ' > ';
            }
            
    $cat_value .= '<a href="' $system->SETTINGS['siteurl'] . 'browse.php?id=' $crumbs[$i]['cat_id'] . '">' $category_names[$crumbs[$i]['cat_id']] . '</a>';
        }
    }

    $secondcat_value '';
    if (
    $system->SETTINGS['extra_cat'] == 'y' && intval($auction_data['secondcat']) > 0)
    {
        
    $query "SELECT left_id, right_id, level FROM " $DBPrefix "categories WHERE cat_id = " $auction_data['secondcat'];
        
    $res mysql_query($query);
        
    $system->check_mysql($res$query__LINE____FILE__);
        
    $parent_node mysql_fetch_assoc($res);

        
    $crumbs $catscontrol->get_bread_crumbs($parent_node['left_id'], $parent_node['right_id']);
        for (
    $i 0$i count($crumbs); $i++)
        {
            if (
    $crumbs[$i]['cat_id'] > 0)
            {
                if (
    $i 0)
                {
                    
    $secondcat_value .= ' > ';
                }
                
    $secondcat_value .= '<a href="' $system->SETTINGS['siteurl'] . 'browse.php?id=' $crumbs[$i]['cat_id'] . '">' $category_names[$crumbs[$i]['cat_id']] . '</a>';
            }
        }
    }
    taken from item.php where category is displayed
     
  19. ianhaney

    ianhaney New Member

    Joined:
    Apr 30, 2013
    Messages:
    59
    Likes Received:
    0
    Hi Xeonn

    I tried {CAT_STRING} instead and didn't work

    What file do I need to add the following to

    'TOPCATSPATH' => ($system->SETTINGS['extra_cat'] == 'y' && isset($_SESSION['browse_id']) && $_SESSION['browse_id'] == $auction_data['secondcat']) ? $secondcat_value : $cat_value,
    'CATSPATH' => $cat_value,
    'SECCATSPATH' => $secondcat_value,
    'CAT_ID' => $auction_data['category'],

    Also what php file do I need to add the following to

    // build bread crumbs
    $query = "SELECT left_id, right_id, level FROM " . $DBPrefix . "categories WHERE cat_id = " . $auction_data['category'];
    $res = mysql_query($query);
    $system->check_mysql($res, $query, __LINE__, __FILE__);
    $parent_node = mysql_fetch_assoc($res);

    $cat_value = '';
    $crumbs = $catscontrol->get_bread_crumbs($parent_node['left_id'], $parent_node['right_id']);
    for ($i = 0; $i < count($crumbs); $i++)
    {
    if ($crumbs[$i]['cat_id'] > 0)
    {
    if ($i > 0)
    {
    $cat_value .= ' > ';
    }
    $cat_value .= '<a href="' . $system->SETTINGS['siteurl'] . 'browse.php?id=' . $crumbs[$i]['cat_id'] . '">' . $category_names[$crumbs[$i]['cat_id']] . '</a>';
    }
    }

    $secondcat_value = '';
    if ($system->SETTINGS['extra_cat'] == 'y' && intval($auction_data['secondcat']) > 0)
    {
    $query = "SELECT left_id, right_id, level FROM " . $DBPrefix . "categories WHERE cat_id = " . $auction_data['secondcat'];
    $res = mysql_query($query);
    $system->check_mysql($res, $query, __LINE__, __FILE__);
    $parent_node = mysql_fetch_assoc($res);

    $crumbs = $catscontrol->get_bread_crumbs($parent_node['left_id'], $parent_node['right_id']);
    for ($i = 0; $i < count($crumbs); $i++)
    {
    if ($crumbs[$i]['cat_id'] > 0)
    {
    if ($i > 0)
    {
    $secondcat_value .= ' > ';
    }
    $secondcat_value .= '<a href="' . $system->SETTINGS['siteurl'] . 'browse.php?id=' . $crumbs[$i]['cat_id'] . '">' . $category_names[$crumbs[$i]['cat_id']] . '</a>';
    }
    }
    }

    Kind regards

    Ian
     
  20. Box Lot

    Box Lot Super Moderator Staff Member Developer

    Joined:
    Dec 18, 2008
    Messages:
    2,621
    Likes Received:
    165
    Hard one to do as I said but certain that post touches on some of the basics pretty well. I would isolate the bits about creating and setting the variable in the php file and then using it in template file.
     

Share This Page