SpecialK
Well-known member
I need to generate a new dropdown menu item in post_macros. This dropdown is generated on the fly based on some XF options. It would be very easy to generate this dropdown right in the template without going down into a template render listener.
Problem is, I don't want to regenerate this dropdown HTML each time post_macro is invoked. So I had the bright idea to save the variable once, in thread_view, and then post_macros would be able to access it. But it's not working. What am I doing wrong? Shouldn't this work?
In template thread_view:
In template posts_macro:
I know the $posts_repo_dropdown is getting set successfully, because I can echo it in thread_view and it shows up fine. I thought vars defined in parent templates were passed to child templates automatically?
Problem is, I don't want to regenerate this dropdown HTML each time post_macro is invoked. So I had the bright idea to save the variable once, in thread_view, and then post_macros would be able to access it. But it's not working. What am I doing wrong? Shouldn't this work?
In template thread_view:
Code:
<xf:if is="{{ $xf.visitor.isMemberOf($xf.options.td_posts_repository_groups) }}">
<xf:set var="$posts_repo_dropdown" value="TESTING" />
</xf:if>
In template posts_macro:
Code:
<xf:if is="{{ $xf.visitor.isMemberOf($xf.options.td_posts_repository_groups) }}">
<a class="actionBar-action menuTrigger"
data-xf-click="menu"
title="Submit to Posts Repository"
role="button"
tabindex="0"
aria-expanded="false"
aria-haspopup="true">Posts Repository</a>
<div class="menu" data-menu="menu" aria-hidden="true">
<div class="menu-content">
<h3 class="menu-header">Submit to Posts Repository</h3>
{{ $posts_repo_dropdown }}
<a class="menu-linkRow" role="button" tabindex="0" data-menu-closer="on" data-xf-init="copy-to-clipboard" data-copy-text="{$bookmark.content_link}">{{ phrase('copy_link') }}</a>
<a href="{$bookmark.edit_link}" class="menu-linkRow" data-xf-click="overlay">{{ phrase('edit') }}</a>
<a href="{$bookmark.delete_link}" class="menu-linkRow" data-xf-click="overlay">{{ phrase('delete') }}</a>
</div>
</div>
<xf:set var="$hasActionBarMenu" value="{{ true }}" />
</xf:if>
I know the $posts_repo_dropdown is getting set successfully, because I can echo it in thread_view and it shows up fine. I thought vars defined in parent templates were passed to child templates automatically?