【问题标题】:How to capture a website url in the shopify contact form [duplicate]如何在shopify联系表格中捕获网站网址[重复]
【发布时间】:2015-01-31 09:24:58
【问题描述】:

我们喜欢显示网站网址,来自电子邮件中的联系表格。

我们使用shopify表单模板

 <div class="contactform"> 
    <input type="text" name="contact[name]" value="" size="22" tabindex="1" placeholder="Vor- und Nachname">
    <input type="email" name="contact[email]" value="" size="22" tabindex="1" required="required" placeholder="Mailadresse">
    <input type="text"  name="contact[firma]" value="" size="22" tabindex="1" placeholder="Firma">
    <input type="text"  name="contact[auflage]" value="" size="22" tabindex="1" placeholder="Auflage">  
    <textarea rows="8" cols="75"  name="contact[nachricht]" placeholder="Nachricht"></textarea>  
    <input type="submit" id="contactFormSubmit" value="Angebot anfragen" />            
    </div>

【问题讨论】:

标签: javascript html shopify


【解决方案1】:

创建隐藏输入

<input type="hidden" value="" id="hiddenurl" name="url"/>

并添加javascript:

var a = document.getElementById('hiddenurl');
a.value = window.location.href;

【讨论】:

  • 截至 2015 年 10 月,这个答案似乎是最可靠的。下一个最佳选择是 sn-p,它检查当前模板类型,即pageblogcollection。但这会遗漏某些 URL,例如 404、homepage/collections/all/ 等。 github.com/joshuacc/Shopify-Snippets/blob/master/…
【解决方案2】:
<p><?= htmlentities( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) ?></p>

【讨论】:

  • 此代码在 Shopify Liquid 模板中解析为:&lt;p&gt;&lt;!--?= htmlentities( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) ?--&gt;&lt;/p&gt;
猜你喜欢
  • 1970-01-01
  • 2018-04-12
  • 1970-01-01
  • 2017-06-29
  • 2012-01-25
  • 2017-04-10
  • 2022-08-05
  • 2018-10-11
  • 1970-01-01
相关资源
最近更新 更多