Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,127
    Thanks
    27
    Thanked 0 Times in 0 Posts

    How to build an HTML Meta String

    Here is a sample HTML meta string...
    Code:
    <link rel="next" href="http://www.example.com/article-part2.html">

    Could someone please help me figure out the easiest way to be able to echo this string out, but replacing the fixed values of "next" and the URL with variables?

    (I seem to be going in circles with single and double quotes, and am sure there is an easier way than how I'm going about this!)

    Thanks,


    Debbie

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,313
    Thanks
    4
    Thanked 207 Times in 204 Posts
    PHP Code:
    echo '<link rel="' $nextvar '" href="' $urlvar '">'
    Dave .... HostMonster for all of your hosting needs

  • #3
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,127
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by djm0219 View Post
    PHP Code:
    echo '<link rel="' $nextvar '" href="' $urlvar '">'
    *sigh*

    That is what I am trying to avoid...

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,549
    Thanks
    8
    Thanked 1,095 Times in 1,086 Posts
    <link rel="<?=$nextvar?>" href="<?=$urlvar?>">

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,476
    Thanks
    63
    Thanked 538 Times in 525 Posts
    Quote Originally Posted by doubledee View Post
    *sigh*
    I'm stayin outta this
    I can't really think of anything to write here now...

  • #6
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,474
    Thanks
    13
    Thanked 361 Times in 357 Posts
    I’m always fond of sprintf().
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #7
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,313
    Thanks
    4
    Thanked 207 Times in 204 Posts
    Quote Originally Posted by doubledee View Post
    That is what I am trying to avoid...
    Say what? That's what you asked for. There are no circles with the quotes in what I posted.
    Dave .... HostMonster for all of your hosting needs

  • #8
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,127
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Dormilich View Post
    I’m always fond of sprintf().
    And how would you use it here?


    Debbie

  • #9
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,127
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by djm0219 View Post
    Say what? That's what you asked for. There are no circles with the quotes in what I posted.
    I went with this in my PHP section, and then just echoed it in my HTML section...
    PHP Code:
            $urlNext BASE_URL "/$sectionSlug/$subsectionSlug/$sortName/$sortDir/$nextPage";
            
    $relNext "<link rel='next' href='$urlNext'>\n"

    Debbie

  • #10
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,127
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tangoforce View Post
    I'm stayin outta this
    You finally learned!!

    BTW, you owe me a l-o-n-g PM...


    Debbie

  • #11
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,476
    Thanks
    63
    Thanked 538 Times in 525 Posts
    and I actually have the time to answer it too so I shall head to my PM box..

    BTW you do realise that the way you've done it is pretty much the same as djm0219's method don't you? - and you sighed at him for it.

    Someone owes someone a little apology
    I can't really think of anything to write here now...

  • #12
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,474
    Thanks
    13
    Thanked 361 Times in 357 Posts
    Quote Originally Posted by doubledee View Post
    And how would you use it here?
    I thought the Manual’s entry would have been sufficient enough …

    PHP Code:
    $link '<link rel="%s" href="http://www.example.com/%s">' PHP_EOL;
    $links[] = sprintf($link"next""article-part2.html"); 
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #13
    Regular Coder Linux_Sage's Avatar
    Join Date
    Mar 2014
    Location
    Sterling,VA
    Posts
    106
    Thanks
    0
    Thanked 10 Times in 10 Posts
    Any particular reason why you're adding the BASE_URL on all your links? I've noticed you doing it on your other questions. Seems to me you're forcing all your links to be absolute and I can't think of any reasons why this would be useful.

  • #14
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,127
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Linux_Sage View Post
    Any particular reason why you're adding the BASE_URL on all your links? I've noticed you doing it on your other questions. Seems to me you're forcing all your links to be absolute and I can't think of any reasons why this would be useful.
    I created BASE_URL long ago.

    To be honest, I can't remember the exact reason, but there was a logical reason. It had something to do with the fact that Relative Links broke horribly when I was including files.

    Also, in more recent times, there are things like rel=canonical that require an absolute path.

    No harm, no foul.


    Debbie

  • #15
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,476
    Thanks
    63
    Thanked 538 Times in 525 Posts
    Quote Originally Posted by djm0219 View Post
    PHP Code:
    echo '<link rel="' $nextvar '" href="' $urlvar '">'
    Quote Originally Posted by doubledee View Post
    *sigh*

    That is what I am trying to avoid...
    Quote Originally Posted by doubledee View Post
    I went with this in my PHP section, and then just echoed it in my HTML section...
    PHP Code:
            $urlNext BASE_URL "/$sectionSlug/$subsectionSlug/$sortName/$sortDir/$nextPage";
            
    $relNext "<link rel='next' href='$urlNext'>\n"

    Debbie
    Quote Originally Posted by tangoforce View Post
    BTW you do realise that the way you've done it is pretty much the same as djm0219's method don't you? - and you sighed at him for it.

    Someone owes someone a little apology
    This isn't going away
    I can't really think of anything to write here now...


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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