eZ Community » Forums » Developer » Generate clean front URLs from back...
expandshrink

Generate clean front URLs from back office session

Generate clean front URLs from back office session

Tuesday 27 March 2012 6:58:42 pm - 2 replies

Hello,

I have a module which permit to export content objects into csv files.

Now, for each content object I have to generate a URL for the front office.

I made it, but it's not a really clean way.

When i get the url from the object main node, it's not the url that could be generated from a front template.

Example of content tree :

  • myfirstsite_home
    • one_content
  • mysecondsite_home
    • another_content

Here is the urls types i can generate (this works but is not clean) :
http://www.myfirstsite.com/myfirstsite_home/one_content

Here is the urls types i'd like generate (like in front templates):
http://www.myfirstsite.com/one_content

 

Is there any way to generate a url as we were in front office from a back office session ?

 

Thanks for reading and any advice,
Thomas

 

My piece of code :

 // Adding an url to the content in Front office
switch ($GLOBALS['eZCurrentAccess']['name']) {
            case 'fr_admin_myfirstsite':
                $siteAccess = 'fr_myfirstsite';
                break;
            ...            
            other cases
}        
$ezIni = eZINI::fetchFromFile(eZSiteAccess::findPathToSiteAccess($siteAccess).'/site.ini');
$url = 'http://'.$ezIni->variable('SiteSettings', 'SiteURL').'/'.$object->mainNode()->url();

Tuesday 27 March 2012 11:54:36 pm

hi Thomas,

 

Its really easy to do this . Just search on site.ini [SiteAccessSettings] PathPrefix variable.

You just need to write PathPrefix=myfirstsite_home. eZ will remove it on FO url .. done blunk.gif Emoticon

 

Cheers

Philippe

Wednesday 28 March 2012 10:50:12 am

Thanks Philippe !

I didn't knew about the PathPrefix.

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from