Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-17231

Allow using url elements in the languageswitcher when uri map matching is used (patch)

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Medium Medium
    • Resolution: Unresolved
    • Affects Version/s: 4.2.0, 4.3.0, 4.4.0beta2
    • Fix Version/s: Customer request, Future
    • Component/s: Misc
    • Labels:
      None

      Description

      The switchlanguage module currently only works with siteaccesses. However, when you use uri map matching, it makes sense to allow url elements of the uri matching rules instead. Example:

      Assuming the site access is named: foobar
      and the url element for this siteaccess is: foo
      Then...
      /switchlanguage/to/foobar/My-Article
      will redirect to
      /foobar/My-Article
      which does not work, because the correct URL is
      /foo/My-Article
       
      This will also not work:
      /switchlanguage/to/foo/My-Article
      because "foo" is not a siteaccess.
      

      With the patch, the last URL in the example will work.

        Activity

        Hide
        André R added a comment -

        I personally think the way to go is to do reverse lookup using SiteURL setting and in cases where you only want only uri_part for some reason use SiteUriParts setting as introduced in 4.4.

        Show
        André R added a comment - I personally think the way to go is to do reverse lookup using SiteURL setting and in cases where you only want only uri_part for some reason use SiteUriParts setting as introduced in 4.4.
        Hide
        Geoff Bentley added a comment -

        Would be great to have this resolved. I'm using SiteUriParts, and the language switcher fails miserably with this.

        Show
        Geoff Bentley added a comment - Would be great to have this resolved. I'm using SiteUriParts, and the language switcher fails miserably with this.
        Hide
        Elie Theocari added a comment - - edited

        I had to implement my own class in order to do that. That's a shame, of course, but it does the trick for now.

        I replaced (line 164 of kernel/private/classes/ezplanguageswitcher.php):

        $finalUrl = $this->baseDestinationUrl . '/' . $this->destinationSiteAccess . '/' . $urlAlias;
        

        by

        $uriPart = $this->destinationSiteAccess;
         
        // ETHE : fix for URI mode, as the particle between the domain name and the URI is not always the name of the siteaccess
        $siteIni = eZINI::instance();
         
        if( $siteIni->hasVariable( 'SiteAccessSettings', 'URIMatchType' )
            && $siteIni->variable( 'SiteAccessSettings', 'URIMatchType' ) == 'map'
            && $siteIni->hasVariable( 'SiteAccessSettings', 'URIMatchMapItems' ) )
        {
            // ETHE : Retrieve the map between siteaccesses and URI parts
            $map = $siteIni->variable( 'SiteAccessSettings', 'URIMatchMapItems' );
            foreach( $map as $mapItem )
            {
                $mapItemParts = explode( ';', $mapItem );
         
                // ETHE : Retrieve the right URI part
                if( $mapItemParts[1] == $this->destinationSiteAccess )
                {
                    $uriPart = $mapItemParts[0];
                    break;
                }
            }
        }
         
        $finalUrl = $this->baseDestinationUrl . '/' . $uriPart . '/' . $urlAlias;
        

        This works fine on my project, which uses a 2012.12 instance.

        Regards,
        Elie

        Show
        Elie Theocari added a comment - - edited I had to implement my own class in order to do that. That's a shame, of course, but it does the trick for now. I replaced (line 164 of kernel/private/classes/ezplanguageswitcher.php): $finalUrl = $this->baseDestinationUrl . '/' . $this->destinationSiteAccess . '/' . $urlAlias; by $uriPart = $this->destinationSiteAccess;   // ETHE : fix for URI mode, as the particle between the domain name and the URI is not always the name of the siteaccess $siteIni = eZINI::instance();   if( $siteIni->hasVariable( 'SiteAccessSettings', 'URIMatchType' ) && $siteIni->variable( 'SiteAccessSettings', 'URIMatchType' ) == 'map' && $siteIni->hasVariable( 'SiteAccessSettings', 'URIMatchMapItems' ) ) { // ETHE : Retrieve the map between siteaccesses and URI parts $map = $siteIni->variable( 'SiteAccessSettings', 'URIMatchMapItems' ); foreach( $map as $mapItem ) { $mapItemParts = explode( ';', $mapItem );   // ETHE : Retrieve the right URI part if( $mapItemParts[1] == $this->destinationSiteAccess ) { $uriPart = $mapItemParts[0]; break; } } }   $finalUrl = $this->baseDestinationUrl . '/' . $uriPart . '/' . $urlAlias; This works fine on my project, which uses a 2012.12 instance. Regards, Elie

          People

          • Assignee:
            unknown
            Reporter:
            (inactive) Gunnstein Lye
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: