How to get complete current url for Cakephp

前端 未结 24 1222
长情又很酷
长情又很酷 2020-12-08 00:10

How do you echo out current URL in Cake\'s view?

24条回答
  •  北海茫月
    2020-12-08 00:40

    All previously proposed approaches didn't satisfy my requirements for getting a complete URL (complete as in qualified) e.g. to be used in an email send from controller action. I need the scheme and hostname as well then, and thus stumbled over the following approach:

    
    

    Due to providing router array current controller and action is kept, however id isn't and thus has to be provided here again. Second argument true is actually requesting to prepend hostname etc. for getting full URL.

    Using Router::url() is available in every situation and thus can be used in view files as well.

提交回复
热议问题