Invision Community 4: SEO, prepare for v5 and dormant account notifications Matt November 11, 2024Nov 11
Posted October 25, 20186 yr The variable documentation seems a little lacklustre, and I can't seem to find any reference to how these variables are actually passed to the templates. For example if I wanted to pass a variable i called $balance to a particular template file, how would i do so? I know that I can add it to the list of variables in the tempalte editor, but where do those variables actually get sent from?
October 25, 20186 yr It's lackluster from your perspective because it's not written for your purpose. It's about using variables already there, not adding new ones. You'd have to hook into the back end PHP code to alter the data before it is sent to the template. WHAT template you're trying to modify data for, and what variable you're wanting to modify would be necessary to point you WHERE in the PHP back end you'd have to hook into to add in your data.
October 25, 20186 yr Author So how would I hook a variable to a particular template in a theme? For example what if I want to add my own variable to my own template theme? Or add a variable from the "points" application that currently isn't in the available variables for a particular template file?
October 25, 20186 yr If the data you're adding is related to other content in the template, you can append the data to an existing variable, if possible.
October 25, 20186 yr So, say you have your own template, your own PHP code, etc. Your variable is called $points. \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'plugins', 'core', 'global' )->myTemplate( $points ); (This is in the context of a plugin for a template file called myTemplate) <ips:template parameters="$points" /> <!-- Then in the template you can use the variable --> Attempting to add a variable to an existing template is a bit more challenging and will depend upon the template, the backend code and other factors. You haven't provided a specific case you are attempting to adjust though, so I can't provide more guidance.
Archived
This topic is now archived and is closed to further replies.