Search
Other ReReplacer questions
Forum

replace href by button

Peter van Westen's Avatar Peter van Westen ADMIN
You can continue here...
Please post a rating at the Joomla! Extensions Directory
Laurent Lacoste's Avatar Laurent Lacoste
ok thanks.
I come back to you when done.
Laurent Lacoste's Avatar Laurent Lacoste
Ok I have now the subscription.
So I did this : prnt.sc/7Z-2A5iXtUqp
But from website front-end, when I look html output I always have <a> instead of <button>.
Peter van Westen's Avatar Peter van Westen ADMIN
Adjust the Regular Expressions to deal with the 'missing' quotes in the html output:
<a href=([^>]*)>Contact</a>
Replace:
<a onclick="location.href='\1'">Contact</a>

If that doesn't work, can you give me (super) admin so I can take a look?
And tell me on what url I can see/reproduce the issue.
You can use the 'Confidential information' button in the forum editor to hide sensitive information.
Please post a rating at the Joomla! Extensions Directory
Laurent Lacoste's Avatar Laurent Lacoste
same problem.
I have added credentials and more infos with 'Confidential information' button.
thank you

Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
The links seemed to have weird whitespace in them (before and after the href) and also would have quotes on some pageloads.

Anyway, this works:
<a\s*href="?([^>\s"]+)"?\s*>Contact</a>
Please post a rating at the Joomla! Extensions Directory
Laurent Lacoste's Avatar Laurent Lacoste
ok works fine.
I have 2 questions more :

1) is it possible to do something like this <a\s*href="?([^>\s"]+)"?\s*>*</a> to rewrite automatically all menu links ?

2) is it possible to create a rule and assign this rule automatically to X or Y pages ?
Peter van Westen's Avatar Peter van Westen ADMIN
Yes, you can do:
<a\s*href="?([^>\s"]+)"?\s*>(.*?)</a>
And replace with:
<a onclick="location.href='\1'">\2</a>
But use the "Between" strings to limit the replacement to only your menu.

You can use the Conditions to make it only be done on the pages you want.
Either via URL or via the menu items or any of the other Rule types.
Please post a rating at the Joomla! Extensions Directory
Laurent Lacoste's Avatar Laurent Lacoste
ok works fine.
About rules, is it also possible to say something like : "I want to replace XXX only on main menu" ?
So maybe apply this rules only on specific css classes?
Peter van Westen's Avatar Peter van Westen ADMIN
not by css class. But you can use the 'Between' strings to limit it to the area you need.
If you cannot find beginning and ending html that is unique enough, you could use a template override to - for instance - wrap your menu in something unique like:
<!-- START MAIN MENU -->
...
<!-- END MAIN MENU -->
Please post a rating at the Joomla! Extensions Directory
Laurent Lacoste's Avatar Laurent Lacoste
Ok good idea.
I check this out and I come back to you.
thank you
Laurent Lacoste's Avatar Laurent Lacoste
Hi,

Tested and works fine.

Another question : I will try to explain as best as I can.

for instance, I go on this page i.imgur.com/3p6V8oZ.png
then, is it possible to rewrite only all these links i.imgur.com/O6W54W9.png + i.imgur.com/jEd77Vd.png + i.imgur.com/LCGjL09.png + i.imgur.com/AJ7rSra.png and keep normal links for these pages i.imgur.com/GnALFc4.png ?

Thanks
L.
Peter van Westen's Avatar Peter van Westen ADMIN
You should have enough information to do what you want/can with ReReplacer Pro.

You can search and replace using dynamic Regular Expressions.
If you need to only replace certain links - in your case, you will need something unique in the html you can limit the search by.
You can limit the Regular Expressions search itself.
And/or use the Between fields to limit it to a certain section on the page.
And/or use conditions to limit the replacement to certain pages/situations.

If there is nothing really unique about specific elements you want to target, you will have to use template overrides to add some unique html around or inside the elements.
Please post a rating at the Joomla! Extensions Directory
Laurent Lacoste's Avatar Laurent Lacoste
Yes I know that.
But my question was more to do that dynamically depending on the page where the user is?
Peter van Westen's Avatar Peter van Westen ADMIN
Maybe possible, but not easy. You would need to use PHP to read out the current url and compare it to whatever you want to replace.
Please post a rating at the Joomla! Extensions Directory
Laurent Lacoste's Avatar Laurent Lacoste
ok I will try to do some tests.
thanks
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription