2016-11-04 4 views
0

ShopifyサインアップフォームをGetResponseフォームに置き換えました。フォームを送信した後、同じ場所にページを置いておきます。そのためには、現在のURLを動的に生成して、戻りURLとして渡すことができます。あなたは、私が個別にすべてのページ・タイプの世話をしているcase文に見ることができるように現在のShopifyページのURLブログページのタグ付きビュー

{% assign current_url = '' %} 

    {% case template %} 
     {% when 'page' %} 
       {% assign current_url = page.url %} 
     {% when 'blog' %} 
       {% assign current_url = blog.url %} 
     {% when 'article' %} 
       {% assign current_url = article.url %} 
     {% when 'collection' %} 
       {% assign current_url = collection.url %} 
     {% when 'product' %} 
       {% assign current_url = product.url %} 
    {% endcase %} 


<form action="https://app.getresponse.com/add_subscriber.html" accept-charset="utf-8" method="post"> 
<!-- Show the name field (required) --> 
<input type="hidden" name="name"/> 
<!-- Email field (required) --> 
<input type="text" name="email"/> 

<!-- Campaign token --> 
<!-- Get the token at: https://app.getresponse.com/campaign_list.html --> 
<input type="hidden" name="campaign_token" value="xxxxx"/> 

<!-- Subscriber button --> 
<input type="submit" value="Sign Me Up" onclick="javascript:window.alert('Thanks for entering your email address!');"/> 
<!-- Add any optional code here (explained below) --> 
<input type="hidden" name="thankyou_url" value="https://example.com{{ current_url }}"/> 

:ここでは私のコードスニペットは次のようになります。ユーザーがメインブログページ(https://example.com/blogs/news)にいるとき、blog.urlは/ blogs/newsを正しく返します。しかし、いずれかのタグをクリックすると、URL行https://example.com/blogs/news/tagged/diyまたはhttps://example.com/blogs/news/tagged/bizarreに行きます。だから、current_urlが値/ブログ/ニュース/タグ付き/ diyまたは/ブログ/ニュース/タグ付き/奇妙なものなどを取得するように、このケースを処理するコードを取得しようとしています。

戻り値それもOKです。タグ値を返す方法が必要です(diyやbizarreのように)。それでは、blog.url +/tagged/+

を連結できますか?

答えて

1

current_tagsを使用してください。 https://help.shopify.com/themes/liquid/objects/current-tags#inside-collection-liquid

を参照してください、あなたのコード内の単純な変更が完全に働いたこの

{% capture current_url %} 
    {% case template %} 
    {% when 'page' %}{{page.url}} 
    {% when 'blog' %}{% if current_tags %}/{{ current_tags.first | handleize }}{% endif %} 
    {% when 'article' %}{{article.url}} 
    {% when 'collection' %}{{collection.url}}{% if current_tags %}/{{ current_tags.first | handleize }}{% endif %} 
    {% when 'product' %}{{product.url}} 
    {% endcase %} 
{% endcapture %} 

<input type="hidden" name="thankyou_url" value="https://example.com{{ current_url | strip_newlines }}" /> 
+0

のようになります!どうもありがとうございます。 – Swagata

関連する問題