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

Checking User (PHP & SQL)

Discussion in 'General PHP and MySQL Discussions' started by AyoubM, Jul 20, 2016.

  1. AyoubM

    AyoubM Member

    Hey guyes,

    So I'm new to XenForo developing but I'd like to check if a column in sql is set to 1 or 0
    And the check should be on every page load.

    Any idea how I can do this without creating a addon?

  2. AyoubM

    AyoubM Member

    Anything guyes?
  3. Claudio

    Claudio Well-Known Member

  4. AyoubM

    AyoubM Member

    Thanks for your reply.
    But that's not it, I know how to code it, I just need to know how can I make xenforo check it every page request without modifying xenforo files.

  5. AyoubM

    AyoubM Member

    Comeon guyes.. anything?

    I just need my query to run on every page load without modifying any of the xenforo files....
  6. AyoubM

    AyoubM Member

    Okay, better said, what can I extend and what function? So that it's done every page.

  7. Jim Boy

    Jim Boy Well-Known Member

    You need some sort of add-on creation - that is just how XF manages it.

    But in super simple steps one way of doing this is:

    1. Put XF in debug mode
    2. Go to development tools
    3. Go to code event listneres and add a listener
    4. In 'Listen to Event', choose 'Template Create'
    5. In 'event hint', choose 'PAGE_CONTAINER'
    6.In Execute Call back put a rerference to your code file eg 'myAddOn_Listener' would equate to /library/myAddOn/Listener.php
    7 In the medthod box (after the "::") put your function called, eg 'listen'
    8 put you code in the file - take note of the Callback Signature info, you need it, eg
    class myAddOn_Listener
        public static function listen(&$templateName, array &$params, XenForo_Template_Abstract $template)
            // do some code

Share This Page