eZ Community » Forums » eZ Publish 5 Platform » PathPrefix and site translation problem
expandshrink

PathPrefix and site translation problem

PathPrefix and site translation problem

Wednesday 06 February 2013 8:11:04 am - 5 replies

Hi!

 

I have the following website structure:

MySite

– page1

– page2

– Blog

– – article1

– – article2

 

IndexPage in the MySite site.ini file points to the MySite node.

IndexPage in the Blog site.ini file points to the Blog node.

 

So, MySite available from this url: http://mysite.com

and the Blog available from this url: http://blog.mysite.com

 

By default my blog article available from this url:

http://blog.mysite.com/Blog/article1

To remove the "Blog" word from the url I have added PathPrefix=Blog to the Blog site.ini file. Now I can read an article using this url:

http://blog.mysite.com/article1

OK, everything works fine! 

 

But when I add a new language (russian) to my blog, the "Blog" word appears again in the article url when I want to translate it.

When I go to 

http://blog.mysite.com/article1 

and click this url:

http://blog.mysite.com/switchlang.../to/blog_ru/<article1_node_id>

EZ5 (in legacy_mode) redirects me to

http://blog.mysite.ru/Blog/article1

and the "Blog" word appears in the url again.

 

How to remove the "Blog" word from the blog urls in all situations???

Thank you in advance.

Modified on Wednesday 06 February 2013 8:14:51 am by Felix Ratnik

Wednesday 06 February 2013 10:32:21 am

Did you add

 PathPrefix=Blog

to the *.ru siteaccess site.ini?

 

Gabriele

Wednesday 06 February 2013 1:49:56 pm

Yes, but it doesn't help.

Any other hints?

Wednesday 06 February 2013 3:34:41 pm

But if you use http://blog.mysite.ru/article1 what happens?

Wednesday 06 February 2013 7:22:26 pm

Gabriele, 

The url http://blog.mysite.ru/article1 works fine. I can open it without any problems. But the LanguageSwitcher translation of this page redirects me to http://blog.mysite.com/Blog/article1. (I don't need the "Blog" word in this url).

I opened the source code of the ezpLanguageSwitcher class (located here: ezpublish_legacy/kernel/private/classes/ezplanguageswitcher.php) and found that it doesn't support PathPrefix variable at all.

There are no settings that can solve my problem since LanguageSwitcher source code doesn't contain any checks for the PathPrefix variable.

So, to fix this I have added the following code:

// Add PathPrefix if needed
$ini = eZINI::instance();
$pathPrefix = $ini->variable( 'SiteAccessSettings', 'PathPrefix' );
if ( $this->origUrl != '' && $pathPrefix != '' )
{
    $this->origUrl = $pathPrefix . '/' . $this->origUrl;
}

to the __construct( $params = null ) function in the ezpLanguageSwitcher class.

And the following code:

// Remove PathPrefix if needed
$ini = eZINI::instance();
$pathPrefix = $ini->variable( 'SiteAccessSettings', 'PathPrefix' );
if ( $urlAlias != '' && $pathPrefix != '' )
{
    $pathPrefix .= '/';
    if ( strncmp( $urlAlias, $pathPrefix, strlen( $pathPrefix ) ) == 0 )
        $urlAlias = substr( $urlAlias, strlen( $pathPrefix ) );
}

to the destinationUrl() function in the same class.

After that all problems have been instantly solved. All urls work just fine.

I think that this fix must be added to the next EZ Publish release.

What do you think about this?

Modified on Wednesday 06 February 2013 7:34:17 pm by Felix Ratnik

Thursday 07 February 2013 11:09:29 pm

Hello Felix, I don't know ezpLanguageSwitcher class so I can't give you an opinion about this fix happy.gif Emoticon

However you can open a issue in jira.ez.no and propose you patch

Gabriele

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from