UCM All Field Values Output

More
3 years 7 months ago - 3 years 7 months ago #80182 by iamrobert
In FLEXIcontent Universal Content Module (UCM) - we have been outputting all the values to make a select list:

Code:
              <option value="">Choose Region</option>               <?php               $fieldname = 'region'; //REGIONS               if ( !isset( $item->fields[ $fieldname ]->parameters ) ) {                 FlexicontentFields::loadFieldConfig( $item->_row->fields[ $fieldname ], $item );               }               $extra_props = array();                $elements = FlexicontentFields::indexedField_getElements( $item->_row->fields[ $fieldname ], $item, $extra_props );               if ( !empty( $elements ) )                 foreach ( $elements as $el ) {                   if ( @unserialize( $el ) !== false || $el === 'b:0;' )$el = unserialize( $el );                   echo '<option value="' . $el->value . '">' . $el->text . '</option>';                   // var_dump($el);                   $GLOBALS[ 'pi_region_filter_list' ][ $el->value ] = $el->text;                 }               ?>




DEMO:
merits.taichungdesigner.com/dealers

This has worked well for many years.

Now, we are trying to make a store locator based on region and suburb. So, we have entered all the possible regions and suburbs in Taiwan, incase the client chooses to expand. However, many of the regions don't currently have a store at present - so the result comes up blank a lot of the time.

Is there a way to rewrite the PHP to check if the value exists before outputting it?


 
Last edit: 3 years 7 months ago by iamrobert.

Please Log in or Create an account to join the conversation.

More
3 years 6 months ago #80321 by ggppdk
Replied by ggppdk on topic UCM All Field Values Output
Hello

Displaying filtering options that exist is done in category view
you are trying to replicate something similar in Universal Content Module ?

I mean you are creating a dynamic filter of the module's items ?
 


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
3 years 6 months ago #80322 by iamrobert
Thanks for the reply.

Yes - it's dynamic. Ideally - it should only show if there is a value present, and in the field category order. For instance option 3 doesn't show because its not present.


[img


We did it here for the category for the categories on the left:
www.tokenproducts.com/bottom-brackets/press-fit
Code:
$el_1_id = $filter1_num; if(isset($items[$i]->fieldvalues[$el_1_id])){ $el_1_vals = $items[$i]->fieldvalues[$el_1_id];  }     if (!empty($el_1_vals)) foreach ($el_1_vals as $v1) {     if ( @unserialize($v1)!== false || $v1=== 'b:0;' ) $v1 = unserialize($v1);     echo ' one'.$v1; }

The links on the left we hid via js:
Code:
    $("#bws-techfilter input:not(.all), #panel1a input:not(.all), #panel2a input:not(.all), #panel3a input:not(.all), #panel4a input:not(.all), #panel5a input:not(.all), #panelcollection input:not(.all)").each(function () {       //  console.log($(this).val());       if ($($(this).val()).length === 0) {         $(this).css("display", "none");         var name = $(this).val().replace(".", "");         $('label[for="' + name + '"]').css("display", "none");       }     });

But it shows dynamically in the category items on the right. Does that make sense?



 

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.758 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline