RM 2.2 Use Resource variables in Widget?

jb-net

Active member
Hi,

while I'm able to use thread variables like title, tags, ... in my own widget in the sidebar (of a thread view) using something like e.g. $context.thread.tags -> which is great because I can do a lot of useful things with these variables in the sidebar including using it as a widget display condition.

However, I wasn't able to do the same with resources yet. I tried using {{ dump($resource) }} or {{ dump($context) }} but it doesn't give me any results in in the sidebar (of a resource view).

Am I doing something wrong? How I'm getting this to work? Thanks!
 
Using {{ dump(vars()) }} in a widget on a resource view page I get:

^ array:5 [▼
"xf" => array:34 [▶]
"title" => "Test"
"widget" => array:4 [▶]
"context" => []
"options" => array:3 [▶]
]
But sadly nothing useful like I get on a thread view page where information like thread title, tags, custom fields are all accessible - wich is great! Is there a way to get this kind of $context data also on a resource view? Thanks!
 
Hi, thanks, that would be great and exactly what I'm looking for (y)

Sadly, it doesn't seem to work:

1. I added in the template xfrm_resource_view

Code:
<xf:page option="resource_tags">{$resource.tags}</xf:page>
<xf:page option="resource_title">{$resource.title}</xf:page>
<xf:page option="resource_rating">{$resource.rating_avg}</xf:page>
<xf:page option="resource_features">{$resource.custom_fields.myname}</xf:page>

2. I added to the widget on the resource view page:

Code:
{$resource_tags}
{$resource_title}
{$resource_rating}
{$resource_features}

But the widget stays empty and doesn't display any values.
 
How are you displaying the widget on the resource view page?

There isn't a position for that so are you manually adding the widget by editing the template?
 
How are you displaying the widget on the resource view page?

There isn't a position for that so are you manually adding the widget by editing the template?

Yess, exactly. I made a template modifcation for xfrm_resource_wrapper and added:

Code:
<xf:widget key="test_widget" position="sidebar" />
 
It's likely a limitation of the widget system.

You may need to consider using the ad templates system and calling the vars using $__globals.resource_title.
 
Top Bottom