CMS Development

Hubmate
Mitwirkender/Mitwirkende

Can't get HubL Unique Filter to Work

lösung

Hi,

 

I'm working with the new custom modules and doing my best to integrate Googe Fonts. The user can select from 30 or so fonts and then dependant on which font is selected, that font's available weights will be displayed in another choice menu.

 

The user can then choose which weight they want for H1, H2, H3 and H4. I store the header weight selections as a HubL array and remove duplicates with the 'unique' filter . So if you imagine the user selects the following weights: H1 - 300, H2 - 300, H3 - 400, H4 - 400. I store the selections in the array like so:

 

{% set headerWeight = ['{{ module.headers.h1.weight }}','{{ module.headers.h2.weight }}','{{ module.headers.h3.weight }}','{{ module.headers.h4.weight }}'] %}

 

{{ headerWeight|unique }}

 

I would expect the array to be [300,400] but the unique filter hasn't worked and it's showing [300,300,400,400].

 

Does anyone know what I'm doing wrong? Sorry for the longwinded question.

 

Thanks,

Steve

0 Upvotes
1 Akzeptierte Lösung
Hubmate
Lösung
Mitwirkender/Mitwirkende

Can't get HubL Unique Filter to Work

lösung

I figured this out in the end. I just removed the quote marks from the HubL values and it did the trick. Like so:

 

{% set headerWeight = [{{ module.headers.h1.weight }},{{ module.headers.h2.weight }},{{ module.headers.h3.weight }},{{ module.headers.h4.weight }}] %}

Lösung in ursprünglichem Beitrag anzeigen

0 Upvotes
1 Antwort
Hubmate
Lösung
Mitwirkender/Mitwirkende

Can't get HubL Unique Filter to Work

lösung

I figured this out in the end. I just removed the quote marks from the HubL values and it did the trick. Like so:

 

{% set headerWeight = [{{ module.headers.h1.weight }},{{ module.headers.h2.weight }},{{ module.headers.h3.weight }},{{ module.headers.h4.weight }}] %}

0 Upvotes