Results 1 to 15 of 19
Page 1 of 2
FirstFirst 1 2 ... LastLast

Thread: [Concept Demo RC3] Conditionals in templates

  1. #1
    Former vBulletin Developer Mike Sullivan will become famous soon enough Mike Sullivan's Avatar
    Join Date
    Apr 2000
    Location
    Regexia
    Age
    25
    Posts
    13,374
    Blog Entries
    7

    [Concept Demo RC3] Conditionals in templates

    I threw this together in about 45 minutes today. It allows you to put stuff like this in your templates:
    {if ($bbuserinfo[userid]) {
    <a href="usercp.php?s=$session[sessionhash]">User CP!</a>
    }else{
    <a href="register.php?s=$session[sessionhash]&action=signup">Signup!</a>
    }endif}

    Of course, it requires a code edit for each template, so it's somewhat counter intuitive, but as I said, it's not exactly a release -- it's more a concept demo.

    Requires PHP4 as I use the /e modifier. Also, you'll want to have some decent PHP understanding. See attachment for more info.

    Feel free to ask questions, but I may not answer/support like I did past hacks.
    --Mike "Ed" Sullivan
    Former vBulletin Developer

    Twitter | Regexia (personal)
     

  2. #2
    Senior Member bira is on a distinguished road bira's Avatar
    Join Date
    May 2000
    Location
    2nd turn left
    Age
    42
    Posts
    1,501
    Thanks Mike, I needed something like this!
     

  3. #3
    Senior Member Mark Hewitt has disabled reputation Mark Hewitt's Avatar
    Join Date
    Apr 2000
    Location
    Geordieland, UK
    Age
    31
    Posts
    1,112
     

  4. #4
    Senior Member TWTCommish has disabled reputation TWTCommish's Avatar
    Join Date
    Jul 2000
    Location
    Pittsburgh, PA
    Posts
    664
    If you're looking for a quick way to swap buttons, do what I did: use the phpinclude template, a one-line ternary operator that stores the HTML for either the register button, or the user cp button -- hold it in a variable name not used elsewhere, and call on it in the template.

    Example:

    Code:
    $the_button = (isset($bbuserid)) ? sprintf('<img src="images/top_register.gif">') : sprintf('<img src="images/top_usercp.gif">');
    Movie Forums - Now With 28% More Bruce Willis
     

  5. #5
    Former vBulletin Developer Mike Sullivan will become famous soon enough Mike Sullivan's Avatar
    Join Date
    Apr 2000
    Location
    Regexia
    Age
    25
    Posts
    13,374
    Blog Entries
    7
    That was just an example

    And if you wanna get technical, you should check $bbuserinfo[userid] instead of bbuserid for those who don't store their username/password.
    --Mike "Ed" Sullivan
    Former vBulletin Developer

    Twitter | Regexia (personal)
     

  6. #6
    Senior Member TWTCommish has disabled reputation TWTCommish's Avatar
    Join Date
    Jul 2000
    Location
    Pittsburgh, PA
    Posts
    664
    A competition now, eh? Well, it's just an extremely simple way to allow people to display the appropriate button.
    Movie Forums - Now With 28% More Bruce Willis
     

  7. #7
    vBulletin Team Wayne Luke is a name known to all Wayne Luke is a name known to all Wayne Luke is a name known to all Wayne Luke is a name known to all Wayne Luke is a name known to all Wayne Luke is a name known to all Wayne Luke's Avatar
    Join Date
    Aug 2000
    Location
    So. California
    Age
    38
    Posts
    34,673
    Blog Entries
    1
    Chris -

    It isn't a competition. Look at where Mike said he put his conditional and look at where you put yours.

    Mike is talking about adding conditionals to any template where they are processed by keyword. This could be used by non-programmers to make things all over the system change based on various information. They wouldn't have to learn a whole new language just a few commands.

    Mike -
    This is a great concept and it should probably be pursued for later versions. This would greatly improved the functionality of vBulletin.
    Wayne Luke
    Get started with your own social network.
    Purchase and download vBulletin today.
    vBCodex (Running vB 4.0 Suite) - Take your vBulletin Community to the next level. Modification tips, tricks and support.
     

  8. #8
    Senior Member TWTCommish has disabled reputation TWTCommish's Avatar
    Join Date
    Jul 2000
    Location
    Pittsburgh, PA
    Posts
    664
    Yes, I know -- I was making a joke.
    Movie Forums - Now With 28% More Bruce Willis
     

  9. #9
    Senior Member Mas*Mind has disabled reputation
    Join Date
    Jun 2000
    Location
    Amsterdam, The Netherlands
    Age
    30
    Posts
    1,450
    Personally I don't see the point to give templates this functionality. Templates are meant to separate code from layout and now you're bringing back the code into the layout

    It gives templates more flexibility: true, but also makes them harder to understand to newbies.

    This can be a great addon for some people, but I hope this won't be a standard in vb
     

  10. #10
    Former vBulletin Developer Mike Sullivan will become famous soon enough Mike Sullivan's Avatar
    Join Date
    Apr 2000
    Location
    Regexia
    Age
    25
    Posts
    13,374
    Blog Entries
    7
    Would this version ever see an official release? No, it's physically impossible because it requires PHP4.

    Then you add that fact that you regex any template that you want to use with it

    Using this system could eliminate a large amount of templates though...
    --Mike "Ed" Sullivan
    Former vBulletin Developer

    Twitter | Regexia (personal)
     

  11. #11
    Senior Member Mas*Mind has disabled reputation
    Join Date
    Jun 2000
    Location
    Amsterdam, The Netherlands
    Age
    30
    Posts
    1,450
    Would this version ever see an official release? No, it's physically impossible because it requires PHP4.

    Then you add that fact that you regex any template that you want to use with it
    Yes, it can dramaticly infect the speed. I'm not sure how many, but regexes are pretty resource intensive

    Using this system could eliminate a large amount of templates though...
    Yeah, but still: It defeats the purpose of templates imho
     

  12. #12
    Senior Member chrispadfield is on a distinguished road chrispadfield's Avatar
    Join Date
    Aug 2000
    Location
    London, UK
    Age
    28
    Posts
    5,368
    i don't know, gossamer threads does this sort of thing for their links based templates and it works very very well. It saves having to have 10 million options for everything like how many links to display here, there and everywhere else because you can set it as part of the template, and in that case it is a display thing because displaying 10 links as opposed to 20 is a display issue. I am not sure the idea transfers over so well to vb but it is still interesting idea anyway.
     

  13. #13
    New Member cliffe2 is on a distinguished road
    Join Date
    May 2001
    Posts
    19
    a combi of a php variable & javascript can do something nice too ...
     

  14. #14
    Senior Member Vinnie is on a distinguished road
    Join Date
    May 2001
    Location
    Miami Beach
    Age
    37
    Posts
    133

    Awesome!

    This is EXACTLY what I need.

    However, I am concerned about the speed issues, and the necessity of reapplying the mod for every new release.

    This having been said, I have an expanded "fivelinks" nav bar at the top of my forum:
    http://forum.bearsharelabs.com
    or
    http://208.239.76.100

    I want to have the "Logout" icon change to "Login" depending on the state of the user.

    It would also be nice to have a "Post" icon appear in the list at the appropriate time.

    And, it would be cool to NOT show the "User control panel" icon when they are actually already viewing the control panel.

    While we're at it, it would be good not to show the Admin icon unless they actually had administrator privileges.

    The possibilities are endless.
     

  15. #15
    Senior Member Mas*Mind has disabled reputation
    Join Date
    Jun 2000
    Location
    Amsterdam, The Netherlands
    Age
    30
    Posts
    1,450
    Originally posted by chrispadfield
    i don't know, gossamer threads does this sort of thing for their links based templates and it works very very well. It saves having to have 10 million options for everything like how many links to display here, there and everywhere else because you can set it as part of the template, and in that case it is a display thing because displaying 10 links as opposed to 20 is a display issue. I am not sure the idea transfers over so well to vb but it is still interesting idea anyway.
    I don't say it's not usefull; In most cases it actually saves alot of vbcode to accomplish certain things. But again: Templates are meant to separate code from layout (for designs sake and to make it friendly for non-coders). Bringing back the code into it just makes no sense.
     

Page 1 of 2
FirstFirst 1 2 ... LastLast

Similar Threads

  1. Conditionals in templates
    By nuno in forum vBulletin Suggestions and Feedback
    Replies: 6
    Last Post: Sat 8th Feb '03, 12:39pm
  2. Conditionals in templates
    By Total Cult in forum vBulletin Suggestions and Feedback
    Replies: 27
    Last Post: Sun 8th Dec '02, 6:37pm
  3. Conditionals in templates?
    By clindh in forum PHP & HTML Questions
    Replies: 0
    Last Post: Thu 8th Mar '01, 9:36am
  4. Conditionals in templates?
    By clindh in forum vBulletin 2 'How Do I' and Troubleshooting
    Replies: 1
    Last Post: Fri 2nd Mar '01, 9:26am

Bookmarks

Posting Permissions

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