• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Creating a page?

bambua

Well-known member
#23
Okay I have done that and its allowed me to save but when I use php within the template it isnt working, or at least it appears it isnt.

All I am using is this:

Code:
<div class="baseHtml messageText">
<?php
require("/home/xxx/public_html/myfile.php");
?>
</div>
Any ideas on how to get it to work? :)
Did you ever get this working? After Brogan's post it sounded like it was possible. Or do we need to use the PHP Callback functionality.
 

Michael

Active member
#24
Unfortunately thats where I gave up and I havent a clue if it should work or not, I did try changing the path to the file so it was just /myfile.php and myfile.php without any luck. Seems like php doesnt work directly within the pages nodes.
 

Anthony Parsons

Well-known member
#26
How do y0u get the menu to show children, without the children also showing on the forum home node list? If you untick "display in node list" on the child page, then you remove it from the main page navigation structure. So how do you build a page structure, ie. FAQ's or such, without each page showing on the home forum?
 

Boothby

Active member
#27
Okay I have done that and its allowed me to save but when I use php within the template it isnt working, or at least it appears it isnt.

All I am using is this:

Code:
<div class="baseHtml messageText">
<?php
require("/home/xxx/public_html/myfile.php");
?>
</div>
Any ideas on how to get it to work? :)
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:
PHP:
<?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
        );
    }
}
That example is quite simple, you can easily assign more variables to the $params-array or include php-files with even more vars. :-D

Edit: Added <?php to the code example.
 

Michael

Active member
#30
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:
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
        );
    }
}
That example is quite simple, you can easily assign more variables to the $params-array or include php-files with even more vars. :-D
Thanks so much for this, I am really looking forward to trying this out :D

Just tried it there, the callback method is apparently incorrect. I get this when saving it:

Please enter a valid callback method.
 

Boothby

Active member
#31
It should work, but I can't exactly remember what I did in what order. So please, create first the php-file Test.php with its content and second save the settings in ACP. And dont forget the <?php at the beginning of the file. I will add that in my post, too.
 

erich37

Well-known member
#36
I would like to create a page very similar to the default one named "Terms and Rules", saying I would like to create a page for the "Imprint".

I want to have this page in the "Help" section, the same as we have for "Terms and Rules".
domain.com/help/imprint


How do I get my "imprint page" into the Footer of the website, just next to the link of "Terms and Rules" ?


Many thanks,
 

Peggy

Well-known member
#37
I would like to create a page very similar to the default one named "Terms and Rules", saying I would like to create a page for the "Imprint".

I want to have this page in the "Help" section, the same as we have for "Terms and Rules".
domain.com/help/imprint


How do I get my "imprint page" into the Footer of the website, just next to the link of "Terms and Rules" ?


Many thanks,
GOOD question. I'll be interested in the answer for this as well.
 

Brogan

XenForo moderator
Staff member
#38
How do I get my "imprint page" into the Footer of the website, just next to the link of "Terms and Rules" ?
Many thanks,
You need to edit the footer template and add your page url to it.

Code:
<div class="footerLegal">
	<div class="pageWidth">
		<div class="pageContent">
			<div id="copyright">{xen:phrase xenforo_copyright}</div>

			<ul id="legal">
				<xen:if is="{$tosUrl}"><li><a href="{$tosUrl}">{xen:phrase terms_and_rules}</a></li></xen:if>
				<xen:if is="{$xenOptions.privacyPolicyUrl}"><li><a href="{$xenOptions.privacyPolicyUrl}">{xen:phrase privacy_policy}</a></li></xen:if>
			</ul>
		</div>
	</div>	
</div>