[SOLVED] Convert syntax to Htmlhelper style

Good day,

I need help converting the following line of code to Htmlhelper.
<li><a href="/"><i class="fa fa-book"></i> <span>List Articles</span></a></li>

I only know how to add the controller and actions.
<li><?= $this->Html->link(__('List Articles'), ['controller' => 'Articles', 'action' => 'index']) ?></li>

<li> <?= $this->Html->link("<i class="fa fa-book"></i> listOfArticales",["controller"=>"Articles","action"=>"index"]) ?> </li>

Hope you enjoy this little help !!!

1 Like
<li> <?= $this->Html->link(
    '<i class="fa fa-book"></i> listOfArticales',
    ['controller' => 'Articles', 'action' => 'index'],
    [
        'escape' => false, // Allow HTML in the link content
        'target' => '....',
    ]
) ?> </li>

Everything that is not a reserved word will result in an attribute (eg. target, “data-…”, rel, etc)

1 Like

Thank you so much!
This worked for me.
<li><?= $this->Html->link('<i class="fa fa-book"></i> <span>List Articles</span>', ['controller' => 'Articles', 'action' => 'index'], ['escape' => false]) ?></li>

Marking this solved.