Resource icon

Route Changer 1.1.3

No permission to download
Hey man, I am having a problem, if I change the index to forums, I can access the forum index like domain.com/forums/ but can't access the thread listing which is domain.com/forums/myforum.2/ its being redirected to domain.com/forums/
 
Is it possible to make this work with routes that have a "/" in them?

AddonChat provides a page at domain.com/AddonChat/Embed, would like to make it /chat

Here's the relevant Navigation.php code highlighted in red; I tried changing $href = XenForo_Link::buildPublicLink('AddonChat/Embed'); manually, but that didn't seem to work:
PHP:
<?php
/**
* AddonChat Navigation Class -
*
* @category  AddonChat
* @package    AddonChat_Public_Navigation
* @copyright  Copyright (c) <COPYRIGHT>
* @license    <LICENSE REFERENCE>
* @version    $Id:  Navigation.php 2011.12.30.1432$
*/
class AddonChat_Public_Navigation {
  public static function navtab(array &$extraTabs, $selectedTabId) {
      $optionsModel = XenForo_Model::create('AddonChat_Model_Options');
      $options = $optionsModel->getAddonChatOptions();
 
      $visitor = XenForo_Visitor::getInstance();
      if( !$optionsModel->isValidAccount() ) {
        return;
      } 
      //if AddonChat is enabled and the tab is enabled then display tab 
      if( $optionsModel->isChatEnabled() && $optionsModel->isChatTabEnabled() ) {         
        $title = new XenForo_Phrase('AddonChat_Tab');         
        $title = $title . " " . $optionsModel->getUserCount();
                               
        // If embedded chat is enabled then allow for a tab click to launch
        // the embedded chat; otherwise, disabled clicking of the tab directly
        // and allow for the possibility of clicking a sub-item for the popup
        // chat (handled in the template).
        $href = "";   
        if( $optionsModel->isEmbeddedChatEnabled() ) {
[COLOR=#ff0000]            $href =  XenForo_Link::buildPublicLink('AddonChat/Embed'); [/COLOR]               
        }
                     
        $extraTabs['AddonChat'] = array(
            'title'        => $title,
            'href'          => $href,
            'selected'      => ($selectedTabId == 'AddonChat'),
            'linksTemplate' => 'AddonChat_Tab_Links',
            'options'      => $options
        );
      }
  }
 
}

Here's AddonChat's full plugin:
http://www.addoninteractive.net/index.php?/topic/4615-xenforo-1x-add-on-official/
 
Hey man, I am having a problem, if I change the index to forums, I can access the forum index like domain.com/forums/ but can't access the thread listing which is domain.com/forums/myforum.2/ its being redirected to domain.com/forums/

That's because you are renaming index to a route that already exists, thereby overwriting that existing route. "forums" already exists.

You can make it work by renaming both routes. For example:

index -> forums
forums -> view

Now the thread listing will use "view" so that the index can use "forums".
 
Is it possible to make this work with routes that have a "/" in them?

AddonChat provides a page at domain.com/AddonChat/Embed, would like to make it /chat

Here's the relevant Navigation.php code highlighted in red; I tried changing $href = XenForo_Link::buildPublicLink('AddonChat/Embed'); manually, but that didn't seem to work:

You should be able to change "AddonChat" with this addon, but not "Embed". The route is the first part only.
 
You should be able to change "AddonChat" with this addon, but not "Embed". The route is the first part only.

Yeah, I was able to change AddonChat to chat, but chat/Embed just looks awkward to me.

It's probably something I need to dig through the chat addon code for, maybe I can come up with an alternative.

Thanks man!
 
This add-on is great. But I do want to know if we can replace a route with nothing. XenPorta uses this route for categories:

domain.com/articles/category

Is this somehow possible to change it to:

domain.com/category

?
 
I think I have found a bug with this add-on. When you change your index page to forum (index -> forum), links of categories are ignored.

Example:

Original Link: domain.com/#category.3

Link after changed index to forum: domain.com/#category.3

But the link should be this: domain.com/forum/#category.3

XenPorta doesn't have this bug if you set your forum to /forum, so the issue must be in this add-on. Can you fix this please in the next release? :)
 
This add-on is great. But I do want to know if we can replace a route with nothing. XenPorta uses this route for categories:

domain.com/articles/category

Is this somehow possible to change it to:

domain.com/category

?

This addon will only change the route which is the first part (articles). It won't change the second part (category).
 
This add-on is great. But I do want to know if we can replace a route with nothing. XenPorta uses this route for categories:

domain.com/articles/category

Is this somehow possible to change it to:

domain.com/category

?
no... because in domain.com/articles/category, 'articles' is the route and 'category' is an action

and you can't change an action to a route... all you can do is redirect domain.com/articles/category to domain.com/category
and of-course you have to manually create a route named 'category' ;)
 
I think I have found a bug with this add-on. When you change your index page to forum (index -> forum), links of categories are ignored.

Example:

Original Link: domain.com/#category.3

Link after changed index to forum: domain.com/#category.3

But the link should be this: domain.com/forum/#category.3

XenPorta doesn't have this bug if you set your forum to /forum, so the issue must be in this add-on. Can you fix this please in the next release? :)

Confirmed. Thank you for the report.

The category links are a special consideration when changing the index. XenPorta has code to check this. I will add a similar check in the next update.
 
no... because in domain.com/articles/category, 'articles' is the route and 'category' is an action

and you can't change an action to a route... all you can do is redirect domain.com/articles/category to domain.com/category
and of-course you have to manually create a route named 'category' ;)
Can you please tell me how to do that? I tried a htaccess rewriting rule,but it didn't work.
 
Can you please tell me how to do that? I tried a htaccess rewriting rule,but it didn't work.
using a .htaccess file wont do the trick because the links are already dynamic: created by the only index.php in the root directory...

you have to create a custom add-on
add the route-prefix class and 'link' it to a template... you'll be needing basic php skills for that...
 
After looking at our Google Analytics, this appears to be causing duplicate content.

Our setup:
index > forums
forums > section
portal > index


/index.php does not redirect to /
/forums/index.php does not redirect to /forums/

I noticed this when I was seeing traffic to / and also /index.php


In XF's case /community/index.php would not redirect to /community/
 
In XF's case /community/index.php would not redirect to /community/

It should if you have friendly URLs enabled:

Admin CP -> Home -> Options -> Search Engine Optimisation -> Use Full Friendly URLs

(as well as the .htaccess file being in place)
 
It should if you have friendly URLs enabled:

Admin CP -> Home -> Options -> Search Engine Optimisation -> Use Full Friendly URLs

(as well as the .htaccess file being in place)
I do have that enabled. (y)

After some more digging, it appears to be a conflict between XenPorta and this mod. If I disable either mod it redirects as it should. Any suggestions?

BTW I do have the "Set as Index Controller" option unchecked.
 
I do have that enabled. (y)

After some more digging, it appears to be a conflict between XenPorta and this mod. If I disable either mod it redirects as it should. Any suggestions?

BTW I do have the "Set as Index Controller" option unchecked.

Not quite a bug. It's the expected behavior given that XenPorta does not canonicalize the request in its controller.

Here is a quick fix:

library/EWRporta/ControllerPublic/Portal.php

Add the red code:

Rich (BB code):
	public function actionIndex()
	{
		$this->canonicalizeRequestUrl(
			XenForo_Link::buildPublicLink('portal')
		);

		$layoutId = $this->_input->filterSingle('layout_id', XenForo_Input::STRING);
		$layoutId = $layoutId ? $layoutId : 'portal';

		$options = XenForo_Application::get('options');

		if ($options->EWRporta_stylechoice['force'] && $options->EWRporta_stylechoice['style'])
		{
			$this->setViewStateChange('styleId', $options->EWRporta_stylechoice['style']);
		}

		$viewParams = array(
			'cookie' => $layoutId == 'portal' ? $this->perms['custom'] : false,
			'layout1' => $layoutId,
			'page' => max(1, $this->_input->filterSingle('page', XenForo_Input::UINT)),
		);

		return $this->responseView('EWRporta_ViewPublic_Portal', 'EWRporta_Portal', $viewParams);
	}

This is what enables automatic redirects with the route changer, otherwise you will have two equally valid URLs for the same page with no automatic redirect. Redirects are handled automatically by XF for all important routes including the index, forums, threads, members, pages, categories, and attachments. All of those pages are canonicalized in XF. The problem in your case is that XenPorta does not canonicalize, but the above code fixes that.
 
Top Bottom