Jump to content

Trying to link to a specific place on another page


Charlie W
 Share

Recommended Posts

I have a page that lists products for a lumber manufacturer; I'll call the manufacturer "Acme" for this example.  Acme's products include both decking lumber and siding lumber.  On the menu, when the user selects "siding", I need to load the page that lists the decking lumber and then the siding lumber and jump to the first siding product.  Pretty straightforward...I have an <a id="siding">...</a> tag on the target page.  The menu link target is "acme#siding", but when the URL gets rendered in Processwire, it changes it to "acme/#siding" (with the slash).  I'm not sure how to get the result I am looking for.  Any help is appreciated.

Link to comment
Share on other sites

@Charlie W your question ist not directly related to processwire. You would get or find an answer more quickly on stackoverflow. Or just ask chatgpt, claude, …

acme/#sliding is correct. Just make sure that you do not have multiple elements with the same id.
Then you link <a href='#siding>siding</a> should get you to your target <div id='siding'></div>

Link to comment
Share on other sites

No.   The proper way to link to a bookmark on ANOTHER page is "acme#siding", not "acme/#siding".  The slash renders from Processwire, but my link is correct.  Processwire is changing my link <a href="acme#siding">Siding Products</a> to acme/#siding when you view the URL at the top of the browser.

Link to comment
Share on other sites

I’m assuming you do something like this:

<a href="<?=$manufacturer->url()?>#siding">Get Wood</a>

Go to the template settings of the $manufacturer page’s template and in the URLs tab, set the slash option to “No”:

image.png.167de108b41e84fb386e359bc10763b6.png

This will make the url() method generate links without the trailing slash and it will stop redirecting to the slashed version.

That said, I’m pretty sure the links should work either way.

Edited by Jan Romero
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...