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

Creating a "Hello World!" page...

Jaxel

Well-known member
#1
As a start of trying to figure this whole XenForo thing out... I'm just trying to make a simple "Hello World!" page. It looks pretty simple, but I know I can't figure it out... I've tried to figure it out using other people's mods, but I dont know what I'm missing.

I have a mod called "EWRporta". It works fine so far, and I have succesfully created a navtab link to it using the advice given on this thread here. The link goes to /forums/portal

The next thing I did was create a "Route" prefix.

Route Prefix: EWRporta
Route Class: EWRporta_Route_Prefix_Index
I think the route prefix should be "portal", not "EWRporta". But if I change it to "portal", it will disappear from the list of route prefixes because it does not match any existing addon ids.

File: /library/EWRporta/Route/Prefix/Index.php
Code:
<?php

class EWRporta_Route_Prefix_Index implements XenForo_Route_Interface
{
	public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
	{
		return $router->getRouteMatch('EWRporta_ControllerPublic_Index', $routePath, 'EWRporta');
	}
}
The next thing I did was make the public controller for index that links to a template

File: /library/EWRporta/ControllerPublic/Index.php
Code:
<?php

class EWRporta_ControllerPublic_Index extends XenForo_ControllerPublic_Abstract
{
	public function actionIndex()
	{
		$viewParams = array();

		return $this->responseView('EWRporta_ViewPublic_Index', 'EWRporta_Index', $viewParams);
	}
}
Template: EWRporta_Index
Code:
Hello World!
I thought this was all that would be required... but unfortunately I cant get it working. I instead get an error:
Code:
Error
The controller does not define an action called .
 
#2
I've got a similar problem, I've added in the Route Prefix over here:

http://xenforo/admin.php?route-prefixes/
but..
An exception occurred: Argument 1 passed to XenForo_Controller::__construct() must be an instance of Zend_Controller_Request_Http, none given, called in C:\WEMP\www\xenforo\library\XenForo\Route\Prefix.php on line 85 and defined in C:\WEMP\www\xenforo\library\XenForo\Controller.php on line 81
XenForo_Application::handlePhpError() in XenForo/Controller.php at line 81
XenForo_Controller->__construct() in XenForo/Route/Prefix.php at line 85
XenForo_Route_Prefix->_loadAndRunSubRule() in XenForo/Route/Prefix.php at line 66
XenForo_Route_Prefix->match() in XenForo/Router.php at line 61
XenForo_Router->match() in XenForo/Dependencies/Public.php at line 93
XenForo_Dependencies_Public->route() in XenForo/FrontController.php at line 254
XenForo_FrontController->route() in XenForo/FrontController.php at line 128
XenForo_FrontController->run() in C:/WEMP/www/xenforo/index.php at line 15
I got a Hello World page working when it was inside the XenForo ControllerPublic directory and added, but anything outside seems to be not resolving the Route Prefix class correctly, and therefore not pushing the right arguments to the class.

I also followed your steps, then added in the route prefix for your addon (same names, etc.) and still got the above error.
 

Lawrence

Well-known member
#3
Jaxel, are you trying to access your "Hello World" page from this Tab you created:

Code:
<?php

class 8wrXenPorta_Listeners
{
	public static function navtabs(array &$extraTabs, $selectedTabId)
	{
		$extraTabs['8wrXenPorta'] = array(
			'title' => 'XenPorta',
			'href' => 'XenPorta',
			'selected' => ($selectedTabId == '8wrXenPorta'),
			'linksTemplate' => '',
		);
	}
}

Your href is set to XenPorta, but your directory is called EWRporta
 

Jaxel

Well-known member
#4
No, I figured it out... Lawrence, I didn't use that code... its different code. The code you have listed was an earlier attempt.