Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. {# Set current query string #}
  2. {% set currentQueryString = craft.request.getQueryStringWithoutPath() %}
  3.  
  4. {# Set variable to break loop #}
  5. {% set popupSet = false %}
  6.  
  7. {# Set up variables from Globals -> Popup #}
  8. {% set qsps = popups.queryStringPopups %}
  9. {% set psps = popups.pageSpecificPopups %}
  10. {% set globalPopup = popups.globalPopup %}
  11.  
  12. {# Determine whether or not a popup should display #}
  13.  
  14. {# Check for query string popups #}
  15. {% if qsps|length and currentQueryString|length %}
  16. {# Check the current url to see if it matches a query string popup #}
  17. {% for popupQueryString in qsps if not popupSet %}
  18. {% set item = popupQueryString.queryStringPopup %}
  19. {% if item.queryString in currentQueryString %}
  20. {% include "_includes/popup" with { entry: item.ad.first() } %}
  21. {% set popupSet = true %}
  22. {% endif %}
  23. {% endfor %}
  24. {% endif %}
  25.  
  26. {# Check for page specific popups if popup is not set #}
  27. {% if psps|length and not popupSet %}
  28.  
  29. {# Check category pages to see if they match a page specific popup #}
  30. {% if category is defined %}
  31. {# Loop through page specific popups that have categories set #}
  32. {% for categoryPopup in psps if not popupSet %}
  33. {% set item = categoryPopup.pageSpecificPopup %}
  34. {# Loop through categories #}
  35. {% for itemCategory in item.categories if not popupSet %}
  36. {# Set category popup if current category matches #}
  37. {% if category.slug == itemCategory.slug %}
  38. {% include "_includes/popup" with { entry: item.ad.first() } %}
  39. {% set popupSet = true %}
  40. {% endif %}
  41. {% endfor %}
  42. {% endfor %}
  43.  
  44. {# Check category pages to see if they match a page specific popup #}
  45. {% elseif entry is defined %}
  46. {# Loop through page specific popups that have pages set #}
  47. {% for entryPopup in psps if not popupSet %}
  48. {% set item = entryPopup.pageSpecificPopup %}
  49. {# Loop through pages #}
  50. {% for itemPage in item.pages if not popupSet %}
  51. {# Set page popup if current entry matches #}
  52. {% if entry.slug == itemPage.slug %}
  53. {% include "_includes/popup" with { entry: item.ad.first() } %}
  54. {% set popupSet = true %}
  55. {% endif %}
  56. {% endfor %}
  57. {% endfor %}
  58. {% endif %}
  59. {% endif %}
  60.  
  61. {# Check for global popup if popup is not set #}
  62. {% if globalPopup|length and not popupSet %}
  63. {# Set the default global popup if it exists #}
  64. {% include "_includes/popup" with { entry: globalPopup.first() } %}
  65. {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement