Search
Other Sourcerer questions
Forum

root URL var inside menu item

TooNet Creation's Avatar TooNet Creation
Hi,

With sourcerer, is it possible to get and display website's root URL and display it on menu item like this ?

prnt.sc/A7rP79p5J-q6

Thanks
L.
Peter van Westen's Avatar Peter van Westen ADMIN
You can't use any special characters in the URL field. Joomla will strip that away before Sourcerer gets to handle the code.

But why not simply do this?
/#concept
Please post a rating at the Joomla! Extensions Directory
TooNet Creation's Avatar TooNet Creation
because I have created a one page website with :
- the home page with some blocs and sections
- and another single page for terms and conditions : this page is available from website footer with and hyperlink.

The problem is :
- my home page url is like this for instance : www.mywebsite.com
- from main menu when I click on each item, There is a scroll down to go on the relevant section.
- so every time I click on main menu item from home page, urls are like this :
www.mywebsite.com/#section1 goes to section 1 on home page
www.mywebsite.com/#section2 goes to section 2 on home page
www.mywebsite.com/#section3 goes to section 3 on home page
etc...
- but if I go to website's footer and if I click on terms and conditions links, I'm redirected to another page where url looks like this : www.mywebsite.com/terms-and-conditions.html
- ok for that point.
- now, from this terms and conditions page, if I click on any main menu item, does not work because the url becomes like this :
www.mywebsite.com/terms-and-conditions.html#section1
- and I want to be redirected to something like this : www.mywebsite.com/#section1

I can make a video if i'm not clear ?
Peter van Westen's Avatar Peter van Westen ADMIN
If you prepend the hash with a slash, it will go to the root of your site:
/#concept
Please post a rating at the Joomla! Extensions Directory
TooNet Creation's Avatar TooNet Creation
no does not work.
Peter van Westen's Avatar Peter van Westen ADMIN
What you could do is use ReReplacer Pro.
Place something like __ROOT__#concept in you menu item's URL.
Then use ReReplacer to replace whatever comes before __ROOT__ including that, with the root URL.

Search (Regular Expressions on):
href="[^"]*__ROOT__
Replace with PHP:
<?php echo \Joomla\CMS\Uri\Uri::root(); ?>
Please post a rating at the Joomla! Extensions Directory
TooNet Creation's Avatar TooNet Creation
good idea, let me try 😉
thanks
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription