Targeting anchor with controller

Situation 1
This code goes through my bootstrap and produces the expected page:
$this->view->render(‘checkIndividualPricesPostSetups/index’,$data);

Situation 2
I understand why this code throws a fatal error (file doesn’t exit - I get that):
$this->view->render(‘checkIndividualPricesPostSetups#c5/index’,$data);

Situation 3
When I type “my.com/checkIndividualPricesPostSetups#c5” into the URL, AFTER the page has been rendered, the page dutifully scrolls down to the a5 id.

What’s the difference between the second and third situation?

Hi @nichemtktg,

Your anchor should be at the end of the URL.
I’m not knowledgeable with your code however I think for point number 2 you should have checkIndividualPricesPostSetups/index#c5 instead of checkIndividualPricesPostSetups#c5/index.

Edit: However I’m not sure how much sense it makes to render that page with the anchor as the anchor is used in the browser’s URL to jump to a particular section of the page and not sure what you’re expecting to happen when you tell your page to render with an anchor

Hope that helps,

Andres

1 Like

When you type “my.com/checkIndividualPricesPostSetups#c5” into a browser, the browser strips off the #c5 and send the rest to the server which is handled by situation 1 in your question.

A full page is generated and sent back to the browser. The browser renders it and then scrolls to id=c5.

So your php code never sees the anchors.

1 Like

Boy that was a rabbit hole and a testament to owning your code!

I got stuck on thinking the URL was coming from my controller when it was, in fact, coming from a form on the previous page.

Thanks to Andres_Vaquero and ahundiak for their time and interest in code!

niche

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.