Drupal - use l or url function for mailto links

六月ゝ 毕业季﹏ 提交于 2020-01-01 08:43:47

问题


Does anyone know how to use the l() or url() function to create mailto links?

I am running drupal 6.


回答1:


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>



回答2:


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));



回答3:


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.



来源:https://stackoverflow.com/questions/1460100/drupal-use-l-or-url-function-for-mailto-links

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