douhuiqi3855
2014-01-31 19:08
浏览 184
已采纳

如何在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 ?"]]);**

Thanks

图片转代码服务由CSDN问答提供 功能建议

我想在OpenCart中的.tpl文件中获取当前网址。 \ n

我见过这个回答但它 仅适用于php文件。

我必须这样:

  _my_array.push(['_ productName',“&lt;  ;?php echo $ heading_title;?&gt;“]); 
 ** _ my_array.push(['_ productUrl',[”我怎么能得到网址?“]]); ** 
   
 
 

谢谢

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

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

    To get full url

    <?php
    $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 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;

    评论
    解决 无用
    打赏 举报