【问题标题】:How to get the last value from url in smarty如何从smarty中的url获取最后一个值
【发布时间】:2023-03-04 07:08:04
【问题描述】:

我需要从 smarty 中的给定 url 中获取最后一个值

My url : http://localhost/htdocs/cscart_mutli_car/electronics/computers/desktops/

I need to get "desktops" from the above url

我该怎么做。请帮帮我。

【问题讨论】:

  • 这是您的 url 要求类别和子类别吗?
  • 如果你 print_r($_REQUEST),你会得到什么?
  • 不需要在 tpl 文件上显示桌面
  • 提取PHP中的片段(从$_SERVER['REQUEST_URI']获取),分配给你的Smarty对象,在模板中使用。

标签: php smarty cs-cart


【解决方案1】:

请尝试

{assign var="last_dir" value="/"|explode:$smarty.server.REQUEST_URI}
{assign var="last_key" value=$last_dir|count}
{assign var="last_dir" value=$last_dir[$last_key-2]}
{$last_dir}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-07
    • 1970-01-01
    • 2019-07-24
    相关资源
    最近更新 更多