• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "php dynamic page title"

Collapse

  • Kipper
    replied
    Ruby Page Title in Common Header

    And if anyone is at all interested here is a solution to providing a different page title on each dynamic page through a common header driven by Ruby:

    Code:
    <% if(@cgi.path_info == '/' || @cgi.path_info == '/index') %>
    <title>The Index Landing Page for Your Site</title>
    <% end %>
    It works but there is a down side. You have to add the above code in your header for each dynamic page generated. Not the prettiest way for sure and on a site with many pages will probably increase your code string to more than double its size in length.

    But for now it is the best fix I can find. Ideally it would be great if there was a way it could read a class identifier off of a h2 page header. Not cracked that one though!

    Leave a comment:


  • NickFitz
    replied
    Originally posted by Kipper View Post
    Not a perfect solution but its only an extra file to copy update as and when it is required.
    And of course your build-and-deploy process will automate that

    Leave a comment:


  • Kipper
    replied
    My Solution

    Thanks for all the posts and help.
    Having duelled on this for a few days I have decided the only answer in this case is to run twin header idents. One for the ruby set up and one for the php files. Not a perfect solution but its only an extra file to copy update as and when it is required.

    cheers

    Leave a comment:


  • Freamon
    replied
    Originally posted by Kipper View Post
    Thanks Nick
    I sort of figured as much. But it is nice to have it confirmed, that way I know that my search for a php answer is fruitless.

    Maybe time to start learning some rails! Never, managed to get my head around the first tutorials I saw when I first looked though!
    It's worth persevering with Rails - it's a great framework.

    Leave a comment:


  • Kipper
    replied
    Thanks Nick
    I sort of figured as much. But it is nice to have it confirmed, that way I know that my search for a php answer is fruitless.

    Maybe time to start learning some rails! Never, managed to get my head around the first tutorials I saw when I first looked though!

    Leave a comment:


  • NickFitz
    replied
    Originally posted by Kipper View Post
    FFS!!!
    Spoke a bit too soon there. Works a total treat on the php generated pages but the ruby generated pages the title is printed as <?=$_TITLE?> This includes the home page.

    To be expected I guess, not sure that ruby can read php?

    Seems this is one battle I can not win. makes me...

    As a crappy work around I may go with a generic title followed by the php <?=$_TITLE?>
    This will print the code at the end of the header title in the ruby pages only which isn't great but I can use it while I find an alternative as this is holding up publication now.

    Thanks for your coding help; cures about 75% of the problem at least.
    If the server (presumably Apache) is configured to serve .rhtml files via the appropriate Ruby module, then the PHP module (mod_php or whatever) will never see them, and thus never get a chance to run any PHP code in them.

    Leave a comment:


  • Kipper
    replied
    Damn it!

    FFS!!!
    Spoke a bit too soon there. Works a total treat on the php generated pages but the ruby generated pages the title is printed as <?=$_TITLE?> This includes the home page.

    To be expected I guess, not sure that ruby can read php?

    Seems this is one battle I can not win. makes me...

    As a crappy work around I may go with a generic title followed by the php <?=$_TITLE?>
    This will print the code at the end of the header title in the ruby pages only which isn't great but I can use it while I find an alternative as this is holding up publication now.

    Thanks for your coding help; cures about 75% of the problem at least.

    Leave a comment:


  • Kipper
    replied
    SOLVED

    Admin - You are my Hero(in)
    Topic Solved - It WORKED!! I've been battling with this one for the better part of two weeks (well not continuously).

    Many many thanks - Contractor UK Rocks.

    Kipper

    Leave a comment:


  • Kipper
    replied
    Thanks for that. It looks like a perfect working solution. My only concern is that any php above the doc type seem to break the ruby header, it is a bit unforgiving like that; but I will give it a go and see.

    regards

    Leave a comment:


  • administrator
    replied
    No Ruby on this example but this is how I have it working on a pure PHP site which pulls a common header:

    At the top of the individual page page where you want to specify a unique page title:

    Code:
    <?php
    $_TITLE = "This is the page specific title";
    
    require_once("headerhome.template.php");
    ?>

    Then in the header template:

    Code:
    <?php
    if (!$_TITLE) {
      $_TITLE = "This is the generic page title.";
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
     <title><?=$_TITLE?></title>

    Leave a comment:


  • Kipper
    started a topic php dynamic page title

    php dynamic page title

    Hi,
    I was wondering if there are any web master members who know a way to solve a issue I'm having with a php / ruby run web site.

    I am putting a site together that uses a common php include header. This of course then presents a common page title which I need to solve for SOE reasons. The way the header works also includes the navigation and the top of each page with the <body> tag. The other issue is that the header is a rhtml file as the back end runs on ruby, which I can not change or access (aside from the templates). This means it has a low tolerance for including too much php scripting before breaking it.

    I have search the web for ways around this and found a few near but not quite there answers. A lot revolve around the naming the <body> with a class, which I can not use.

    I'm looking for a way that can pick up another element in the individual page. I have found this method which uses a heading class to work (Although I'd change it to use a <h2 = class"">):

    <?php if ($title): ?>
    <?php print render($title_prefix); ?>
    <h1 class="title" id="page-title"><?php print $title; ?></h1>
    <?php print render($title_suffix); ?>
    <?php endif; ?>

    I can't get this to work though. The anonymous source on a pastebox site was unclear on any detailed usage instruction. I am not sure on what to place in the header and what to place on the page. When placed in the header it just breaks the script as expected. Has anyone else had this sort of problem and found a fix please? Or can make more sense out of this code than me.

    Kind regards
    kipper

Working...
X