Does anyone know if it's possible to render a view to open at an anchor tag in the middle of a page?
I want index.html
to open at id="xyz"
.
This is my Controller code:
View::renderTemplate('Folder/index.html', [
'array' => $array
]);
This throws an error:
View::renderTemplate('Folder/index.html#xyz', [
'array' => $array
]);
This is not possible, but you can use this solution with javascript.
Add the anchor on the page with the twig template. If the javascript find the ID, it redirects the nativator to the anchor without reloading the page.
If you want redirect with an HTTP 301/302 code and anchor you can see _fragment https://symfony.com/blog/new-in-symfony-3-2-routing-improvements