Implementing 404 redirect with LV dropdown
Hi,
I have LV set up for an ecommerce site: Every product category has it's own LV Group with a WYSIWG editor for general category infos and intro text and the such. Then I have a Matrix variable type for the products (Headings and text for subcategories) and a Playa cell type.
This gives great flexibility to the site owner and editors. Products can be rearranged with Playa and so on.
Now I'd simply like to add an option to "close" certain categories, so that editors could set a category to "closed" and upon requesting that given url visitors are being redireted to 404, sort of mimicking EE standard 404 redirect ({if status == "closed"}{redirect="404"}{/if}).
How would I best go about that? Set up a "status" dropdown variable-type and then in the template something like:
{exp:low_variables:pair var="status"}
{if {status} == "Closed"}{redirect="404"}{/if}
{/exp:low_variables:pair}
Additional question:
If all of the products coming from the Playa cell type inside the Matrix variable are set to closed, how would I manage a redirect then? Just thinking that if no products are open no products would be displayed to visitors so I might as well then redirect to 404.
Thanks and Cheers!
Marc
Replies
Low 3 Apr 2014 12:54
Yeah, using a var per category for that would be one way. If set to early parsing, you'll also be able to use {if my_status_var == 'Closed'}{redirect="404"}{/if}.
Doesn't the Playa cell support some kind of no_results conditional? That's how you'd trigger it, I think.
MarcTiedemann 4 Apr 2014 08:51
Thanks Low,
it's working great. Now checking the Playa part...