17 replies
Wondering if anyone has any ideas on how to solve a small problem.

I have this code:

Code:
<?php if (!S2MEMBER_CURRENT_USER_IS_LOGGED_IN){ ?>
<a href="<?php echo S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL; ?>">Please subscribe now to continue reading</a>
<a href="<?php echo S2MEMBER_LOGIN_PAGE_URL; ?>">Or Login</a>
<?php } ?>]
This is from the S2Member WP membership plugin.

The part I need help with are the two echo statements. Currently the two options are on two different lines but I would like to have them all on one line if possible just for a little better look.

Any ideas?

Thanks in advance.

Mark
#php #question
  • Profile picture of the author kewkii
    I take it you mean they're on different lines when viewing the resulting page? You need to look at the styling of anchor 'a' elements in your stylesheet.
    {{ DiscussionBoard.errors[9288227].message }}
    • Profile picture of the author Kent_Thompson
      try putting both links on the same line in the PHP code and put a &nbsp; to join them, with no spaces between them.
      Signature
      Use Agency Ace to provide white-label directory, loyalty, rewards, direct-mail, email & SMS marketing services to local businesses: http://www.agencyace.com
      {{ DiscussionBoard.errors[9290730].message }}
  • Profile picture of the author RobinInTexas
    You need to combine the strings into one string


    <a href=
    S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL
    Please subscribe now to continue reading</a><a href=
    S2MEMBER_LOGIN_PAGE_URL
    Or Login</a>

    and output them in one php echo statement (I have to get to a project now and would have to test the code to get it perfect, but the 2 separate php echo statements is what's forcing the line break
    Signature

    Robin



    ...Even if you're on the right track, you'll get run over if you just set there.
    {{ DiscussionBoard.errors[9292219].message }}
  • Profile picture of the author kingjpm
    For example
    PHP Code:
    define("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL","http://www.");
    define("S2MEMBER_LOGIN_PAGE_URL","http://");

    printf("%s",'<a href="'.S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL.'">Please subscribe now to continue reading</a> <a href="'.S2MEMBER_LOGIN_PAGE_URL.'">Or Login</a>'); 
    Signature
    RogueDen.com
    {{ DiscussionBoard.errors[9293087].message }}
  • Profile picture of the author Mark Singletary
    I appreciate the responses but for some reason I can't get any of it to work. I tried Robin's solution but couldn't figure out how to get it in one echo statement.

    I'll keep fiddling with it or try to find another workaround. This may be one of those things I have to settle for 2nd or 3rd best in order to get the project finished versus spending forever on a little problem.

    Thanks again.

    Mark
    {{ DiscussionBoard.errors[9293455].message }}
  • Profile picture of the author kingjpm
    Mark, for my example code, be sure to take out the define part

    PHP Code:
    define("S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL","http://www.");
    define("S2MEMBER_LOGIN_PAGE_URL","http://"); 
    that was just there for example purpose
    Signature
    RogueDen.com
    {{ DiscussionBoard.errors[9293548].message }}
  • Profile picture of the author kewkii
    Is there any styling being applied to the anchors that would force them onto different lines? i.e. a { display:block; }
    {{ DiscussionBoard.errors[9293979].message }}
  • Profile picture of the author Nett
    Code:
    <?php
    if (!S2MEMBER_CURRENT_USER_IS_LOGGED_IN) {
        echo '<a href="' . S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL . '">Please subscribe now to continue reading</a><a href="' . S2MEMBER_LOGIN_PAGE_URL . '">Or Login</a>';
    }
    ?>
    {{ DiscussionBoard.errors[9294030].message }}
    • Profile picture of the author David Beroff
      If you can post the URL, I'm pretty sure someone will be able to see the issue. My bet is with the above guesses on CSS styling; the PHP source should still be able to output on two separate lines and display on one.
      Signature
      Put MY voice on YOUR video: AwesomeAmericanAudio.com
      {{ DiscussionBoard.errors[9294568].message }}
  • Profile picture of the author TheCrazyCoder
    <br /> - is tag for new line in html. New line can be caused by div, p and other tags or style "display: block".
    PHP new line don't mean new line in HTML.

    Most likely parent tag for your links don't have enough width to have links on same line and apply wordwrap.
    {{ DiscussionBoard.errors[9294677].message }}
  • Profile picture of the author Mark Singletary
    I decided to look into the shortcodes that came with the package versus the PHP - either should work.

    Using the shortcodes I can get both links on the same line so it shouldn't be the CSS.

    Code:
    <a href="[s2Get constant="S2MEMBER_LOGIN_PAGE_URL" /]">Login</a> <a href="[s2Get constant="S2MEMBER_MEMBERSHIP_OPTIONS_PAGE_URL" /]">Or Signup</a>
    Would still be interesting to know why the PHP didn't work from a learning standpoint.

    Thanks.
    Mark
    {{ DiscussionBoard.errors[9294703].message }}
    • Profile picture of the author David Beroff
      Wow. If that's the only difference between the two approaches, it sort of implies that the constant itself has a hard-coded line-break... which certainly shouldn't be the case. Take a close look and compare the source code for the two. Also consider using a tool like Firebug (or simply right-click > Inspect Element in Firefox); I find I learn a lot when I can quickly look how something is being done on the Web.
      Signature
      Put MY voice on YOUR video: AwesomeAmericanAudio.com
      {{ DiscussionBoard.errors[9294718].message }}
  • Profile picture of the author RobinInTexas
    Sounds like a lot of work for a tiny tweak of appearance that is not likely to have any effect.
    Signature

    Robin



    ...Even if you're on the right track, you'll get run over if you just set there.
    {{ DiscussionBoard.errors[9297170].message }}

Trending Topics