Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {# Set current query string #}
- {% set currentQueryString = craft.request.getQueryStringWithoutPath() %}
- {# Set variable to break loop #}
- {% set popupSet = false %}
- {# Set up variables from Globals -> Popup #}
- {% set qsps = popups.queryStringPopups %}
- {% set psps = popups.pageSpecificPopups %}
- {% set globalPopup = popups.globalPopup %}
- {# Determine whether or not a popup should display #}
- {# Check for query string popups #}
- {% if qsps|length and currentQueryString|length %}
- {# Check the current url to see if it matches a query string popup #}
- {% for popupQueryString in qsps if not popupSet %}
- {% set item = popupQueryString.queryStringPopup %}
- {% if item.queryString in currentQueryString %}
- {% include "_includes/popup" with { entry: item.ad.first() } %}
- {% set popupSet = true %}
- {% endif %}
- {% endfor %}
- {% endif %}
- {# Check for page specific popups if popup is not set #}
- {% if psps|length and not popupSet %}
- {# Check category pages to see if they match a page specific popup #}
- {% if category is defined %}
- {# Loop through page specific popups that have categories set #}
- {% for categoryPopup in psps if not popupSet %}
- {% set item = categoryPopup.pageSpecificPopup %}
- {# Loop through categories #}
- {% for itemCategory in item.categories if not popupSet %}
- {# Set category popup if current category matches #}
- {% if category.slug == itemCategory.slug %}
- {% include "_includes/popup" with { entry: item.ad.first() } %}
- {% set popupSet = true %}
- {% endif %}
- {% endfor %}
- {% endfor %}
- {# Check category pages to see if they match a page specific popup #}
- {% elseif entry is defined %}
- {# Loop through page specific popups that have pages set #}
- {% for entryPopup in psps if not popupSet %}
- {% set item = entryPopup.pageSpecificPopup %}
- {# Loop through pages #}
- {% for itemPage in item.pages if not popupSet %}
- {# Set page popup if current entry matches #}
- {% if entry.slug == itemPage.slug %}
- {% include "_includes/popup" with { entry: item.ad.first() } %}
- {% set popupSet = true %}
- {% endif %}
- {% endfor %}
- {% endfor %}
- {% endif %}
- {% endif %}
- {# Check for global popup if popup is not set #}
- {% if globalPopup|length and not popupSet %}
- {# Set the default global popup if it exists #}
- {% include "_includes/popup" with { entry: globalPopup.first() } %}
- {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement