We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

List of venues with geographical hierarchy

Development and Programming

mycloc's avatar
mycloc
4 posts
14 years ago
mycloc's avatar mycloc

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

       
Paul @ Westhouse IT's avatar
Paul @ Westhouse IT
89 posts
14 years ago
Paul @ Westhouse IT's avatar Paul @ Westhouse IT

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.

       
mycloc's avatar
mycloc
4 posts
14 years ago
mycloc's avatar mycloc

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.

       
Paul @ Westhouse IT's avatar
Paul @ Westhouse IT
89 posts
14 years ago
Paul @ Westhouse IT's avatar Paul @ Westhouse IT

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.

       
Paul @ Westhouse IT's avatar
Paul @ Westhouse IT
89 posts
14 years ago
Paul @ Westhouse IT's avatar Paul @ Westhouse IT

Anyone have an EE tag equivalent or alternative?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.