Keyword

Limiting Extra FieldsDisplay

  • CuppaJoe
  • CuppaJoe's Avatar Topic Author
  • Offline
  • New Member
  • Share The Warmth
More
10 years 8 months ago #125234 by CuppaJoe
Replied by CuppaJoe on topic Re: Limiting Extra FieldsDisplay
Thanks for the reply.

I personally prefer this method.
Although my way works, the html is still rendered, but just hidden with css, meaning the code can still be inspected if required and the hidden data found.

In my application, it does not contain sensitive information, just a way to not show some fields.

Hopefully this might be useful to others.

Regards,

Joe,

ShareTheWarmth

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

More
10 years 8 months ago #125235 by Hardkiffeur
Replied by Hardkiffeur on topic Re: Limiting Extra FieldsDisplay

Mohamed Abdelaziz wrote: @CuppaJoe

I thought in a modification to your way, that can be used in this case, without having the fields html in the document but hiding them with CSS.

You can create an array with the field ids either to show or to hide, which is shorter.
Lets assume that the shorter list is the fields to show, then the code will be like this:

<?php $fieldsToShow = array(1,5,7,13); //this is an array of fields keys/ids to show ?>
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
      <?php if(in_array($key, $fieldsToShow)): ?>
             <li class="type<?php echo ucfirst($extraField->alias); ?> group<?php echo $extraField->group; ?>">
                     <span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
                       <span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
                 </li>
      <?php endif; ?>
<?php endforeach; ?>

This way, only the html code of the fields to show will be there.
Also it easy to modify the $fieldsToShow array if you changed your mind.

+1 Simply cute ;)

And what sorte of code I've to add at the item.php for the RelatedItems block for having some extrafields Name & Value in the foreach loop ? Could not find ...

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


Powered by Kunena Forum