1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

simple "if" condition

Discussion in 'XenForo Development Discussions' started by karev, Feb 15, 2011.

  1. karev

    karev Active Member

    hello community,im a really novice to oop php developpement but i try to verify if the post ID==1
    i mean to verify if its the first post in a thread can someone help me please ??
  2. James

    James Well-Known Member

    In templates, arrays use the dot (.) operator.

    Have you checked if $message has the array key post_id? I'll check in a second and get back to you.
  3. SneakyDave

    SneakyDave Well-Known Member

    I think this works, to determine the first post position, assuming you want it in a xF template.
    <xen:if is="{$post.position} == 0>
    .. do something crazy ..
  4. karev

    karev Active Member

    i just give example i dont know if its correct okey i'll delete the example to not confuse people XD
  5. karev

    karev Active Member

    no im not working with templates
  6. ragtek

    ragtek Guest

    where are you trying to use this?
  7. karev

    karev Active Member

  8. James

    James Well-Known Member

    A simple workaround (from a quick 5sec glance) would be to add another condition to the if ($visitor['user_id'] <= 0)

    Something like: if (($visitor['user_id'] <= 0) && ($message['post_id'] == '1'))
  9. karev

    karev Active Member

    thanks james but this disable the addons :(
  10. SneakyDave

    SneakyDave Well-Known Member

    There's an error in that if, a missing parenthesis I think....
    if (($visitor['user_id'] <= 0) && ($message['post_id'] == '1'))
  11. karev

    karev Active Member

    always dont work
  12. SchmitzIT

    SchmitzIT Well-Known Member

    Can you explain in a bit more detail what you are trying to do, and where in the code you are seeing problems?
  13. karev

    karev Active Member

  14. EQnoble

    EQnoble Well-Known Member

    Basically you want unregistered users to not be able to view the contents of the original post unless they are logged in with permissions right?
  15. karev

    karev Active Member

    i want that visitor cant see the link in the first post of the thread ,only link in first post
  16. Ajaxboy

    Ajaxboy Active Member

    Well first you gotta get the thread object then, you gotta go from there..

    If you are novice, I would not recommend editing things as it could brake something. But otherwise, post what you have and will try to point you on the right path..
    karev likes this.

Share This Page