Drupal - use l or url function for mailto links

非 Y 不嫁゛ 提交于 2019-12-04 01:58:10

You need to use the absolute option:

l('Mail me', 'mailto:jim@hotmail.com', array('absolute' => TRUE));

will generate

<a href="mailto:jim@hotmail.com">Mail Me</a>

A good practice is to use the t() function with strings. Code should be then:

l(t('Mail me'), 'mailto:jim@hotmail.com', array('absolute' => TRUE));

Preferably none:

l() is useful for the output of internal links:

it handles aliased paths and adds an 'active' class attribute to links that point to the current page (for theming)" see reference

You need none of the above. Same goes for url(). You CAN use them, but why not keeping it simple and just use the HTML anchor tag directly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!