Can I gate some content in my HubDB based on type of asset?

I have a column in Hubdb called “Category” and it’s a list of types of assets. All the content shows up in our Resources section and I want to keep it all there in one place… it’s searchable, etc.

However, I want to gate SOME of the content, based on the category of the content (i.e., whitepaper is gated, case study is not).

Is this possible? If so, how?

Are you wanting to gate them behind a membership login? Also are the pages themselves dynamically generated?

Yes, the pages are dynamic -- all the “Resources” are on a page, then the user can filter to see a certain topic or category (type of content). What I want is, if they click on certain (but not ALL) Assets, I could pop up a form page for them to access it.

To link to a form page I’d probably just do something simple like:

  • Add a column to the HubDB for a form page link
  • In the dynamic listing code change the link to add the form page link if it exists and if not add the original dynamic link

Here’s a simple example:

{% if dynamic_page_hubdb_table_id %} {# In the dynamic listing #}
 <ul>
 {% for row in hubdb_table_rows(dynamic_page_hubdb_table_id) %}
 {# Inside the row for loop #}
 <li>
 {# In href add row.form_link if it exists OR (||) add dynamic link #}
 <a href="{{ row.form_link || request.path~'/'~row.hs_path }}">
 {{ row.hs_name }}
 </a>
 </li> 
 {% endfor %}
 </ul>
{% endif %}

If you want them all to go to the same form page you’d instead run an if statement on whatever column holds the category to check if it matches the criteria. If it does, add the form link, if not the dynamic link. You’d probably need to send some sort of parameter to the page to determine which asset was clicked and then use JavaScript on a form embed’s callback to redirect to the correct asset based on that parameter.

{% if dynamic_page_hubdb_table_id %} {# In the dynamic listing #}
 <ul>
 {% for row in hubdb_table_rows(dynamic_page_hubdb_table_id) %}
 {# Inside the row for loop #}
 <li>
 {# create link variable and set the default to the dynamic link #}
 {% set link = request.path~'/'~row.hs_path $}

 {# run if statement to check if category matches a gated category #}
 {% if row.category == "whitepaper" %}
 {# set link variable to form link with a parameter that will identify what asset was clicked #}
 {% set link = "https://www.yourformlink.com?asset="~row.hs_path %}
 {% endif %}

 {# set href to link variable #}
 <a href="{{ link }}">
 {{ row.hs_name }}
 </a>
 </li> 
 {% endfor %}
 </ul>
{% endif %}