Hi all,
I’m developing an EE2 managed store list for a customer and the stores would be categorized and displayed by location like this:
Global Region > Country > State/Province/U.K. County > Metropolitan Area
So you would see each of these as a heading, and then under the last heading, you would see a list of stores addresses in that area. Also note that Metropolitan Area is not universal – most areas will not have them (an example of a Metr. Area would be “Manhattan” or “Greater Los Angeles”).
My question is, what would be the best way to approach this? Would you use Categories and subcategories on the publish page? Would looping through all the categories/subs get pretty cumbersome?
Any help would be appreciated, and if you have any example tutorial links similar to this, it would be helpful.
Thanks in Advance,
Mike
I’d probably do it using a template and snippets+variables.
template_group/template/region/country/province/area
In the template:
{if segment_3 == ""}
#list global regions using DB query
{if:else}
{if segment_4 == ""}
#list global regions using DB query
{if:else}
#list countries using DB query
{/if}
{/if}This would mean just entering the normal data for each store without redundant category info.
Thanks for your reply, Westhouse IT. I guess I should have been more specific about the page though. Everything appears on one page, so for instance for the North America page, I would like to see something like this:
United States
Alaska - Store 1 - Store 2 - Store 3
New York - Manhattan - Store 1 - Store 2 - Other Areas - Store 1 - Store 2
Canada
Ontario - Store 1 - Store 2
…etc.
Oh, I see. In that case you’ll need to modify the code inside each {if} to output not just the next level below, but all levels below. I could do it in PHP code, but since I’m new to EE there may already be a quicker/easier way using EE tags.
For the PHP method, query the DB based on the final segment, e.g. all shops where country = USA. Load the data into an associative array so you have something like:
array(
'Alaska' => array(store1, store2, store3);
'New York' => array('Manhattan'=>array(store1,store2));
etc
);Then iterate through the array to output the results.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.