2016-11-04 2 views
0

Shopify 가입 양식을 GetResponse 양식으로 대체했으며 양식을 제출 한 후 동일한 위치에 있어야합니다. 이를 위해 현재 URL을 동적으로 생성하여 반환 URL로 전달할 수 있습니다. 여기 내 코드의 모습입니다 :현재 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이/blogs/news/tagged/diy 또는/blogs/news/tagged/bizarre 등의 값을 얻도록이 코드를 처리하려고합니다.

반환하는 단일 변수가없는 경우 그것도 괜찮습니다. 태그 값 (예 : 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

관련 문제