Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
(HTML)将变量添加到当前URL_Html_Widget - Fatal编程技术网

(HTML)将变量添加到当前URL

(HTML)将变量添加到当前URL,html,widget,Html,Widget,这对你来说很简单,可以帮助非程序员 我是一名网页设计师,帮助一位Magento Go商店老板。他们的网站以英语或德语显示。控制语言的小部件通过在当前URL上添加两个变量进行更改: ?___store=default&___from_store=german (to change from German to English) ?___store=german&___from_store=default (to change from English to German) 我在页

这对你来说很简单,可以帮助非程序员

我是一名网页设计师,帮助一位Magento Go商店老板。他们的网站以英语或德语显示。控制语言的小部件通过在当前URL上添加两个变量进行更改:

?___store=default&___from_store=german (to change from German to English)
?___store=german&___from_store=default (to change from English to German)
我在页面顶部添加了两个PNG国家标志,我希望单击其中一个标志,添加上面要添加到当前URL的适当变量

我该怎么做?


<a href="?___store=default&___from_store=german"><img src="german.png" /></a>


但这是一个Magento部署,商店切换器本身应该运行良好。

使用JavaScript:

<img src = "yourgermanflagimg" onclick = "changeURL('german')" alt = "german flag">
<img src = "yourenglishflagimg" onclick = "changeURL('english')" alt = "german flag">

<script type = "text/javascript">
function changeURL(type)
{
if(type=="german")
{
window.location.assign("www.yourpage.com?___store=default&___from_store=german");
}
else
{
window.location.assign("www.yourpage.com?___store=default&___from_store=default");
}
</script>

函数更改URL(类型)
{
如果(类型=“德语”)
{
window.location.assign(“www.yourpage.com?\uuuuuuu store=default&\uuuuuuuu from\u store=derman”);
}
其他的
{
window.location.assign(“www.yourpage.com?\uuuuuu store=default&\uuuuuuuuu from\u store=default”);
}

解决方案应将参数添加到当前URL。如果使用固定前缀(“yourpage.com”)每次更改语言时,您都会被重定向到主页。@MihaiStancu我感觉OP想用另一种语言重新加载当前页面。我加了前缀,因为我不知道他的页面的真实名称。这些URL是Magento“store”切换器的典型URL。商店有一种关联的语言。因此(确实如此)语言切换器。但它意味着将任何页面切换到其翻译版本。@MihaiStancu我明白了。对不起。我不知道如何用JavaScript获取URL,但我的答案仍然很简单。谢谢你Mihai。(店主出于某种原因想要这些标志)在Magento 1.7中,有一个专门为标志定义的商店切换器模板。因此,基本上您需要做的就是将添加商店切换器的布局XML从使用
语言.phtml
stores.phtml
模板更改为使用此模板:
app/design/frontend/base/default/template/page/switch/flags.phtml
根据经验,你应该首先陈述你的“最终目标”,记录你所做的尝试,然后提出一个能解决你的“明显目标”的问题。有些解决方案可能会更好,绕过你的“明显目标”,但仍然能解决你的“最终目标”。
<img src = "yourgermanflagimg" onclick = "changeURL('german')" alt = "german flag">
<img src = "yourenglishflagimg" onclick = "changeURL('english')" alt = "german flag">

<script type = "text/javascript">
function changeURL(type)
{
if(type=="german")
{
window.location.assign("www.yourpage.com?___store=default&___from_store=german");
}
else
{
window.location.assign("www.yourpage.com?___store=default&___from_store=default");
}
</script>