dqpkea9486 2014-12-03 10:11
浏览 25

如何在prestashop中从smarty获得正确的cms链接(带有漂亮的URL)?

If I want to link to a cms page from a template with smarty, I currently use something like this:

{$link->getPageLink('cms',null,null,'id_cms=4')}

But that is going to generate a regular url (with query string), so if I activate pretty urls (url rewrite), it won't work. I analized the Link class but I can't find a way to generate a proper rewritten url. In fact, THERE IS a simple way:

{$link->getCMSLink(4)}

BUT, taking a look into Link::getCMSLink notes, I read that using an ID instead of a CMS object is deprecated. But from a template I don't have the cms object available.

Anyone had the same problem?

  • 写回答

1条回答 默认 最新

  • duanchen7703 2015-09-14 15:00
    关注

    I found it really by "let's try if this one works".....

    In PS1.6 you can get CMS object like:

    $myCMS = new CMS( YOUR_CMS_ID );
    

    If you want to use it in tpl, you have to define it in your controller e.g.:

    $this->context->smarty->assign( "myCMS", $myCMS );
    
    评论

报告相同问题?

悬赏问题

  • ¥30 seata使用出现报错,其他服务找不到seata
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误