HubDB filter based on Column

Regular Contributor

I had a difficult time following the team-member location tutorial.  I am trying to filter rows based on a multi-select category column.  Ideally, the items would show up with "../category/" showing the rows containing the rows containing the category.  Keep in mind there are instances when someone might be trying to drill down to two or three categories.  I want to use a vertical menu with clickable links, and not the search box functions... yet.

In short, I am trying to recreate this in HubDB:

https://towersurfaces.com/product-category/showers/shower-bases/barrier-free/

 

I am at a total loss so far.  I managed to get everything to come on the screen and show the product details once one of them is clicked on, but that's as far as I can figure out.  I am not sure if I am supposed to do a multilevel dynamic page, or what...

 

{% if dynamic_page_hubdb_row %}
  <h1>
    {{ dynamic_page_hubdb_row.Name }}
  </h1>
  <img src="{{ resize_image_url(dynamic_page_hubdb_row.featured_image.url, 400,0,0)}}" alt="{{ dynamic_page_hubdb_row.Name }}">
  <p>
    {{ dynamic_page_hubdb_row.product_description }}
  </p>
  {% elif dynamic_page_hubdb_table_id %}
<div class="ProductCatalog">
  <!-- Shows all Products -->
  {% for product in hubdb_table_rows(dynamic_page_hubdb_table_id) %}
  <div class="ProductBox">
<a class="ProductImage" href="{{ request.path }}/{{ product.hs_path }}" title="{{ product.Name }}" target="_blank">
  <img src="{{ resize_image_url(product.featured_image.url, 400,0,0)}}" alt="{{ product.Name }}">
  <p class="ProductTitle">
   {{ product.Name }}
  </p>
    </a>
  </div>
  {% endfor %}
</div>
{% endif %}

Pls Halp

Reply
0 Upvotes
2 Replies
Highlighted
Regular Contributor

Hi @DBellamy,

I've tried a similiar thing a while ago. You can find it here.

The only difference is, that the customer wanted to have a "filter module" for different options which had to be concatenated.

 

Maybe it gives you the needed solution or an idea how to get a filter into HubDB.

 

 

Also - have you tried the "real estate tutorial" - there is a documentation for a filter function. 

 

regards,

Anton 

 

 

 

 

 

Reply
0 Upvotes
Regular Contributor

OK, so I am halfway there...  I am able to create one module to filter them all based on the path they are on, thanks to you and the Dynamic Team tutorial, but the holy grail is to get the filter path to show up in the product detail, all with the same module.  Here is where I am...

 

 

{# sets the different query parameters using request path for hubdb query #}
{% set queryparam = "" %}
{% if request.path == "/showers/showerbase/" %}
    {% set queryparam = queryparam ~ "&category__in=1" %}
{% endif %}
{% if request.path == "/showers/showerbase/barrierfree" %}
    {% set queryparam = queryparam ~ "&category__in=2" %}
{% endif %}
{% if request.path == "/showers/showerbase/custom" %}
    {% set queryparam = queryparam ~ "&category__in=3" %}
{% endif %}

  <!-- Shows Product Details -->
{% if dynamic_page_hubdb_row %}
  <h1>
    {{ dynamic_page_hubdb_row.Name }}
  </h1>
  <img src="{{ resize_image_url(dynamic_page_hubdb_row.featured_image.url, 400,0,0)}}" alt="{{ dynamic_page_hubdb_row.Name }}">
  <p>
    {{ dynamic_page_hubdb_row.product_description }}
  </p>
  {% else %}
<div class="ProductCatalog">
  <!-- Shows all Products -->
  {% set products = hubdb_table_rows ('8675309', queryparam) %}
  {% for product in products %}
  <div class="ProductBox">
{# I think I need to do something with this request.path URL to make this work, but I know not what #} <a class="ProductImage" href="{{ request.path }}/{{ product.hs_path }}" title="{{ product.Name }}" target="_blank"> <img src="{{ resize_image_url(product.featured_image.url, 400,0,0)}}" alt="{{ product.Name }}"> <p class="ProductTitle"> {{ product.Name }} </p> </a> </div> {% endfor %} </div> {% endif %}

 I know if I change the a href to remove the dynamic path, and change it to "showers," it works, but I have NO idea why!

<a class="ProductImage" href="/showers/{{ product.hs_path }}" title="{{ product.Name }}" target="_blank">
Reply
0 Upvotes