• 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

Your right, I see my mistake. That is what I get for ignoring my addon for awhile due to RL stuff.
 
Working now. Is there a way to make the Home tab selected when on the homepage using this method?
 
The home "tab" that is available in stock xenforo is not a real tab. So you won't be able to select it.

You'll have to create a new event listener for navigation_tabs. Then in your callback method, append a new tab and set it's position to "home". Whatever name you give your tab, update the "majorSection" key accordingly.

PHP:
	public static function navigationTabs(array &$extraTabs, $selectedTabId)
	{
		$extraTabs['xportal'] = array(
			'title'         => new XenForo_Phrase('home'),
			'href'          => XenForo_Link::buildPublicLink('full:xportal'),
			'position'      => 'home',
			'linksTemplate' => 'your_tab_links_template_name',
		);
	}
 
Can you tell us what you did and what it accomplished !

Alright, I'll give you the general gist

  1. Upload the geekpoint folder to your library
  2. In your library, look at your config.php and turn your debug mode on by adding
    PHP:
    $config['debug'] = 1;
  3. Still in the library, Create a new folder (I named it CustomIndex)
  4. Create a .php file in the newly created folder (I named it Addon.php)
  5. In Addon.php add the following code...
    PHP:
    <?php
       
       class CustomIndex_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);
           }
       }
       
       ?>
  6. Now, go to your ACP, under the development tab, click code event listeners
  7. Then click Create, then setup the new event listener...
  8. Listen to Event is "init_dependencies"
  9. Execute Callback is CustomIndex_Addon :: initDependencies
 
I've looked arround if this is appliable for [bd] WordPress Proxy addon, but it has no ControllerPublic. Either that or I didn't do it right.
 
I've looked arround if this is appliable for [bd] WordPress Proxy addon, but it has no ControllerPublic. Either that or I didn't do it right.
Had a quick look at the source code. These config settings might work:

- routePrefix: blog
- controllerClass: bdWordPressProxy_Controller
- majorSection: bdWordPressProxy
 
This is what I did for addon [bd] WordPress Proxy addon:

  1. I created a new folder named WpPortal in the library folder
  2. Created a .php file in the newly created folder and named it Addon.php
  3. In Addon.php I added this:
    PHP:
    <?php
    
      class WpPortal_Addon
      {
          public static function initDependencies(XenForo_Dependencies_Abstract $dependencies, array $data)
          {
              if (!$dependencies instanceof XenForo_Dependencies_Public)
              {
                  return;
              }
    
              $config = new Zend_Config(array(
                  'routePrefix'     => 'blog',
                  'controllerClass' => 'bdWordPressProxy_Controller',
                  'majorSection'    => 'bdWordPressProxy'
              ));
    
              GeekPoint_CustomIndex_Helper::setDefaultRoute($config, $data);
          }
      }
    
      ?>
  4. Listen to Event is "init_dependencies"
  5. Execute Callback is WpPortal_Addon :: initDependencies
I saved it. There is something wrong with the addon prolly because I get this error:

Fatal error: Call to a member function register() on a non-object in /var/www/vhosts/path/httpdocs/blog/wp-includes/widgets.php on line 431

which on line 431 is $wp_widget_factory->register($widget_class);
 
There is something wrong with the addon prolly because I get this error:

Fatal error: Call to a member function register() on a non-object in /[...]/blog/wp-includes/widgets.php on line 431
Yes, this is an issue with the Wordpress Proxy addon itself. $wp_widget_factory is a global variable and it's not global'ed inside the addon's controller, so that could be the reason.
 
Thanks for making this script, it's definitely helped in my add-on. My question is that if you have homePageUrl defined in the ACP, you end up with 2 Home tabs. At the moment, I just remove the URL in the field in the ACP but I was wondering if there was a way to get rid of that tab when this using this script in combination with my add-on and do it automatically (basically ignore that field so it ends up not creating the duplicate Home tab).

I did glance through the thread but didn't see something in particular about this, so if I missed it I apologize.
 
You could set homePageUrl to an empty string, in your navigation_tabs listener.
Code:
$options = XenForo_Application::get('options');
$options->homePageUrl = '';


Although doing this doesn't feel right. Because the homePageUrl setting is supposed to take precedence over any other home url. (See: XenForo_Dependencies_Public::_getNavigationContainerParams()).
 
You could set homePageUrl to an empty string, in your navigation_tabs listener.
Code:
$options = XenForo_Application::get('options');
$options->homePageUrl = '';

Although doing this doesn't feel right. Because the homePageUrl setting is supposed to take precedence over any other home url. (See: XenForo_Dependencies_Public::_getNavigationContainerParams()).
Thanks. I knew it was something simple but couldn't figure it out. Simple and I don't get along well. :p
 
I had this installed, and I want to go back to stock xen. I was thinking that if I removed the event listener (which was created in the instructions), & deleted the geekpoint folder through ftp, that things would go back to the original xen setup?? This isn't the case. Can anyone comment on what else needs done to get things back to stock?
 
Alright, I'll give you the general gist

  1. Upload the geekpoint folder to your library
  2. In your library, look at your config.php and turn your debug mode on by adding
    PHP:
    $config['debug'] = 1;
  3. Still in the library, Create a new folder (I named it CustomIndex)
  4. Create a .php file in the newly created folder (I named it Addon.php)
  5. In Addon.php add the following code...
    PHP:
    <?php
      
      class CustomIndex_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);
          }
      }
      
      ?>
  6. Now, go to your ACP, under the development tab, click code event listeners
  7. Then click Create, then setup the new event listener...
  8. Listen to Event is "init_dependencies"
  9. Execute Callback is CustomIndex_Addon :: initDependencies

I did this, but now I'm getting this constantly in ACP's Tools/Server Error Logs:
 

Attachments

  • capture.webp
    capture.webp
    74.1 KB · Views: 12
I must have had a typo someplace. :oops:

I made a new folder in libraries, made a new addon and a new listener. Deleted the old listener and now its working fine.
 
I was just giving this a shot and I keep getting a

Code:
Parse error: syntax error, unexpected T_STRING in Addon.php on line 9

Have I done anything wrong?

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'     => 'pages',

        'controllerClass' => 'XenForo_ControllerPublic_Page',

        'params'          => array('node_name' => 'testhome'),

    });
    
        GeekPoint_CustomIndex_Helper::setDefaultRoute($config, $data);

    }

}

:S thank you
 
Ok ignore the above I used a standard text editor added a whole lotta junk got it working fine. Can someone please elaborate a little further on getting the tab working?

The home "tab" that is available in stock xenforo is not a real tab. So you won't be able to select it.

You'll have to create a new event listener for navigation_tabs. Then in your callback method, append a new tab and set it's position to "home". Whatever name you give your tab, update the "majorSection" key accordingly.

PHP:
 public static function navigationTabs(array &$extraTabs, $selectedTabId)
{
$extraTabs['xportal'] = array(
'title'        => new XenForo_Phrase('home'),
'href'          => XenForo_Link::buildPublicLink('full:xportal'),
'position'      => 'home',
'linksTemplate' => 'your_tab_links_template_name',
);
}
Where exactly do I slot the php in?

And what goes in the : Execute Callback class::Method?

Thank You!
 
Top Bottom