• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

[Library] Set your own Route/Controller as Homepage

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.

I am not entirely sure how to do this part... Is there a specific file I need to edit? Do I create a new php file?

I want to set it up so that XenPorta is the homepage...

I'm a newbie when it comes to XF and php :)

Edit: Alright I read up a bit and did some homework...

I made the event listener, and added the following code...
PHP:
    public static function initDependencies(XenForo_Dependencies_Abstract $dependencies, array $data)
    {
        if (!$dependencies instanceof XenForo_Dependencies_Public)
        {
            return;
        }

        $config = new Zend_Config(array(
            'routePrefix'     => 'portal',
            'controllerClass' => 'EWRporta_ControllerPublic_Portal',
            'majorSection'    => 'portal'
        ));

        GeekPoint_CustomIndex_Helper::setDefaultRoute($config, $data);
    }
to helper.php (not sure if that is where it goes...)

and I get an error...
b1093bb4bf373280d9652d8d17ea000d.png


any and all help is appreciated :)
 
Don't modify any of the library files. Create your own php file: /library/Eruadan/Addon.php (code given below), and then setup a new event listener for the "init_dependencies" event in your Admin Panel, attached to:

Eruadan_Addon :: initDependencies

PHP:
<?php

class Eruadan_Addon
{
	public static function initDependencies(XenForo_Dependencies_Abstract $dependencies, array $data)
	{
		if (!$dependencies instanceof XenForo_Dependencies_Public)
		{
			return;
		}

		$config = new Zend_Config(array(
			'routePrefix'     => 'portal',
			'controllerClass' => 'EWRporta_ControllerPublic_Portal',
			'majorSection'    => 'portal'
		));

		GeekPoint_CustomIndex_Helper::setDefaultRoute($config, $data);
	}
}
 
Does this mean there is no benefit to using this if the forum is installed in /community?
True. Users who have installed xenforo in a subdirectory (say /community/), already have a "free" spot for a homepage one level up (ie /).
 
Hmm, now I'm confused ( :D not hard I know).

I was hoping to use this so I could set /community/pages/home as my "home page" at the domain root and also have the Home tab highlighted.
 
Thanks Shadab, much appreciated.

I may consider moving the forum to the root and trying this anyway.
I was leaving the root free, just in case, to avoid potential conflicts with other software which might have an index.php, which I might install at some point in the future.
 
Related Threads:
Setting a "Page" as your "Home" Page - Is it possible.
In addition to $extraTabs, lets have a $homeTabs
Addon as default page?
Shadab: can you hit people over the head with what your tutorial can do ?
Something like this in the first post ?

This tutorial can enable you to:
Set a Native Xenforo "Pages" Page as a Home Page
- where: www.yoursite.com directs users to a Page you made)
Set an Addon to be your Home (Landing) Page - examples: Wordpress Addon, XenPorta (Portal addon).
- where: www.yoursite.com directs users to your Addons (Wordpress, XenPorta)
 
Don't modify any of the library files. Create your own php file: /library/Eruadan/Addon.php (code given below), and then setup a new event listener for the "init_dependencies" event in your Admin Panel, attached to:

Eruadan_Addon :: initDependencies
I'm sorry, but can you elaborate on this step. I don't see any "listener" setting in Admin Panel... :-(
 
Disregard...
I was unaware of the "debug" mode...
For all others, to add a listener, you must edit the config.php file and add:
$config['debug'] = true;

Then you will have a new menu option in AdminCP called Development.
OK, for those laughing... Hey, I really had no idea... :)

EDIT...
Oh this is AWESOME!
Added my tabs to the NavBar and everything...
I am simply grinning from ear to ear.

THANKS TO EVERYONE!!!!!!!
 
Why do I get the feeling i'm not the sharpest tool in the shed......

When I try to follow the instructions I keep getting the error ""Please enter a valid callback method"

I've created the example Addon.php as suggested above and placed it in the library/Redirect folder

OK, got it all figured out now, wouldn't say I'm sharp, just not as blunt as others now..which is a big step up ;)
 
This is very nice but with Beta 6 I have uploaded the directory and tried adding a code event listener, I get an error when I click submit on the listener of "Invalid callback method".
 
@Cory Booth, @Keith: Glad you figured it out. :)

This is very nice but with Beta 6 I have uploaded the directory and tried adding a code event listener, I get an error when I click submit on the listener of "Invalid callback method".
Make sure you create the static callback function (eg, in /library/Steve/Addon.php)
before you add it in your Admin Panel.
 
Sure thing
PHP:
<?php
class xPortal_homeLink
{
	public static function initDependencies(XenForo_Dependencies_Abstract $dependencies, array $data)
    {
        if (!$dependencies instanceof XenForo_Dependencies_Public)
        {
            return;
        }

        $config = new Zend_Config(array(
            'routePrefix'     => 'xportal',
            'controllerClass' => 'xPortal_ControllerPublic_Index',
            'majorSection'    => 'xportal'
        ));

        GeekPoint_CustomIndex_Helper::setDefaultRoute($config, $data);
    }
}
?>
 
Your class name (xPortal_homeLink) and file name (Listeners.php) don't match.
So the autoloader won't be able to find your callback method.
 
Top Bottom