XF 2.0 Send parameters to add-on by $_GET

Parjam

Member
Imagin I created a page in Xenforo -> Nodes and named it memberBusinessCard.
And made an add-on and named it getBussinessCard. This add-on will give a user_id and send it to another service and give the card info for the member.

This is the add-on callback:
Code:
<xf:callback class="getBussinessCard\getBussinessCard" method="getJsonData" params="[$_GET['user_id']]"></xf:callback>

I need for example If anybody opened page http://forum.com/pages/memberBusinessCard?user_id=15
Then I give the query string by anyway example "$_GET['user_id']" and send it to add-on ad param.

How can I do it?
 
Because I want to have a single page that handles all members card. As I explained example I want to have this page http://forum.com/pages/memberBusinessCard and get data by user id passed in URL query string or another way!
 
You can do that directly in the PHP file, no need to pass the param to the callback. If you use the callback like this:
Code:
<xf:callback class="getBussinessCard\getBussinessCard" method="getJsonData"></xf:callback>
And get the param via $_GET['user_id'] in the getJsonData method directly, it will work just fine.
 
Yes, sure but I made a page in Xenforo forum.com/pages/memberBusinessCard and does not open page when I pass GET query string! How can I create a flexible page in Xenforo that I can pass GET parameters?
 
If you create a custom page via ACP > Forums > Nodes, you can pass parameters like so: forum.com/pages/memberBusinessCard/?user_id=1
Must have a trailing slash before.
 
Please for the love of all that is holy, do not reference $_GET in templates. In fact I believe it is against the XF add-on guidelines to directly touch this.

The correct solution is to implement a controller which can then call $this->filter("name, "type")
 
If you create a custom page via ACP > Forums > Nodes, you can pass parameters like so: forum.com/pages/memberBusinessCard/?user_id=1
Must have a trailing slash before.

Cool dear. done.
I just have a little problem. I can now get back a JSON data and show it in HTML page. But I need to meaning and use these JSON data as variables wherever I need.
example: this is my JSON object:
Code:
{
  profile_score: 15 ,
  profile_simple_text: "This is my simple text"
}

And in my HTML page example show like this:

<h1><?php profile_score ?></h1>
<p><?php echo profile_simple_text ?></p>

How can I do it?
Also, I have a problem with my addon the function I just run a CURL request. Even if I did not echo the result, it will echo the result in output! I mean whole of the result! I do not want that. I maybe want to put it in a variable and separate it into HTML and show it.
 
Top Bottom