Stuck trying to access "session" and "thread" arrays

HeadHodge

Active member
Hi,

I'm in the "search_results" template and I inserted the following in it:
{xen:helper dump, $results.0}

The partial dump I get is:
object(XenForo_Template_Public)#98 (3) {
["_templateName" protected] => string(20) "search_result_thread"
["_params" protected] => array(22) {
["session"] => array(19) {
["sessionStart"] => int(1403139873)
["ip"] => string(4) "K0�"
["sessionCsrf"] => string(16) "T29jUa0qCoARM9ZD"
["user_id"] => int(692)
(end of snippet)

and further down in the dump I get:

["thread"] => array(78) {
["thread_id"] => int(2796)
["node_id"] => int(71)
["title"] => string(16) "Vanuatu Powdered"
["reply_count"] => int(2)
["view_count"] => int(24)
["user_id"] => int(845)
["username"] => string(11) "Grant Moore"
["post_date"] => int(1403131671)
["sticky"] => int(0)
(end of snippet)

I'm trying to access those two arrays ("session" and "thread"), they all the info I'm looking for and need.

But I just can't figure the correct syntax to access them. I keep getting an error something like: "Template Public is an object and not an array"

Please help and provide an example of how to access these two arrays.

Thanks in advance for your Help!!!!

 
Last edited:
{xen:helper dump, $session.sessionStart}

Etc.
Thanks, but that didn't work. I did get a value using your example, but when I try {xen:helper dump, $thread.title} it returns NULL. It should return "Vanuatu Powdered".

Just to make sure you understand $results is an array of 20. What I'm trying to do is get the [thread] array from results.0 (which is the first element of the results array as shown in my previous post).

I want to be able to iterate through the $results array and get all 20 $thread.title values.
 
To make my question simpler.... Does anyone know how I can access the _params array in the example above? If I can access that array, I probably could then get everything I need.

I've tried {$results.0->_params} and {$results.0->$_params} and {$_params}, with no luck.

Next to _params above it says "protected". Does that mean it's read-only or does it mean I'm not able to access it?

Thanks in advance for anyone who can answer this.
 
You posted this in the wrong forum. This is the styling forum is explains why most people who would view this, wouldn't know what you're talking about.

With that said, exactly why are you trying to extend that code? What is the end result you're hoping to achieve?
 
I use the standard search engine that comes with Xenforo. And I want to modify the results template (search_results) to show some extra fields that are not shown in the results list output. The information I want appears to be there (as shown above). Just can't figure out how to access it (nor know if I'm even able to).

I'll be glad to give you any info you need to help me out. Thanks!!!
 
In the search_results template, the $results array is a collection of template objects. As it is an object (and not an array) it isn't possible using normal template syntax to access those params.

However, remember $result is a template object so...

upload_2014-6-20_8-38-52.webp

The solution is simple.

Use a template modification on the search_result_thread template. That has access to the params directly, so you should be able to easily add anything that is in the thread record.
 
.....In the search_results template, the $results array is a collection of template objects. As it is an object (and not an array) it isn't possible using normal template syntax to access those params.

However, remember $result is a template object so........
@Chris D THANK YOU SO MUCH!!!!

That's is "exactly" what I needed!!! I can now access "everything" I need and modify the search results list. (y)(y)(y)

I was pretty sure the answer was there and not real difficult, but I'm new to using <xen:xxx> syntax commands and even though I feel I'm a fair coder, at the moment, I'm feeling like a total Moron with this stuff (and probably sound like one too :) ). If there is anything you could recommend that I could read up on that would help me understand some of these basic concepts (i.e. syntax, standard helpers, Objects, Templates, PHP Callbacks, architecture, etc.) I would be most appreciative.

Thanks again for helping me out Chris.
 
Top Bottom