Exclude Locale from Menu links
-
Hi, i have set
'hideDefaultLocaleInURL' => true,
inlaravellocalization.php
but when I render a menu the URLs all have/en/
prefixed to them. How can I avoid this happening please?
-
Hi what is your locale in config/app ?
-
Default menuPresenter has this sorted, if you are using custom one please see default one for the part where it checks for this.
MenuPresenter - specificallysetLocale
function and its usages.
-
@hgy said in Exclude Locale from Menu links:
Hi what is your locale in config/app ?
Hi, it's
'locale' => 'en'
-
@armababy said in Exclude Locale from Menu links:
Default menuPresenter has this sorted, if you are using custom one please see default one for the part where it checks for this.
MenuPresenter - specificallysetLocale
function and its usages.Hi, yes I am using a custom presenter, but even using the MenuPresenter the locale is appearing in the generated URL. Seems like the original
$item->url
contains the locale, so thesetLocale
function isn't actually doing anything..
-
Also, the home page URL is being returned as
en/home
- any reason why it contains the homepage slug? How can i prevent this? It should just returnen/
right?
-
Oh I see...
'hideDefaultLocaleInURL' => true only removes it from your path in address line... links has the locale in the database
You can remove it from the string start easily by checking if current locale() is default locale and 'hideDefaultLocaleInURL' is true.Cheers
-
@pavsid Are you use the homepage functionality of backend?
-
@hgy said in Exclude Locale from Menu links:
Oh I see...
'hideDefaultLocaleInURL' => true only removes it from your path in address line... links has the locale in the database
You can remove it from the string start easily by checking if current locale() is default locale and 'hideDefaultLocaleInURL' is true.Cheers
OK thanks.
-
@hgy said in Exclude Locale from Menu links:
@pavsid Are you use the homepage functionality of backend?
You mean in the Pages module? I have checked the "Homepage ?" option yes, if that's what you mean?
-
@pavsid Yes that is what I mean.
Then the slug is there if You call homepage route, because its set it up as a homepage if you dont want it you can use it as an internal link menutype, I think it solves your problem or extend your menupresenter with default home menuitem as you prefer.