XF 2.2 Access args in a child Macro?

Dannymh

Active member
I am building some macros that will sit in various areas. For instance in the thread_view we have the post_macros. I am using a template modification to add a macro into the post_macros which works, However I also have an extension on the thread controller where I add some params that I pass as an argument to the thread_view.

However as the post_macros by default don't take in these params as arguments, I would have to do more extensions to pass that information into the post_macros which adds the arguments into say post.

Is there a way to have my macro which sits inside post_macros take on the arguments that are passed into the thread_view

Structurally in looks like this
<thread_view>
<macro name="mymacro" arg-threads="{$threads" arg-myarg="{$myargarray}>

that works fine however if I then include it in
<thread_view>
<macro name="post_macros">
<macro name="mymacro" arg-threads="{$threads" arg-myarg="{$myargarray}>

then $myarray wont have any values as it wasn't passed to post_macros

I looked at the macro extensions but could'nt see how this would work either. Basically I want to pass the parameters down from my extended thread controller to anywhere in the thread_view including inside macros in that view.

Is this possible?

The only other work around, which will require a bit of a re-write at this stage is to possible add these variables as getters in the thread entity which may also work.

Thanks for any help you can offer
 
I kind of hoped making these into includes because really thats what they are would have worked, however because the include position is "post_macros" it appears this include won't grab the parent thread_view params because they aren't available in the post_macros. Looks like I may have to go deeper and extend either post_macros to include them or make them available in the $thread param

does anyone have guidance on the best way to do this?
 
I ended up using a getter to do this, and that has worked for now. Because $thread is parse into the macro, I extended the thread entity and added a getter "extras" and return an array of the properties I need into that getter
 
Back
Top Bottom