I have a page who is showing the listing of all my news items and you can also “filter” the news items by category.
In this page I also use the add-on switchee. Here is my code, I delete all the div and span to make it smaller:
{exp:switchee variable="{segment_3}" parse="inward"}
{!-- --------------------------------- ALL NEWS ITEMS ------------------------------ --}
{case value="#^P(\\\\d+)$#|''|tag"}
{!-- tag is my Category URL Indicator --}
{exp:channel:categories channel="ch_nieuws" style="linear"}{if active} :: {category_name}{/if}{/exp:channel:categories}
{exp:channel:entries channel="ch_nieuws" disable="member_data" pagination="bottom" limit="7"}
<!-- 1 nieuws item-->
{categories style="linear" backspace="2"}{category_name}, {/categories}
{title}
{nieuws_teaser} <a href="http://{title_permalink=actueel/nieuws}">READ MORE</a>
<!-- einde 1 nieuws item-->
<!-- PAGINATION -->
here is the pagination code
<!-- E.O. PAGINATION -->
{/exp:channel:entries}
<!-- ============= SIDE BAR LEFT ================================ -->
filter berichten
<!-- filter per category -->
<form name="catmenu" action="">
<select name="selcat" class="droptagstyled" >
<option value="">Selecteer tag</option>
{exp:channel:categories channel="ch_nieuws" show_empty="no" style="linear"}
<option value="{path='actueel/nieuws'}">{category_name}</option>
{/exp:channel:categories}
</select>
</form>
<!-- e.o. filter per category -->
<!-- ============= EINDE SIDE BAR LEFT ================================ -->
{/case}
{!-- --------------------------------- 1 SELECTED NEWS ITEM ------------------------------ --}
{case default="Yes"}
{exp:channel:entries channel="ch_nieuws" disable="member_data|paginate" limit="1" url_title="{segment_3}" require_entry="yes"}
{if no_results} {redirect="404"} {/if}
{entry_date format="%d-%m-%Y"} {categories style="linear" backspace="2"}{category_name}, {/categories}
<h1>{title}</h1>
{nieuws_inleiding}
{if nieuws_foto != "" }
{nieuws_foto}
{/if}
{nieuws_tekst}
{/exp:channel:entries}
{/case}
{/exp:switchee}
{embed=includes/footer}
Everything is working as expected,
in this url type: .../actueel/nieuws I get all the news items
in this url type: .../actueel/nieuws/tag/press I get all the news item from category press
If I clic on the READ MORE from on news item i also get everything just fine, something like that:
../actueel/nieuws/my-first-news and I see the “detail” of that news item.
But let’s say I change manually the last segment (my-first-news) in something that doesn’t exist, for example blablabla, then I should expect to be redirect to my 404 page. But it is not the case, I just get a blanco page.