SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    phplib template and conditions

    Hello,
    I would like to know how to do this using phplib template, for example:

    If (condition x)
    {
    //display the link "edit" to allow the user click on it
    }
    else
    {
    //display the link "delete" to allow the user click on it
    }

    I don't want to hardcode the links "edit" or "delete" on the x.html page such as:
    a row with title... [edit] [delete]

    so if the condition x is true then it will display a x.html web page with:
    a row with title... [edit]
    else it will displays the SAME x.html page BUT with:
    a row with title... [delete]

    How do I do it?
    Thanks,
    John
    Last edited by johnn; Jun 4, 2001 at 01:36.

  2. #2
    Node mutilating coot timnz's Avatar
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well you would parsing an extra thing, or you could add it to the end of your variable with the a row title stuff.

    So it would be like:

    if (condition x)
    {
    $content .= '<a href="">[Edit]</a>';
    }
    else
    {
    $content .='<a href="">[Delete]</a>';
    }

    Where content is the variable with the row title stuff in, or you could change it to another name to put this in another variable to parse through your template, but be sure to make it like this:
    $variable = '<a href="">Whatever</a>';

    Then just parse your template like normal, or parse it with the added variable.

    Hope this is what you were after.

  3. #3
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, but I'm not sure if it works because it will display

    <a href="">[Delete]</a>

    exactly letter by letter in the browser... because say if
    $y ='<a' then it displays <a in browser. See what I mean?

    John
    Last edited by johnn; Jun 4, 2001 at 01:55.

  4. #4
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It should work, it should be a real hyperlink instead of displaying the <a, if you want to display the actual text, you would write:

    Code:
    &lt;a href=""&gt;[Delete]&lt;/a&gt;

  5. #5
    SitePoint Zealot
    Join Date
    May 2000
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: phplib template and conditions

    I use a modified version of phplib template. I use this method:

    x.html
    <!--logged_in-->
    You are logged in.
    <!--logged_in-->

    <!--not_logged_in-->
    Please Login
    <!--not_logged_in-->


    Then, if the user is logged in, I remove the HTML inside <!--not_logged_in-->(.*?)<!--not_logged_in-->, else I remove the HTML in <!--logged_in-->(.*?)<!--logged_in-->
    Use regular expressions.

    Something like this in my php script:

    $tp = new Template("x.html");

    if (Logged in) {
    $tp->Remove("not_logged_in");
    } else {
    $tp->Remove("logged_in");
    }


    Arpith

  6. #6
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Everyone,

    The Remove() function is what I need, then I need the modified version of PHPlib. What's the url to download it?

    If not, any other comments?
    Thanks,
    John
    Last edited by johnn; Jun 4, 2001 at 13:00.


Bookmarks

Posting Permissions

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