Results 1 to 13 of 13

if condition help

This is a discussion on if condition help within the Link Building forums, part of the vBulletin SEO Discussion category; I hope it's not against terms to ask for help with basic coding, but it does pertain to links If ...

  1. #1
    Senior Member Array
    Real Name
    Karl
    Join Date
    Aug 2008
    Location
    England
    Posts
    122
    Liked
    0 times
    Blog Entries
    1

    if condition help

    I hope it's not against terms to ask for help with basic coding, but it does pertain to links

    If it's not, feel welcome to delete it....


    Just need a quick hand with a condition statement...

    I'm trying to use two different ad codes depending on if the member is male or female.

    I created a profile field for Man / Woman.

    I currently have:
    Code:
    <if condition="$post['field7'] == 'Man'">
    <--code here for male members-->
    </if>
    
    <if condition="$post['field7'] == 'Woman'">
    <--code here for female members-->
    
    </if>
    I know the problem is with the condition code, and I also know I can't use (or at least, I don't know how to if I can?) is_member_of as that is for member groups, not profile fields.

    Any help, muchly appreciated.

    ETA: I mean, I know the above code works on the postbit and checks whether the member who posted is male or female... what I need it to do though, is check the reader's membership to field7 - whether they are male or female, and display ads according to the sex of the view - not the poster.

    In addition, I will be adding a condition based on the forumID. So for example, a man viewing a thread under the 'fathers forum' (say, ID=10) will see ads for (e.g.) "dads rights, thinning hair help, muscle building" while a woman would see ads similar, but based more towards their sex (e.g.) "safe sex, moms clubs, etc." - however, if a man viewed a different forum, e.g. 'health' , he'd see items relating to mens health - while women viewing the health forum would see ads directed towards women's health... long winded, but you get the idea I hope.
    You could have said instead of rewriting my signature.

  2. #2
    Senior Member Array
    Real Name
    Michael Biddle
    Join Date
    Jan 2007
    Location
    Southern California
    Posts
    7,095
    Liked
    5 times
    What page is that for? That should work on the postbit template, and probably the showthread page, other then that, you would need a new query.
    The Forum Hosting - Forum Hosting from the Forum Experts

  3. #3
    Senior Member Array
    Real Name
    Arkidas
    Join Date
    Feb 2008
    Posts
    254
    Liked
    1 times
    I think you can use

    Code:
    <if condition="$vbulletin->userinfo['field7'] == 'Man'">
    <--code here for male members-->
    </if>
    
    
    <if condition="$vbulletin->userinfo['field7'] == 'Woman'">
    <--code here for female members-->
    </if>

  4. #4
    Senior Member Array
    Real Name
    Karl
    Join Date
    Aug 2008
    Location
    England
    Posts
    122
    Liked
    0 times
    Blog Entries
    1
    Michael, I'm trying to figure that code to work as a seperate template - so it can be used in other locations, such as showthread or even FAQ. It'll be wrapped into pages using vbadvanced.
    Arkidas, that worked a treat (at least the minor test I've done works) thank you!
    You could have said instead of rewriting my signature.

  5. #5
    Senior Member Array
    Real Name
    Michael Biddle
    Join Date
    Jan 2007
    Location
    Southern California
    Posts
    7,095
    Liked
    5 times
    If you want it to be global, then use what Arkidas suggested.
    The Forum Hosting - Forum Hosting from the Forum Experts

  6. #6
    Senior Member Array
    Real Name
    Karl
    Join Date
    Aug 2008
    Location
    England
    Posts
    122
    Liked
    0 times
    Blog Entries
    1
    Nice one, thanks
    You could have said instead of rewriting my signature.

  7. #7
    Senior Member Array
    Real Name
    Chris
    Join Date
    May 2007
    Location
    Boston, MA
    Posts
    116
    Liked
    0 times
    I do it this way for my sidebar:

    <if condition="(in_array($bbuserinfo['usergroupid'], array(5, 6, 9, 11, 12, 13)) AND $vbulletin->userinfo[field18] <> 'No') OR !in_array($bbuserinfo['usergroupid'], array(5, 6, 9, 11, 12, 13))">
    Note that there are no ticks around [field18].

  8. #8
    Senior Member Array
    Real Name
    Karl
    Join Date
    Aug 2008
    Location
    England
    Posts
    122
    Liked
    0 times
    Blog Entries
    1
    Chris, thanks for the tip - but it's wayyyyy over my head!?!
    You could have said instead of rewriting my signature.

  9. #9
    Senior Member Array
    Real Name
    Michael Biddle
    Join Date
    Jan 2007
    Location
    Southern California
    Posts
    7,095
    Liked
    5 times
    It says, if the user viewing is in usergroups 5, 6, 9, 11, 12, 13, and their option for field18 does not equal no, OR if they are not in 5, 6, 9, 11, 12, 13, it will show it.
    The Forum Hosting - Forum Hosting from the Forum Experts

  10. #10
    Senior Member Array
    Real Name
    Karl
    Join Date
    Aug 2008
    Location
    England
    Posts
    122
    Liked
    0 times
    Blog Entries
    1
    So the layman's translation is:
    It shows to everyone, except usergroups 5, 6, 9, 11, 12, 13 who have selected anything other than 'No'?
    You could have said instead of rewriting my signature.

  11. #11
    Senior Member Array
    Real Name
    Michael Biddle
    Join Date
    Jan 2007
    Location
    Southern California
    Posts
    7,095
    Liked
    5 times
    Yes, exactly.
    The Forum Hosting - Forum Hosting from the Forum Experts

  12. #12
    Senior Member Array
    Real Name
    Karl
    Join Date
    Aug 2008
    Location
    England
    Posts
    122
    Liked
    0 times
    Blog Entries
    1
    Super. I have a very (very, very) basic understanding of this, but it's rather like a child's matchstick drawing of a 'sunny day at the park with daddy' vs michelangelo art exhibit.

    To be honest, it was more the 'in_array' that knocked my senses more then gist of the conditions themselves.
    You could have said instead of rewriting my signature.

  13. #13
    Senior Member Array
    Real Name
    Michael Biddle
    Join Date
    Jan 2007
    Location
    Southern California
    Posts
    7,095
    Liked
    5 times
    Personally I would rather use is_member_of then the $bbuserinfo, as it includes the secondary usergroups as well.

    Code:
    <if condition="(is_member_of($vbulletin->userinfo, 5, 6, 9, 11, 12, 13) AND $vbulletin->userinfo[field18] <> 'No') OR !is_member_of($vbulletin->userinfo, 5, 6, 9, 11, 12, 13)">
    The Forum Hosting - Forum Hosting from the Forum Experts

Similar Threads

  1. More if condition help - search and searchid
    By jbartle in forum Template Modifications
    Replies: 6
    Last Post: 09-24-2009, 12:11 AM
  2. IF condition for certain pages?
    By jbartle in forum Off-Topic & Chit Chat
    Replies: 9
    Last Post: 01-03-2007, 12:02 AM
  3. if condition for admins and mods only
    By jbartle in forum Off-Topic & Chit Chat
    Replies: 6
    Last Post: 10-14-2006, 11:56 PM

Posting Permissions

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