Advertisement:

Author Topic: Custom Attributes hide checkbox  (Read 1736 times)

kurt

  • Newbie
  • *
  • Posts: 2
Custom Attributes hide checkbox
« on: January 13, 2015, 01:51:09 pm »
Hello,

it is possible to display the checkbox only when is selected.
Currently, yes or no is displayed.
Because of that I have 3 big selection option, and it looks not good when all is only with no Displayed.

Here is the code from item_detail_fields.php.

<?php
$hide_empty = osc_get_preference('hide_empty', CA_PLUGIN_NAME);
foreach ($fields as $field) {
   $type = $field['s_type'];
   $label = $field['s_label'];
   $value = Attributes::newInstance()->getValue($item_id, $field['pk_i_id']);
   if (!empty($hide_empty) && 'hide' == $hide_empty) {
      if ('checkbox' != $type && '' == trim($value)) {
         continue;
      }
   }   
   if ($type == 'checkbox') {
      if ($value == 'checked') $value = 'Yes';
      else $value = 'No';
   }
?>

Thanks and best regards Kurt

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom Attributes hide checkbox
« Reply #1 on: January 13, 2015, 03:12:18 pm »
Hi,

Replace:

Code: [Select]
if ('checkbox' != $type && '' == trim($value)) {
         continue;
      }

with

Code: [Select]
continue;
Of course you need to check "Hide empty attributes" on Settings & Help menu.

Regards
« Last Edit: January 13, 2015, 03:15:17 pm by teseo »

kurt

  • Newbie
  • *
  • Posts: 2
Re: Custom Attributes hide checkbox
« Reply #2 on: January 13, 2015, 07:20:22 pm »
Hello teseo,

Thank you for the quick reply.

That's my problem: Of course you need to check "Hide empty attributes" on Settings & Help menu.

Is there a guide.

regards Kurt

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom Attributes hide checkbox
« Reply #3 on: January 13, 2015, 07:51:59 pm »
You're welcome :)

No guide, I'm afraid. Check the official thread of the plugin and for a bunch of specific solutions for some things, use the forum search bar.

Regards

PS.- If my answer solved your problem, please add [SOLVED] to the title of this thread.

monah

  • Full Member
  • ***
  • Posts: 223
Re: Custom Attributes hide checkbox
« Reply #4 on: June 04, 2015, 09:52:52 pm »
and replace the code as it is written in the top, but then disappear completely all the attributes?
Code: [Select]
<?php
if ( !defined('ABS_PATH') ) { 
exit('ABS_PATH is not loaded. Direct access is not allowed.');
}
?>

<table class="sss">
<tbody>
<?php 
$hide_empty 
osc_get_preference('hide_empty'CA_PLUGIN_NAME);
foreach (
$fields as $field) {
$type $field['s_type'];
$label $field['s_label'];
$value Attributes::newInstance()->getValue($item_id$field['pk_i_id']);
if (!empty($hide_empty) && 'hide' == $hide_empty) {
continue;
}
if ($type == 'checkbox') {
if ($value == 'checked'$value 'Yes';
else $value 'No';
}
?>

<tr class="ddd">
<td class='detail_label'><?php echo $label?></td>
<td class='detail_label1'><?php echo $value?></td>
</tr>
<?php ?>
</tbody>
</table>
<?php //END
------------------------------
ie I want to see if the checkbox is not selected, so as not to appear in item.php
« Last Edit: June 04, 2015, 10:08:55 pm by monah »

monah

  • Full Member
  • ***
  • Posts: 223
Re: Custom Attributes hide checkbox
« Reply #5 on: June 05, 2015, 01:00:13 pm »
I found a solution, or rather I helped me in one forum
Code: [Select]
<?php
if ( !defined('ABS_PATH') ) { 
    exit(
'ABS_PATH is not loaded. Direct access is not allowed.');
}
?>

    <table class="sss">
        <tbody>
<?php 
$hide_empty 
osc_get_preference('hide_empty'CA_PLUGIN_NAME);
foreach (
$fields as $field):
   
$value Attributes::newInstance()->getValue($item_id$field['pk_i_id']);
   if (!empty(
$hide_empty) && 'hide' == $hide_empty) {
      if (
'checkbox' != $field['s_type'] && '' == trim($value)) {
         continue;
      }
   }   
   if (
$field['s_type'] == 'checkbox' && $value != 'checked')
       continue;
?>

    <tr class="ddd">
        <td class='detail_label'><?=$field['s_label']?></td>
        <td class='detail_label1'><?=$value?></td>
    </tr>
<?php endforeach; ?>
        </tbody>
    </table>
<?php //END