简体   繁体   English

在prestashop中检索当前页面的其他语言的URL

[英]retrieve the URL for a different language of the current page in prestashop

Good day all. 大家好。 I'm developing a simple module for prestashop, the idea is to be able to setup the hreflang thing in the backoffice, and inject the code in the header of all the pages. 我正在为prestashop开发一个简单的模块,其想法是能够在后台安装hreflang,并将代码注入所有页面的标题中。 I'm actually struck at this point: 在这一点上,我实际上很震惊:

let say I'm on a page which URL is: 假设我在一个URL为以下的页面上:

http://www.server.com/en/content/8-quality

from here, I want to retrieve the URL of the same page, let's say in italian: 从这里,我想检索同一页面的URL,用意大利语说:

http://www.server.com/it/content/8-qualita

is there a way to do it without try to search this on the database? 有没有一种方法可以尝试不尝试在数据库上搜索? I mean, this should be work for cms pages, products, categories and so on, I would like a way to ask Prestashop: 我的意思是,这应该适用于cms页面,产品,类别等,我想问问Prestashop:

which is the URL of the current page in a given langage? 给定语言的当前页面的URL是哪个?

thanks in advance. 提前致谢。

Assuming the page you want is a cms one, in the Link.php class, you have the following function : 假设您想要的页面是cms,在Link.php类中,您具有以下功能:

public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null)

Juste call it with the good lang id and it's done. Juste用良好的lang ID调用它,就完成了。 You can call it from smarty with 您可以使用

{$link->getCMSLink('quality', null, false, $id_lang)} {$ link-> getCMSLink('quality',null,false,$ id_lang)}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM