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

accessing simpleCache from templates

Discussion in 'XenForo Development Discussions' started by tenants, May 11, 2015.

  1. tenants

    tenants Well-Known Member

    For sessions, there is no need to added anything to the controller/model/view since the session can be accessed from a template as:

    {$session.x}

    for example:
    Code:
    <xen:if is="!{$session.robotId}">
       Xenforo has not detected me as a crawler
    </xen:if>
    Is there something similar for simpleCache (since its globally fetched and requires 0 query overhead)
    Or do I have to push something in the controller every time I need to access simpleCache in a template ?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Yes:
    Code:
    {$xenCache.key}
    e.g.

    Code:
    <xen:if is="{$xenCache.userUpgradeCount}"><li><a
        class="{xen:if "{$selectedKey} == 'account/upgrades'", 'secondaryContent', 'primaryContent'}"
        href="{xen:link account/upgrades}">{xen:phrase account_upgrades}</a></li></xen:if>
     
    tenants likes this.
  3. tenants

    tenants Well-Known Member

    Chris, you are a star... saved me hours :)
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    Incidentally you can see default template params by going to:
    XenForo_Dependencies_Abstract::preRenderView();

    They will apply to public and admin templates.

    Then there's some Admin/Install/Public specific ones too.
     
    NixFifty and tenants like this.

Share This Page