Nadjib Mami
Nadjib Mami

Reputation: 5830

Symfony .. hyperlinks on a view

My question is how to make a hyperlink in a view? Like <a href="link"></a> in HTML. Have I to create it in an action method in the controller and then send it to a view? or what exactly?

Upvotes: 0

Views: 299

Answers (2)

d.syph.3r
d.syph.3r

Reputation: 2215

If you are using the Twig templating engine you would have something like

<a href="{{ path('homepage') }}">Home</a>

If you are using PHP for your templates you would have something like

<a href="<?php echo $view['router']->generate('homepage') ?>">Home</a>

homepage in the above examples is a route identifier that you must already have defined in your routing configuration

Upvotes: 1

John Godspeed
John Godspeed

Reputation: 1407

Define the anchor text in the view.

Views are exactly what they sound like they're for, providing view to the visitor. Controllers, models are all for the internal processing & logic of the application.

Upvotes: 1

Related Questions