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

Custom Variables?

Discussion in 'XenForo Development Discussions' started by Hersheybar, Jan 15, 2014.

  1. Hersheybar

    Hersheybar New Member

    I was wondering how i'd pass custom variables on to a template and load them in the template, i'm assuming loading them in the template will be something like {$custom.ver} or something. I was just wondering how to do it PHP side, the variable will be dynamic and be defined in the code when it runs.
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    You'll need to extend the controller that utilizes the templates and add them into the viewParams. This can be done via the class proxy system, but needs to be done via PHP.
     
  3. Hersheybar

    Hersheybar New Member

    Thanks, i'll look into this now. Also is there any documentation? I'd love to have a read of it if there is.
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

  5. Hersheybar

    Hersheybar New Member

  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    PHP:
    XenForo_Application::get('db');
     
    Vincent Gabriel likes this.
  7. Vincent Gabriel

    Vincent Gabriel Active Member

    XenForo is built on top of Zend Framework, So you'll be using the Zend_Db component.

    Once you do:

    PHP:
    $db XenForo_Application::getDb();
    You'll be able to use the methods listed here in the Zend_Db documentation.
    http://framework.zend.com/apidoc/1.11/
     
    Daniel Hood likes this.

Share This Page