2014-01-31 19:08 阅读 102

如何在OpenCart .tpl文件中获取当前URL?

I'd like to get the current url in a .tpl file in OpenCart.

I've seen this answer but it works only in a php file.

I have to get this way:

_my_array.push(['_productName',"<?php echo $heading_title; ?>"]);
**_my_array.push(['_productUrl', ["how can I get url ?"]]);**


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    dongshu4755 dongshu4755 2014-02-01 08:54

    To get full url

    $url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

    and btw those answers work on tpl files also because tpl files are sort of php files only

    点赞 评论 复制链接分享
  • douyi1779 douyi1779 2018-02-21 12:45

    The best practice would be to get it in the controller then use it in the view file.

    In your controller

    $data['current'] = $this->url->link($this->request->get['route'], '', 'SSL');

    Then in the view file

    echo $current;

    点赞 评论 复制链接分享