Shadab
Well-known member
Just a quick addon/library I put together for shifting the forum listing to /forum/ and setting the homepage to be handled by your controller's index action.
These instructions are for the next release of XenForo (Beta 6), which will hopefully require no patch for this to work. Patches for Beta 5 will be posted shortly in the second post below.
Installation
Usage/API
There's only one static method which you need to call. The first argument (type: Zend_Config) is the configuration data you need to pass; and the second argument (type: array) is the dependency data supplied by init_dependencies.
Configuration
routePrefix
controllerClass
majorSection
minorSection
params
Examples
Create a new event-listener for init_dependencies. Then in your callback method, just set the configuration options, and call the helper. That's it. Some examples are given below, starting with the code for setting "Recent Activity" as your homepage...
@Jaxel:
Configuration for setting the portal page as homepage...
(No other changes required.)
@Brogan:
Configuration for setting a node page as the homepage.
(Replace "lectus-pretium-consequat" with your node name. Any changes that you make to the page name via Admin Panel need to be reflected in this config array.)
License
Related Threads
Installation
- Download the attached zip file.
- Extract and upload the contents inside your /library/ directory.
- There's no step 3.
Usage/API
There's only one static method which you need to call. The first argument (type: Zend_Config) is the configuration data you need to pass; and the second argument (type: array) is the dependency data supplied by init_dependencies.
GeekPoint_CustomIndex_Helper::setDefaultRoute($config, $data);
Configuration
routePrefix
This is the route prefix which you want to set as the default. Suppose you set the "foo" route-prefix as default, any links generated for "foo" or "foo/index" will now point to the homepage "/".
controllerClass
This is the controller class which will handle the homepage. Specifically, the actionIndex() method in your controller will be responsible for generating the homepage.
majorSection
[Optional] The major section-name, used when generating the route-match for homepage.
minorSection
[Optional] The minor section-name, used when generating the route-match for homepage.
params
[Optional] Parameters that will be added to the request object during the routing process. This enables you to set any content which depends upon a request parameter to be present, as your homepage. For example: node "Pages", or Threads (yes, threads! But for heaven's sake don't do that.)
Examples
Create a new event-listener for init_dependencies. Then in your callback method, just set the configuration options, and call the helper. That's it. Some examples are given below, starting with the code for setting "Recent Activity" as your homepage...
PHP:
public static function initDependencies(XenForo_Dependencies_Abstract $dependencies, array $data)
{
if (!$dependencies instanceof XenForo_Dependencies_Public)
{
return;
}
$config = new Zend_Config(array(
'routePrefix' => 'recent-activity',
'controllerClass' => 'XenForo_ControllerPublic_RecentActivity',
));
GeekPoint_CustomIndex_Helper::setDefaultRoute($config, $data);
}
@Jaxel:
Configuration for setting the portal page as homepage...
(No other changes required.)
PHP:
$config = new Zend_Config(array(
'routePrefix' => 'portal',
'controllerClass' => 'EWRporta_ControllerPublic_Portal',
'majorSection' => 'portal'
));
@Brogan:
Configuration for setting a node page as the homepage.
(Replace "lectus-pretium-consequat" with your node name. Any changes that you make to the page name via Admin Panel need to be reflected in this config array.)
PHP:
$config = new Zend_Config(array(
'routePrefix' => 'pages',
'controllerClass' => 'XenForo_ControllerPublic_Page',
'params' => array('node_name' => 'lectus-pretium-consequat'),
));
License
Since this addon(?) is released under the MIT License, you are free to include and use this in your own addons & products. It would be nice if you leave the directory structure & the files included therein, unmodified; but it's not a requirement.
The complete license text is available in the LICENSE file inside the release package.
Related Threads