That would be a pretty big security issue...
On several sites there is more than one person with access to the AdminCp, it is not uncommon to have an administrator and someone with access to the templates to "edit' the style of the site and make small changes.Hi Shawn,
Curious what sort of things could go wrong.
New <xen:callback> tag
While generally we don't recommend running PHP via templates, some times it's significantly simpler than writing a full add-on. Here's an example call:
Code:<xen:callback class="Class_Name_Here" method="getHtml"><b>HTML that will be passed to the callback.</b></xen:callback>
For advanced usage, you can also pass params to the callback via the params attribute (like in template hooks).
To try to limit any untoward usage of this, we place a couple constraints:
I should note that while we've deprecated template hooks, you can actually use this with the new template modification system to effectively create new hooks. That is, if you'd rather work on the final rendered output rather than the template itself.
- Like all of our other callbacks, it must happen to a method within a class. You can't just read out /etc/passwd directly.
- The method that you're calling must start with a limited set of prefixes: get, is, has, render, view, return, print, show, display
not knowing but guessing here...I quoted Mike's explanation about xen:callback, but it's over my head.
Could someone explain how this callback would work. In my post #1 I was suggesting it would be great to be able to call a php file directly from a template. Brogan indicates this has been implemented by this xen:callback but to me it sounds like it's different than what I was asking for.
How would the template call a php file using this xen:callback?
<xen:callback class="Andys_AndyB" method="getHtml"><b>HTML that will be passed to the callback.</b></xen:callback>
<?php
echo 'test';
?>
<xen:callback class="Andy_test" method="getHtml"></xen:callback>
<?php
class AndyB_Test
public static function getTest()
return 'test';
}
}
<?php
class XFP_Test{
public static function getHtml(){
return 'my returned text';
}
}
<xen:callback class="XFP_Test" method="getHtml"></xen:callback>
public static function getHtml($content, $params, XenForo_Template_Abstract $template){
<xen:callback class="XP_Test" method="getHtml" params="{xen:array 'foo=baz'}">content</xen:callback>
<?php
class XP_Test{
public static function getHtml($content, $params, \XenForo_Template_Abstract $template){
$return = '';
$return .= 'passed content : ' . $content ."<br >";
$return .= 'passed params : ' . var_dump($params);
// you can even attach a existing template to the output
$templateParams = array();
$t = $template->create('template', $templateParams);
$return .= $t;
return $return;
}
}
Just did a quick test, which is working fine
My class:
PHP:<?php class XFP_Test{ public static function getHtml(){ return 'my returned text'; } }
template:
Code:<xen:callback class="XFP_Test" method="getHtml"></xen:callback>
I thought you're much smarter, young Padawan
classname => XFP_Test
this means=>
Library\XFP\Test
We use essential cookies to make this site work, and optional cookies to enhance your experience.