We devised a clever solution leveraging Shopify's existing features in non-conventional ways:
Metafields for Categorization:
We created a metafield on Shopify "pages" (not products or blog posts) called "target markets."
This metafield was configured as a single-line text field with a preset list of choices (e.g., "Lead Generation," "Retail"). This provided a controlled vocabulary, ensuring consistent categorization and a better user experience for staff adding new case studies via a dropdown list. This was preferred over Shopify tags, which lack preset lists and rely on existing tags for visibility.
Link Lists for Ordering and Display:
To list and order the case studies, we utilized Shopify menus (link lists). A private menu named "case studies" was created.
Each case study page was added as a menu item within this link list. This allowed Sunbowl to manually control the display order of case studies on the main listing page simply by dragging and dropping items within the menu.
JavaScript for Filtering:
For the filtering functionality, a set of filter tabs (e.g., "Lead Generation," "Retail") were created, also using a Shopify menu ("case study filters").
Each filter tab's link was set to the case study page's URL with an appended query parameter (e.g., ?tag=retail).
A small JavaScript snippet on the case study listing page was written to:
- Read the tag parameter from the URL.
- Iterate through all case study elements (which had a class market and additional classes derived from their metafields, e.g., retail, lead-generation).
Show only the case studies whose associated metafield class matched the tag in the URL, effectively hiding the others. If no tag was present, all case studies were shown.
"Handleization" of metafield values (converting "Lead Generation" to "lead-generation") was crucial for matching URL tags with CSS classes, and this was managed within the Liquid code.
Content Presentation:
Each case study card displayed on the listing page pulled its hero image from a metafield on the individual case study page.
"Pills" or labels showing the target markets (e.g., "Retail," "Lead Generation") were dynamically pulled from the metafields and displayed on each case study card, providing quick visual cues for users browsing.