MyBB Community Forums

Full Version: Make your own hooks?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a plugin file the uses a template. It takes a conditional variable from $_GET. How would I pass that to my template? in place of {$page} or something Smile
I don't really understand the question.

The title is a bit misleading as you don't mention hooks in your message.
(2011-01-07, 08:44 PM)Tom K. Wrote: [ -> ]I have a plugin file the uses a template. It takes a conditional variable from $_GET. How would I pass that to my template? in place of {$page} or something Smile

I'm assuming you mean this:
$_GET['something'] = 'someval'

You want $_GET['something'] used inside your template?

If this is a custom template you can add:
$mybb->input['something']
anywhere in the template ($mybb->input is automatically filled with the values of $_POST and $_GET)

Or you can use your normal control structures (if(), while(), etc...) on the input to do whatever you need do.
The built-in $_GET function is used to collect values from a form sent with method="get".

Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send.

For more info: http://www.w3schools.com/PHP/php_get.asp
I know how to use get..... I just didnt know how to parse it in mybb
(2011-01-08, 07:53 AM)Tom K. Wrote: [ -> ]I know how to use get..... I just didnt know how to parse it in mybb

Are you still having issues, or did my post get you what you needed?
(2011-01-08, 02:10 PM)Dylan M. Wrote: [ -> ]
(2011-01-08, 07:53 AM)Tom K. Wrote: [ -> ]I know how to use get..... I just didnt know how to parse it in mybb

Are you still having issues, or did my post get you what you needed?

Havent tried it yet, i was answering yaldaram's post explaining what $_GET actually was Toungue
Never ever print the content of $_GET (or some other user-input) direct on your page!

Without a filter everyone is able to insert html/js-code which results in a XSS (cross site scripting) possibility.

-> everyone is able to steal sessions, passwords, everything without being an admin Wink
I know Wink
is there any way i can get the TID of the page the user has just come from? I have modified the class_parser to add $_GET['tid'] onto the the end of the url.

EG:
$link = "<a href=\"".$linkfile."?url=".$fullurl."&post=".$_GET['tid']."\" target=\"_blank\">".$name."</a>";

With $linkfile being the link handler file for my plugin, and $fullurl being the url the user wants to visit.

Thanks
(2011-01-08, 06:06 PM)thebod Wrote: [ -> ]Never ever print the content of $_GET (or some other user-input) direct on your page!

Without a filter everyone is able to insert html/js-code which results in a XSS (cross site scripting) possibility.

-> everyone is able to steal sessions, passwords, everything without being an admin Wink

No one suggested printing it direct. All user input should always be sanitized.