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

XF 2.0 Building pages with widgets - does it need an addon to access variables?

RobParker

Well-known member
#1
If I understand correctly, the notable members page is basically a template with widgets, right?

Is there a code behind the scenes somewhere that passes the variables it needs to it or are they available globally? i.e. to replicate something similar to this would it require a new addon or just a new template?

What I mean is say for this

Code:
<xf:foreach loop="{$resultsData.{$active.member_stat_key}}" key="$userId" value="$data">
                        <li class="block-row block-row--separated">
                            <xf:macro template="member_list_macros" name="item"
                                arg-user="{$data.user}"
                                arg-extraData="{$data.value}"
                                arg-extraDataBig="{{ true }}" />
                        </li>
                    <xf:else />
Are variables like $resultsData and $data.value available to all templates or would this code only work in this specific template?

Hope that question makes sense!
 

Mike

XenForo developer
Staff member
#3
Technically, some of the stuff in the sidenav on that page are widgets, though none of the main content is. There is a widget to display a particular member stat though (see the "most resources" block on the resource overview page).
 

Chris D

XenForo developer
Staff member
#5
Ah no we just made member stats available as widgets because it was pretty much equivalent to some separate code we used to create in some cases for things like the RM and MG index page side nav (Most media items etc.).