You need to edit the help_index template for that.thanks Brogan, but how do you get a new page under the "Help"-tree ?
As you might expect that will not work.
Ok, into the the Template HTML-field you write:
HTML:<div class="baseHtml messageText"> {xen:raw $myContent} </div>
You have to set a PHP callback class and method
class-name: XenForo_Pages_Test
method-name: includeFile
When naming the class you should keep the xenforo folder structure in mind.
Now you have to create a php-file <xenforo>/library/XenForo/Pages/Test.php. The sub-folder Pages does not exists by default, so you have to create it first. The file/path and the clase-name must match or you will end up in an error.
The php-file content:
That example is quite simple, you can easily assign more variables to the $params-array or include php-files with even more vars. :-DPHP:<?php class XenForo_Pages_Test { public static function includeFile(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response) { ob_start(); require('/path/to/your/html/file.html'); $myContent = ob_get_contents(); ob_end_clean(); $params = array( 'myContent' => $myContent ); $response->params = array_merge( $response->params, $params ); } }
Edit: Added <?php to the code example.
<?php
class XenForo_Pages_PickupLines
{
public static function includeFile(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)
{
ob_start();
require('/home/xarcell/public_html/inspireromance.com/page-pickup-lines.php');
$pickupLines = ob_get_contents();
ob_end_clean();
$params = array(
'pickupLines' => $pickupLines
);
$response->params = array_merge(
$response->params,
$params
);
}
}
<div class="baseHtml messageText">
{xen:raw $pickupLines}
</div>
<?php
echo '<div>hello world</div>';
?>
Now I have another problem. I am unable to apply any classes or add CSS to the php file. What is the proper way of doing that?
<?php
echo '<div class="secondaryContent">hello world</div>';
?>
<form method="post" name="_xfToken" value="{$visitor.csrf_token_page}">
<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
It should be
and doesn't care where you place it, it just have to be in the formCode:<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
for example before the closing tag
<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
</form>
Here's what I did...
Created PickupLines.php and uploaded to library/Xenforo/Pages with the following content:
PHP:<?php class XenForo_Pages_PickupLines { public static function includeFile(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response) { ob_start(); include('/home/xarcell/public_html/inspireromance.com/page-pickup-lines.php'); $pickupLines = ob_get_contents(); ob_end_clean(); $params = array( 'pickupLines' => $pickupLines ); $response->params = array_merge( $response->params, $params ); } }
Then I created a forum page with this as the HTML:
Callback: "XenForo_Pages_PickupLines :: includeFile"Code:<div class="baseHtml messageText"> {xen:raw $pickupLines} </div>
My php file that I'm trying to include contains this:
Code:<?php echo '<div>hello world</div>'; ?>
Yes, i'd like to do the same, include it into templates but adding {xen:raw $pickupLines} is not working. Please help.So what if I want to include $pickupLines in an other template? How would I approach this? simply placing: {xen:raw $pickupLines} somewhere doesnt seem to do the trick....
NVM, I got it. I changed require to include, and made sure my path was correct.
We use essential cookies to make this site work, and optional cookies to enhance your experience.