Hi,
I have a bunch of case studies (EE entries), and I want to have users be able to “filter” them down by clicking on a map of the U.S states. In other words, Case Study 1 is assigned to Texas, while Case Study 2 and Case Study 3 are assigned to California. Clicking on California should filter the full list down to Case Study 2 and 3.
The landing page for this section will look/work something like this static HTML/JS example (uses the brilliant ImageMapster):
In other words:
1. States that have entries assigned to them are highlighted in purple.
2. Only those states’ imagemap areas are linked to URLs that will do the job of filtering the entries.
My first instinct is to implement U.S. States as EE categories. I can then have a category template that filters the list down for each state. But it feels inefficient for every state to have an EE loop that checks to see whether it should output the href attribute. It would look something like this:
<area {exp:channel:entries channel="case_studies" category="5" disable="member_data" dynamic="off" limit="1" }
{if count > 0} href="{site_url}/about-us/case-studies-filter/category/alabama" {/if}{/exp:channel:entries}
data-state="AL" data-full="Alabama" shape="poly" coords="453,353,452,342,450,329,450,318,451,296,451,284,451,279,457,278,476,277,484,276,484,278,484,279,485,281,487,287,489,295,490,299,491,302,492,308,494,312,495,314,496,317,497,317,497,319,496,323,496,325,496,326,497,329,497,333,497,335,497,336,498,336,499,339,494,339,489,339,470,341,463,342,463,344,464,346,466,347,467,353,461,355,460,355,461,353,461,353,459,348,458,348,457,351,456,353,455,353,453,353">And that’s just Alabama. Is there any way around running {exp:channel:entries} 50 times? Logically I really do have to hard-code the <area> tags because they have specific rectangular or polygon coordinates, and each time I output an area I have to decide whether the href should be included, based on whether there are entries assigned to that state.
Is there a better way? Thank you!