Drupal - use l or url function for mailto links

前端 未结 3 2040
挽巷
挽巷 2021-02-20 04:44

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

I am running drupal 6.

相关标签:
3条回答
  • 2021-02-20 04:59

    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>
    
    0 讨论(0)
  • 2021-02-20 05:12

    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.

    0 讨论(0)
  • 2021-02-20 05:21

    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));
    
    0 讨论(0)
提交回复
热议问题