Module, Plugin

Archived
Forum
(read-only)

Reefine

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

Back to this add-on's main page
View Other Add-ons From Patrick Woodcock

     

Search one, show two.

Support (Resolved)

MrMadsen
MrMadsen

Hey!

Just bought the EE3-version, thank you thank you thank you for updating it! :)

Anyways;

I have 1500 products, which all have three fields in them, “sizes”, “size_1” and “size_2”.
I want to filter using “sizes”, but when showing the filter to the user, I want it to show “size_1” and “size_2”.

I have read through the documentation, but can’t wrap my head around how to do this.
Any ideas on how to do this? :)

Again, thanks for upgrading to EE3, you made xmas come early :)

Ralph
# 1
Ralph

Hi.

Thanks, glad you’re finding it useful. Sorry it took a while to get round to making it compatible for EE3.

Just so I can understand what you’re trying to do, are “size_1” and “size_2” basically human readable text for the “sizes” field? If they are hardcoded you could use some {if} statements eg

...{filters}<li><a href="{url}">
{if sizes=='MS'}Medium Short{/if}
{if sizes
=='MA'}Medium Average{/if}
{if sizes
=='ML'}Medium Long{/if}
...
</
a></li>{/filters}... 

Or you could use Stash variables https://github.com/croxton/Stash/wiki/Variables to store all the types and then output them like this:

{exp:channel:entries channel="..." limit="99999" }
{exp
:stash:set name="sizes_{sizes}"}{size_1} {size_2}{exp:stash:set}
{
/exp:channel:entries} 

and then in the filters code:

...{filters}<li><a href="{url}">
{exp:stash:get name="sizes_{sizes}"}
</a></li>{/filters}... 

Hope that helps.

Edit: Added limit var

 

MrMadsen
# 2
MrMadsen

“size_1” and “size_2” are numbers fields.
“sizes” is a text field.

Example:
“sizes” == 10 x 15
“size_1” == 10
“size_2” == 15

This is done so that I can show “sizes”, but use “Size_1” to orderBy.
If I order by “sizes”, it’s 1,10,2,200,33,4,500,6 etc.
If ordered by “size_1”, I can make it 1,2,4,6,10,33,200,500

I’m using stash for this, and doing a exp:query loop.

{exp:stash:set_list parse_conditionals="no" name="consolidatedList" trim="yes" parse_tags="yes" refresh="1440"}
{exp
:query sql="SELECT DISTINCT field_id_141, field_id_26, field_id_27, field_id_142 FROM exp_channel_data"}
{if 
('{field_id_142}' != 'Mosaik') AND ('{field_id_141}' != '0x0') AND ('{field_id_141}' != '999x999')}
{stash
:storlekarNoDes}{field_id_141}{/stash:storlekarNoDes}
{
/if}
{stash
:storlek_1}{field_id_26}{/stash:storlek_1}
{stash
:storlek_2}{field_id_27}{/stash:storlek_2}
{
/exp:query}
{
/exp:stash:set_list} 

And then outputting it to reefine-flter like so:

<div class="reefine-filter-holder">
 <
h6>Storlek (cm)</h6>
 
{exp:stash:get_list
  name
="consolidatedList"
  
orderby="storlek_1"
  
sort="asc|asc"
  
unique="storlekarNoDes"
  
match='#.+#'
  
against="storlekarNoDes"
 
}
 {if count 
== 14}
  
<section class="show-more-of-sizes" style="display:none;">
 
{/if}
  
<div class="filter-name {if '{segment_4}' *= '{storlekarNoDes}'}active{/if}">
   <
a href="{site_url}keramik/index_reefine/
   {if '{segment_3}' == ''}typ{if:else}{segment_3}{/if}/
   {if '{segment_4}' == 'storlek'}{storlekarNoDes}{if:elseif '{segment_4}' == ''}{storlekarNoDes}{if:else}{segment_4}-or-{storlekarNoDes}{/if}/
   {if '{segment_5}' == ''}farg{if:else}{segment_5}{/if}/
   {if '{segment_6}' == ''}yta{if:else}{segment_6}{/if}/
   {if '{segment_7}' == ''}egenskap{if:else}{segment_7}{/if}/
   {if '{segment_8}' == ''}serie{if:else}{segment_8}{/if}/
   "
>{storlek_1} x {storlek_2}</a>
  </
div>
 
{if count == total_results}
  
</section>
 
{/if}
 {
/exp:stash:get_list}
 
<div class="show_more_sizes">Visa alla</div>
</
div

I was just wondering if there was a more reefing-way of doing it without the use of stash :)
So, problem solved, there’s not a reefing’er way :)

Thanks! :)

 

Ralph
# 3
Ralph

Hi

Ah I see. Yeah I don’t think there’s a way to do this with just Reefine at the moment. It’s a nice idea for a new feature though I could add when I get some time.

Cheers,
Patrick.

MrMadsen
# 4
MrMadsen

Well, fingers crossed! :)
I will try your thing tho, just to see if it’ll be able to do the whole “selected” and “not empty”-status’es :)

Ralph
# 5
Ralph

I’m thinking about what I can add to solve your problem. I think if there was a way to filter by multiple combined fields in the same filter this might work.  In this case the “sizes” field wouldn’t be required we can just use size_1 and size_2 which is combined. I imagine the code would look something like this. Do you think it’s what you need?

{exp:reefine ...
filter:sizes:fields="size_1|size_2"
filter:sizes:combine_fields="yes"
...}

{sizes}
{filters}
<a href="{url}">{size_1} X {size_2} </a>
{/filters}
{
/sizes}
... 

 

MrMadsen
# 6
MrMadsen

Absolutely, that looks about right.

The main thing here tho, would be to be able to order numeric, based on “size_1”.

Something like

filter:sizes:orderby="size_1|size_2"
filter:sizes:sorttype="numeric" 

I know it’s complexed as hell, but otherwise we get the whole 1, 20, 3, 400, 55, 6 instead of 1, 3, 6, 20, 55, 400.

Ralph
# 7
Ralph

Great, I’ve added that to the to-do list.  I’m not sure when I’ll have it done I’m afraid, (the todo list is getting rather long) but I’ll let you know.

MrMadsen
# 8
MrMadsen

Awesome!
Thanks, keep me posted :D