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

Insert basic page info instead of main content?

Neil E.

Active member
#1
I'd like to add some really simple page information triggered by new buttons on the NavBar.
The buttons are easy thanks to Jake. http://xenforo.com/community/threads/how-to-add-a-new-tab-in-the-navbar.7781/

I want all the main content (including the top and bottom breadboxes) to be replaced with some sort of table (or object filled with text). The QuickSearch box would remain. Suggestions? I certainly don't want to tackle anything like Xenporta or Wordpress etc. I'm thinking along the lines of a new template that replaces the normal main content. Some form of hard coding would be OK.
 

Neil E.

Active member
#3
OK, I looked at the other topic, but I don't get it.

Create new file on the server, no problem.
library/Callback/PageNode.php
<?php

class Callback_PageNode
{
public static function noContainer(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)
{
$response->containerParams['containerTemplate'] = 'mycontainer';

$response->templateName = 'mycontent';
}
}

new template for 'mycontainer', should be possible
{xen:raw $contents}

new template for 'mycontent', should be possible
{xen:raw $templateHtml}

handle the callback, no clue here, looks like maybe I have to create a new page to have somewhere to put the callback, and the new page has to exist in the node tree (was looking for something simpler)
Callback_PageNode::noContainer

Any other methods? Leaving the breadcrumbs in place would be OK.
 

Jake Bunce

XenForo moderator
Staff member
#4
The callback is defined when adding or editing a page node in the Admin CP. You can hide the page from the node tree if you want. That's another option when adding / editing a page node.
 

Neil E.

Active member
#7
Very useful, thanks Jake. I want to learn more about callbacks.
Is there a list somewhere of the various callback methods and what they do?
 

Neil E.

Active member
#9
I decided that including a file would do what I need. This keeps the page looking the same to users (main content becomes some html).

library/Callback/WelcomePage.php (new file)
<?php
class Callback_WelcomePage
{
public static function includeFile(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)
{
ob_start();
require('/welcomeXF.html');
$myContent = ob_get_contents();
ob_end_clean();

$params = array(
'myContent' => $myContent
);

$response->params = array_merge(
$response->params,
$params
);
}
}

Create New Page details
URL Portion: welcomeXF
Title: Welcome Page
Description: <div class="baseHtml messageText">
{xen:raw $myContent}
</div>
PHP Callback: Callback_WelcomePage::includeFile

Location of html file
www.odsc.on.ca/.xenforo/welcomeXF.html

Location of php file
www.odsc.on.ca/.xenforo/library/Callback/WelcomePage

Location of new page (will be the link in added extra NavBar Tab called "Welcome")
<a data-description="#nodeDescription-" href="index.php?pages/welcomeXF/">Welcome Page</a>

Error when I try to open the new page
Fatal error: Callback_WelcomePage::includeFile() [function.require]: Failed opening required '/welcomeXF.html' (include_path='/home/odsc/public_html/.xenforo/library:.:.:/usr/lib/php:/usr/local/lib/php') in /home/odsc/public_html/.xenforo/library/Callback/WelcomePage.php on line 7
Any idea what I'm doing wrong?
 

Jake Bunce

XenForo moderator
Staff member
#10
Use a full server path.

Visit admin.php?tools/phpinfo and search the page for "DOCUMENT_ROOT". That will reveal the full server path.
 

Neil E.

Active member
#11
Well I was unable to find "phpinfo" in admin.php?tools/, but I did eventually get the server path correct. The callback is functioning as desired.

I would like to know how to get the name of the new page inserted into the breadcrumb.
 

Jake Bunce

XenForo moderator
Staff member
#12
The first breadcrumb will always be Home, but only if you have a home URL defined:

Admin CP -> Home -> Options -> Basic Board Information -> Home Page URL

The second breadcrumb will always be the name of the selected navigation tab. If you want to change the tab of the page node (create new or assign to existing) then you can use this addon:

http://xenforo.com/community/resources/nodes-as-tabs.9/