We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to pass array attribute to Phalcon\Tag linkTo

Hi All, I need a function created linkTo instead: linkTo([$a, $b, 'title'=>'tt', 'class' => 'tty']);

I want pass array for attribute: same:

$a = 'link'; $b = 'title'; $c = [ 'title'=>'tt', 'title'=>'tty' ];

$tag = new Tag(); return $tag->linkTo([$a, $b, $c]);

It's only show: <a href="link">title</a>



93.7k
Accepted
answer
edited Mar '16

Hello,

// Volt
{{ linkTo(['LINK_HERE', 'TEXT_HERE', 'class': 'red', 'target': '_blank']) }}
// Produces
<a href="https://localhost/LINK_HERE" class="red" target="_blank">TEXT_HERE</a>

// PHP templates
echo Phalcon\Tag::linkTo(array("signup/register", "Register Here!", "class" => "btn-primary"));

More info: https://docs.phalcon.io/en/latest/api/Phalcon_Tag.html