Created
February 15, 2012 11:34
-
-
Save croxton/1835200 to your computer and use it in GitHub Desktop.
Stash no results placeholder trickery (untested)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{!-- The URL structure is like this /wiki/{category}/{url_title}/ | |
If I fill in random characters for the {url_title}, {no_results} should be TRUE. | |
I've verified through the Template debugger that it does indeed return "No results", but the redirect @L91 to the 404 does not work. Is there a problem with the parse order, or is it something with Switchee/Stash? | |
Thanks! | |
---------------------------------------------------------------------------------------- --} | |
{exp:stash:set name="wiki_navigation" type="snippet" parse="inward"} | |
{exp:nsm_categories:archive | |
style="nested" | |
enable="entries" | |
channel="wiki" | |
show_empty="yes" | |
pare="inward" | |
} | |
<li{if "{category_url_title}" == "{freebie_2}"} class="active"{/if}> | |
<a href="/wiki/{category_url_title}/">{category_name}</a> | |
{if category_channel_entries_total_results} | |
<ul> | |
{category_channel_entries} | |
<li {if "{freebie_3}" == "{url_title}"} class="active"{/if}><a href="/wiki/{freebie_2}/{url_title}/">{title}</a></li> | |
{/category_channel_entries} | |
</ul> | |
{if:else} | |
{!-- <li>No results fool!</li> --} | |
{/if} | |
</li> | |
{/exp:nsm_categories:archive} | |
{/exp:stash:set} | |
{exp:switchee variable="{freebie_2}" parse="inward"} | |
{case value=""} | |
{embed="_views/.wiki-list"} | |
{/case} | |
{case default="Yes"} | |
{!-- Check if we should display a category list or entry view --} | |
{switchee variable="{freebie_3}"} | |
{case value=""} | |
{!-- Parse page data --} | |
{exp:channel:entries | |
channel="wiki" | |
status="{parameter:status_pages}" | |
dynamic="no" | |
category="{exp:swanify_category:get category_url='{freebie_2}'}" | |
parse="inward" | |
{parameter:disable_default} | |
} | |
{exp:stash:append name="category_list" type="snippet"} | |
<div> | |
<a href="/wiki/{freebie_2}/{url_title}/"> | |
{if "{wiki_images:total_files}" > 0} | |
{wiki_images var_prefix="file" limit="1"} | |
<img src="{site_url}{file:url}" {if "{file:alt_text}"}alt="{file:alt_text}"{/if}> | |
{/wiki_images} | |
{if:else} | |
<img src="{global:assets_url}/img/temp/wiki-lit-no-image.gif" alt="{file:alt_text}"> | |
{/if} | |
<h2>{title}</h2> | |
<p> | |
{exp:eehive_hacksaw words="20" append="..."} | |
{wiki_intro} | |
{/exp:eehive_hacksaw} | |
</p> | |
</a> | |
</div> | |
{/exp:stash:append} | |
{/exp:channel:entries} | |
{embed="_views/.wiki-list"} | |
{/case} | |
{case default="Yes"} | |
{!-- Parse page data --} | |
{exp:stash:set_value name="no_results" value="no_results"} | |
{exp:stash:set | |
parse_tags="yes" | |
type="snippet"} | |
{exp:channel:entries | |
channel="wiki" | |
limit="1" | |
status="{parameter:status_pages}" | |
dynamic="no" | |
url_title="{freebie_3}" | |
{parameter:disable_default} | |
} | |
{!-- this placeholder should get replaced with 'no_results' before channel entries is parsed --} | |
{if {stash:no_results}}{redirect="404"}{/if} | |
{stash:entry_title}{title}{/stash:entry_title} | |
{stash:entry_id}{entry_id}{/stash:entry_id} | |
{stash:date_nice}{entry_date format="{global:date_normal}"}{/stash:date_nice} | |
{stash:date_iso}{entry_date format="{DATE_ISO8601}"}{/stash:date_iso} | |
{if wiki_intro}{stash:intro}{wiki_intro}{/stash:intro}{/if} | |
{if wiki_body}{stash:body}{wiki_body}{/stash:body}{/if} | |
{if "{wiki_images:total_files}" > 0} | |
{stash:images} | |
{wiki_images var_prefix="file"} | |
<img src="{site_url}{file:url}" {if "{file:alt_text}"}alt="{file:alt_text}"{/if}> | |
{/wiki_images} | |
{/stash:images} | |
{/if} | |
{/exp:channel:entries} | |
{/exp:stash:set} | |
{embed="_views/.wiki-details"} | |
{/case} | |
{/switchee} | |
{/case} | |
{/exp:switchee} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment