Advertisement:

Author Topic: Custom field compare in if statement  (Read 995 times)

geo78

  • Full Member
  • ***
  • Posts: 100
Custom field compare in if statement
« on: October 06, 2015, 10:33:35 pm »
Hi,

Im using the following code to check a custom field's value so i can change css  :

Code: [Select]
<?php $custom_field = array();
            if( 
osc_count_item_meta() >= ) { 
                    while ( 
osc_has_item_meta() ) { 
                        if(
osc_item_meta_value() !="") {
            
$custom_field_name[osc_item_meta_slug()] = osc_item_meta_name();
            
$custom_field_value[osc_item_meta_slug()] = osc_item_meta_value();
                        }
                    }
?>

<?php $tipos trim($custom_field_value['typos_aggelias']); ?>
<?php if ($tipos == 'Πώληση') { ?>
              <div class="eidos_aggelias_polisi"><strong><?php echo $custom_field_value['typos_aggelias'] ;?></strong></div>
              <?php ?>
<?php if ($tipos == 'Ζήτηση') { ?>
              <div class="eidos_aggelias_zitisi"><strong><?php echo $custom_field_value['typos_aggelias'] ;?></strong></div>
              <?php ?>
<?php if ($tipos == 'Ανταλλαγή') { ?>
              <div class="eidos_aggelias_antallagi"><strong><?php echo $custom_field_value['typos_aggelias'] ;?></strong></div>
              <?php ?>

Even though $tipos is 'Πώληση' ( I can see it in every ad if I echo $tipos before the if statements), the echo in first if is not triggered.

Anyone have an idea why its not working?

George

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom field compare in if statement
« Reply #1 on: October 07, 2015, 12:54:30 am »
Hi,

I'm getting "&Pi;ώ&lambda;&eta;&sigma;&eta;" as custom field value, instead of Πώληση. Try this way:

Code: [Select]
<?php

$custom_field_name
[osc_item_meta_slug()] = osc_item_meta_name();
// $custom_field_value[osc_item_meta_slug()] = osc_item_meta_value();
$custom_field_value[osc_item_meta_slug()] = html_entity_decode(osc_item_meta_value());

Regards
« Last Edit: October 07, 2015, 12:56:18 am by teseo »