1. 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...

Discussion in 'XenForo Development Discussions' started by Jaxel, Oct 6, 2010.

  1. Jaxel

    Jaxel Well-Known Member

    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. Netrosis

    Netrosis New Member

    I've got a similar problem, I've added in the Route Prefix over here:

    http://xenforo/admin.php?route-prefixes/
    but..
    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.
     
  3. Lawrence

    Lawrence Well-Known Member

    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
     
  4. Jaxel

    Jaxel Well-Known Member

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

Share This Page