0

Is there a way to pass in an icon inside the tag of the link built by using the link (l()) function?

<a href="#"><icon> Link Text</a>

I use it like so currently:

l('text','path',options)

Options all seem to be attributes of the tag itself besides the "text". Using html =>true, I can add before the link text:

print l('<span class="' . implode(" ",$link[options][attributes]["class"]) . '"></span> ' . $link["link_title"]

However, I cannot check if the span isset inline there, unless I am missing something...

This works (below), but all my <a> have <a><span></span> linktext... even if span is empty, and I don't want that blank tag in there:

<li class="nav-item"><?php print l('<span class="' . implode(" ",$link[options][attributes]["class"]) . '"></span> ' . $link["link_title"],$link["link_path"],array('attributes'=> array('class'=>array($link[options][item_attributes]["class"], 'nav-link')),'html' => TRUE)); ?></li>

How can I add an icon, without CSS, before my link text as well as check if that span is empty?

0

you can use something like this:

l(t('Back'), 'node/' . implode(" ",$link[options][attributes]["class"]) . '/edit/', array('attributes' => array('class' => array('btn btn-default btn-back'))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.