Skip to main content

Forums

This topic contains 8 replies, has 0 voices, and was last updated by  chrisburton 8 years, 4 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #32555

    chrisburton
    Participant

    I’m trying to figure out a way not to use wordpress for this because of the bulk files.

    Is there possibly a way to create page titles and body ID’s dynamically as I create links in the navigation?

    example:

    As I create:

  • Home


  • I get:
    John Doe

    or

    As I create:

  • News


  • I get:
    John Doe | News

    Any ideas?

    #48240

    ChrisBull
    Member

    Not sure if it will work but can’t you use $_SERVER; which should return everything after index, so if in the url you have http://www.site.com it will have a value of / or if the url is http://www.site.com/news/ it would return /news/ etc.
    then do something like this,,,


    $urlValue = $_SERVER;
    if($urlValue == "/") {
    $titleValue = "";
    } else {
    $urlValue = ltrim($urlValue = "/");
    $urlValue = rtrim($urlValue = "/");
    $titleValue = " | " . $urlValue;
    }


    //////Then in the Title Tag
    < ?php echo "John Doe" . $titleValue ?>

    I can’t see why it wouldn’t work but i havn’t tested it and it’s probably not the best way to go about it….

    #48247

    chrisburton
    Participant

    I want to say Chris made a screencast which showcased this but I can’t remember. Your code somewhat works but if I have a subdomain the title displays:

    John Doe | /

    #48248

    chrisburton
    Participant

    Fixed it by changing out the = and adding commas for $urlValue.

    $urlValue = $_SERVER;
    if($urlValue == "/") {
    $titleValue = "";
    } else {
    $urlValue = ltrim($urlValue, "/");
    $urlValue = rtrim($urlValue, "/");
    $titleValue = " | " . $urlValue;
    }

    Another question is how to get the title to be capitalized?

    #48150

    chrisburton
    Participant

    For anyone wanting to know:

    < ?php
    $urlValue = $_SERVER;
    if($urlValue == "/") {
    $titleValue = "";
    } else {
    $urlValue = Ltrim($urlValue, "/");
    $urlValue = Rtrim($urlValue, "/");
    $titleValue = " | " . ucfirst($urlValue);
    }
    ?>

    Title

    < ?php echo "John Doe" . $titleValue ?>

    Thanks @ChrisBull for getting me started

    #48034

    whats adding the dynamic body ID? I’ve been using
    ">
    to make the filename the body id.

    #48036

    chrisburton
    Participant

    @whiteInkDesign i’m confused by your response

    #48037

    I figured it out, had a blonde moment.

    #48039

    chrisburton
    Participant

    @whiteInkDesign Oh, sorry. I thought you were questioning my code, not asking a question yourself.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

icon-link icon-logo-star icon-search icon-star