- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Can't get HubL Unique Filter to Work
SOLVEFeb 8, 2018 5:34 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Accepted Solutions
Feb 12, 2018 12:43 PM - edited Feb 12, 2018 12:44 PM
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 }}] %}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content