Hello,
I’m trying to figure out why my URL isn’t working the way that it is supposed to. For this particular template, the structure is as such:
http://www.example.com/latest/{category}/{url_title}
So latest is segment_1, the category is segment 2, and the url_title from the post is segment_3. At the beginning of the code I’m parsing the URL, but I’m not getting the results that I would expect. Even with multiple segments, I hit the “404” error from the results right away. Here is the code:
{!-- Break Apart URL for Page Processing --}
{if segment_3!=""}
{!-- Segment 3 Exists: Check URL for Validity --}
{exp:channel:entries
channel="latest"
url_title=segment_3
disable="categories|category_fields|custom_fields|member_data|pagination"
limit="1"}
{if no_results}
{!-- Entry Not Found: 404 --}
{if:else}
{!-- Entry Found: Display Single Post --}
{/if}
{/exp:channel:entries}
{if:else}
{!-- Segment 3 Does Not Exist: Begin Segment 2 Breakdown --}
{if segment_2!=""}
{if segment_2=="history"}
{!-- Segment 2 is History: Display Full Post History --}
{if:else}
{!-- Top Level is at Category Level (2): Verifying Category Exists --}
{exp:query
sql="SELECT cat_id, cat_name
FROM exp_categories
WHERE cat_url_title = '{segment_2}'
LIMIT 1"}
{if no_results}
{!-- Category Does Not Exist: Redirect to Home --}
{if:else}
{!-- Category Exists: Displaying Category Feed --}
{/if}
{/exp:query}
{/if}
{if:else}
{!-- No Segment 2 or 3: Display All Content --}
{/if}
{/if}Let me know if I can provide anything else that can illuminate the issue. Thanks in advance!