2016-10-19 11:24
浏览 75


It seems that Shopware has some "magic behind" when generating URLs and i am looking for someone, who can explain this to me.

This is the code of standard-template to generate SEO-urls with variables which can be configured in SEO-router-settings in the backend:

{* Product name *}
{block name='frontend_listing_box_article_name'}
    <a href="{$sArticle.linkDetails|rewrite:$sArticle.articleName}"

The configuration in SEO-router-settings looks like this per default:

enter image description here

Anyway, the output is little different:

(All capital letters demonstrates real correct domain-, category- and product-names, that are hidden here for the sake of privacy of my client)

The issue here is the URL-Parameter "?c=7" which isn't wanted and should be omitted as defined in SEO-router-options.

First question: how to omitt this URL-parameter "c=7" at the end of URL?

When i debug this code, i run into strange things. The following code will result in two different URLs although it is the same term executed:

enter image description here

These are the issues here:

  1. The output of {$sArticle.linkDetails|rewrite:$sArticle.articleName} is different between the href-Attribute and the second output as the caption of this link.
  2. The output of {$sArticle.linkDetails|rewrite:$sArticle.articleName} within href-Attribute will add an URL-Parameter to describe the id of the category, which isn't wanted: "?c=7"

Second question:

How can the same template-code be so different? What magic is there working behind the scenes?

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

似乎 Shopware 在生成网址时有一些“魔力背后”,我正在寻找 对于那些可以向我解释的人。

这是标准模板的代码,用于生成带有变量的SEO-urls,可以在SEO-router-settings中配置 后端:

  {* Product name *} 
 {block name ='frontend_listing_box_article_name'} 
&lt; a href =“{$ sArticle.linkDetails | rewrite:$  sArticle.articleName}“
 class =”product  -  title“
 title =”{$ sArticle.articleName | escape}“&gt; 
 {$ sArticle.articleName | truncate:50} 
&lt; / a&gt;  
 {/ block} 



  http:  //

(所有大写字母表示真正正确的域名,类别 - 和产品名称,为了我的客户隐私而隐藏在这里)

这里的问题是URL参数“?c = 7”,这是 不应该如SEO-router-options中所定义的那样省略。

第一个问题:如何在这个网址参数“c = 7”中省略 URL的结尾?

当我调试这段代码时,我遇到了一些奇怪的事情。 以下代码将生成两个不同的URL,尽管它是相同的术语:


  1. {$ sArticle.linkDetails | rewrite:$ sArticle.articleName} 的输出在href之间是不同的 -Attribute和第二个输出作为此链接的标题。
  2. href-Attribute中 {$ sArticle.linkDetails | rewrite:$ sArticle.articleName} 的输出将 添加一个URL-Parameter来描述类别的id,这是不需要的:“?c = 7”


    相同的模板代码如何如此不同? 在幕后工作有什么魔力?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题