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

Only execute callback2 if callback1 doesn't return content?

Discussion in 'XenForo Development Discussions' started by Marcus, Sep 13, 2013.

  1. Marcus

    Marcus Well-Known Member

    Addon2 should only be executed if Addon1 does not output content. How could I do that with Template Modification Replace:
    <xen:include template="ad_forum_view_above_thread_list" />
    with execution order 10
    <xen:callback class="Addon1_Callback_ForumView" method="getForumView"
    params="{$forum}" />
    with execution order 20
    <xen:callback class="Addon2_Callback_ForumView" method="getForumView"
    params="{$forum}" />
    How can I do that? Is that possible with hasContent or xen:set?
    Last edited: Sep 13, 2013
  2. Snog

    Snog Well-Known Member

    I know this is not what you want to hear, and it's slightly off topic, but you do realize that by using the Template Modification system your mod won't work with any custom templates that someone might create don't you?

    In this case, IMHO you're better off using a listener and adding your info to the contents of the template. That way so long as any custom template includes the ad_forum_view_above_thread_list template your mod will work with that custom template.
  3. Marcus

    Marcus Well-Known Member

    The $0 takes care the template is still there.

    Does anyone know how to solve that problem? I thought of returning xen:set $addon1output=1 but it will be parsed only after the second addon is executed.
  4. Marcus

    Marcus Well-Known Member

    If this is not possible, a short yes/no statement would be helpful, too :)
  5. Chris D

    Chris D XenForo Developer Staff Member

    Something like this, maybe:

    <xen:set var="$addOn1">
        <xen:callback class="Addon1_Callback_ForumView" method="getForumView" params="{$forum}" />
    {xen:raw $addOn1}
    <xen:if is="{$addOn1}">
        <xen:callback class="Addon2_Callback_ForumView" method="getForumView" params="{$forum}" />
    Marcus likes this.
  6. Marcus

    Marcus Well-Known Member

    That's an amazing idea!! Thanks.
  7. Marcus

    Marcus Well-Known Member

    It works great. Thanks.
    Chris D likes this.

Share This Page