CMS Development

DanielSanchez
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

How to make the HubDB listing not display results

SOLVE

Hello!

 

I'm creating a landing page that pulls information from our HubDB. LP link: https://ead.univali.br/lp-selecao-curso (Password: MaisCampus)

 

The point is that on this landing page, I didn't want the content to be listed until the person selected it in the filter.

 

The Filter is working now, and so are the results. What I need is to know how I can make sure that when I access this landing page, the loaded courses do not come.

I send the code snippet that refers to the list of HubDB content

 

<!-- LISTAGEM DE CURSOS -->
{% elif dynamic_page_hubdb_table_id %}
  <div class="header-courses-list" style="background-image: url('{{ module.courses_list.background_header_courses_list.src }}')">
    {#<div class="section-toggleable-tabs-detail" style="background-image: url('{{ module.background_img.src }}')"></div>#}
    <div class="content-wrapper">
      <div class="box-cursos-lista">  
        <h1>{{ module.courses_list.title_courses_list }}</h1>  

        <!-- Set the filter by drop down, search bar, and submit button -->
         <div class="filters-content-hubdb">
           <form id="form_id" method="get">
             <div class="input-filter">
              <!--<h4>Tipo do curso:</h4>-->
              <select name="cursofield" form="form_id" onChange="this.form.submit()">
                <option value="show-all">Curso</option>
                {% set types = hubdb_table_column(2621653, "curso").options %}
                {% for choice in types %}
                  {% set type_list = type_list~choice.id|list %}
                  {% if choice.id == request.query_dict.cursofield %}
                    <option selected="selected" value="{{ choice.id }}">{{ choice.name }}</option>
                  {% else %}
                    <option value="{{ choice.id }}" class="option-{{ choice.id }}">{{ choice.name }}</option>
                  {% endif %}
                {% endfor %}
              </select>
             </div>
          </form>
        </div>
     </div>
    </div>
  </div>

  <div class="content-courses-list">
     <div class="content-wrapper">
        <div id="Graduacao" class="tabcontent">
        {# <h2>{{ module.courses_list.h2_courses_list }}</h2>#}

        <!-- Set the different query parameters using submitted input for hubdb query -->
        {% set queryparam = "&active__eq=s" %}

        {% if request.query_dict.cursofield in ["1", "2", "3", "4", "5", "6"]  %}
          {% set queryparam = queryparam ~ "&curso="~request.query_dict.cursofield|urlencode %}
        {% endif %}  

        {% if request.query_dict.cursofield == "show-all" %}
          {% set queryparam = queryparam ~ "&active__eq=lp" %} <!-- "..eq=s" para exibir todos cursos com active "s". LP = parâmetro feito para não exibir cursos -->
        {% endif %}


        <!-- Render Listing database -->
        {% set table = hubdb_table_rows(2621653, queryparam) %}

        <!-- CONTEUDO QUANDO O FILTRO NAO TEM RESULTADO -->      
        {% if table == [] %}
          <p class='align-center'>Nenhum resultado encontrado para essa busca. Tente novamente!</p>
        {% else %}
      
        {#% for row in table|sort(False, False, 'hs_name') %}#}
        {% for row in table %}
      
<!-- SOBRE O CURSO + FORM -->
<div class="section-courses-grad">
  <div class="content-wrapper">
    <div class="content-left">
      
      <h1>{{ row.h1_header }}</h1>
      <div class="tags-header">
        <div class="tag-single {{ row.cor_do_curso.name }}"><img src="{{ module.header.icon_type.src }}"> {{ row.tipo.name }}</div>
        <div class="tag-single {{ row.cor_do_curso.name }}"><img src="{{ module.header.icon_modalidade.src }}"> {{ row.modalidade.name }}</div>
        <div class="tag-single {{ row.cor_do_curso.name }}"><img src="{{ module.header.icon_duracao.src }}"> {{ row.duracao }}</div>
        <div class="tag-single {{ row.cor_do_curso.name }}"><img src="{{ module.header.icon_carga_horaria.src }}"> {{ row.carga_horaria }}</div>
      </div>
      
      
      {{ row.descricao_curso }}  
    </div>
    <div class="content-right">
      <div class="form-box-detail" style="background-image: url('{{ module.form.form_box_detail.src }}')"></div>
      <div class="background-box-form" style="background-image: url('{{ module.form.form_box.src }}')">        
      <div class="box-form">        
        <div class="mensalidade">
          <p>MENSALIDADE (R$)</p>
          <p class="valor {{ row.cor_do_curso.name }} promo-valor-original-{{ row.ativar_promocao.name }}">{{ row.mensalidade }}</p>
          <p class="valor {{ row.cor_do_curso.name }} promo-valor-desconto-{{ row.ativar_promocao.name }}">{{ row.mensalidade_promo }}</p>
        </div>
        <h3>{{ row.titulo_form }}</h3>
        {#{{ dynamic_page_hubdb_row.embed_form|replace('&lt;','<')|replace('&gt;','>')|replace('<p>','')|replace('</p>','') }}#}
        
        <div class="form-inscricao {{ row.tipo_form.name }}">{% inline_rich_text field="form.embed_form_inscricao" value="{{ module.form.embed_form_inscricao }}" %}</div>
        <div class="form-interesse {{ row.tipo_form.name }}">{% inline_rich_text field="form.embed_form_interesse" value="{{ module.form.embed_form_interesse }}" %}</div>
        
        <div class="legend-form">{{ row.texto_pos_form }}</div>
      </div>
      </div>
    </div>
  </div>
</div>
<!-- FIM SOBRE O CURSO + FORM -->
      
      

<!-- MERCADO DE TRABALHO -->
<div class="section-mercado-trabalho">
<div class="detail-right" style="background-image: url('{{ module.detail_right.src }}')">
  <div class="content-wrapper">
    <div class="content-left">
      <img class="lazy" src="{{ row.img_mercado_de_trabalho.url }}">
    </div>
    <div class="content-right">
      {{ row.mercado_de_trabalho }} 
      
      <div class="quanto-ganha">
        <h3>{{ row.titulo_salario }}</h3>
        <ul class="salario">
          <li><span>JÚNIOR |</span> {{ row.salario_junior }}</li>
          <li><span>PLENO |</span> {{ row.salario_pleno }}</li>
          <li><span>SÊNIOR |</span> {{ row.salario_senior }}</li>
        </ul>
        <span>{{ row.fonte_salarios }}</span>
      </div>
    </div>
  </div>
</div>
</div>
<!-- FIM MERCADO DE TRABALHO -->


<!-- MATRIZ CURRICULAR + GALERIA -->
<div class="section-matriz-curricular">
<div class="detail-left" style="background-image: url('{{ module.detail_left.src }}')">
  <div class="content-wrapper">
    <div class="content-left">
      <h2><b>MATRIZ CURRICULAR</b></h2>
      {{ row.matriz_curricular|replace('&lt;','<')|replace('&gt;','>') }}
    </div>
    <div class="content-right">
      <h2><b>CONHEÇA ONDE VOCÊ VAI ESTUDAR</b></h2>
      <div class="galeria">
        <img class="lazy" src="{{ row.galeria_foto1.url }}">
        <img class="lazy" src="{{ row.galeria_foto2.url }}">
        <img class="lazy" src="{{ row.galeria_foto3.url }}">
        <img class="lazy" src="{{ row.galeria_foto4.url }}">
      </div>
    </div>
  </div>
</div>
</div>
<!-- FIM MATRIZ CURRICULAR + GALERIA -->
  {% endfor %}
{% endif %}
      
      
    </div>
  </div>
 </div>



{% endif %} 
<!-- FIM LISTAGEM DE CURSOS -->    

 

 

0 Upvotes
1 Accepted solution
DanielSanchez
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

How to make the HubDB listing not display results

SOLVE

Hi, thanks @piersg for your attention. I will test your solution, if it works I'll be back to mark it as a solution too.

 

 

I managed to solve it as follows: I defined a parameter with a value that no product have. Thus, no product matches this parameter and no longer displays the products.

 

After selecting an option in the filter, it also changes the queryparam from the value that no product is configured, to a value that corresponds to the active products.

 

Summary: by default I left a queryparam value from the listing that doesn't exist in the products, and when you do the filter, the queryparam changes to the existing value in the products.

 

 

        {% set queryparam = "&active__eq=lp" %}
        
        {% if request.query_dict.cursofield in ["1", "2", "3", "4", "5", "6"]  %}
          {% set queryparam = "&active__eq=s" | queryparam ~ "&curso="~request.query_dict.cursofield|urlencode %}
        {% endif %}  

        {% if request.query_dict.cursofield == "show-all" %}
          {% set queryparam = queryparam ~ "&active__eq=lp" %} <!-- "..eq=s" para exibir todos cursos com active "s". LP = parâmetro feito para não exibir cursos -->
        {% endif %}

 

 

Thanks!

View solution in original post

2 Replies 2
piersg
Key Advisor

How to make the HubDB listing not display results

SOLVE

Hi @DanielSanchez, you could wrap your content (i.e. around your row in table for loop) in an if statement testing for the existence of a query parameter? That content will therefore only display if an option from your filter has been selected (including show-all).

 

{% if request.query_dict|length > 0 %}
  {% for row in table %}
  ...
  {% endfor %}
{% else %}
  <p>Por favor selecione uma opção</p>
{% endif %}

 

DanielSanchez
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

How to make the HubDB listing not display results

SOLVE

Hi, thanks @piersg for your attention. I will test your solution, if it works I'll be back to mark it as a solution too.

 

 

I managed to solve it as follows: I defined a parameter with a value that no product have. Thus, no product matches this parameter and no longer displays the products.

 

After selecting an option in the filter, it also changes the queryparam from the value that no product is configured, to a value that corresponds to the active products.

 

Summary: by default I left a queryparam value from the listing that doesn't exist in the products, and when you do the filter, the queryparam changes to the existing value in the products.

 

 

        {% set queryparam = "&active__eq=lp" %}
        
        {% if request.query_dict.cursofield in ["1", "2", "3", "4", "5", "6"]  %}
          {% set queryparam = "&active__eq=s" | queryparam ~ "&curso="~request.query_dict.cursofield|urlencode %}
        {% endif %}  

        {% if request.query_dict.cursofield == "show-all" %}
          {% set queryparam = queryparam ~ "&active__eq=lp" %} <!-- "..eq=s" para exibir todos cursos com active "s". LP = parâmetro feito para não exibir cursos -->
        {% endif %}

 

 

Thanks!