Keyword

Restrict extra fields for guests

  • Benjamin Neubauer
  • Benjamin Neubauer's Avatar Topic Author
  • Offline
  • New Member
More
12 years 8 months ago #61854 by Benjamin Neubauer
Restrict extra fields for guests was created by Benjamin Neubauer
Hi there,

I´m trying to hide one or better more extra fields form guests.

I found this article which should be the solution but for some reason I can´t make it work:

community.getk2.org/forum/topics/restrict-extra-field-not
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
      <!-- Item extra fields -->
      <div class="k2ExtraFields">
          <h3><?php echo JText::_('Additional Info'); ?></h3>
          <ul>
            <?php foreach ($this->item->extra_fields as $key=>$extraField):?>
           
<!-- insert code to test for registared and wether or not to skip here Replace HideField2 with name of your extra field-->
 <?php $user =& JFactory::getUser(); ?>
 <?php if($extraField->name == "HideField2" && $user->get('guest') ==1) { ?>
<!-- prove it works - delete the text below after testing -->
            field omitted
           
<?php  } else { ?>
            <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
                <span class="k2ExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
                <span class="k2ExtraFieldsValue"><?php echo $extraField->value; ?></span>
            </li>

           
<?php } ?>
            <?php endforeach; ?>

I'm using J1.7.3 with k2 2.5.4

I created an override and replaced existing extra field code in the file templates/"my template"/html/com_k2/templates/"my override"/item.php with the code given in the article above.
Switching to my override all I get is a blank screen. Of course I also put in the correct name of the extra field I want to hide. Is it maybe because of the german language pack
(german expression for guest needed)? Is something missing in the code?

I would highly appreciate any help!

Thanks in advance, Ben

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

More
12 years 8 months ago #61855 by william white
Replied by william white on topic Re: Restrict extra fields for guests
Go to Global settings, turn error reporting to hightest or developer and see what the blank page error is

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

  • Benjamin Neubauer
  • Benjamin Neubauer's Avatar Topic Author
  • Offline
  • New Member
More
12 years 8 months ago #61856 by Benjamin Neubauer
Replied by Benjamin Neubauer on topic Re: Restrict extra fields for guests
Hi William, thanks for the quick reply!

Still not showing anything, also no reporting, as if the page wouldn´t exist...

Firebug only shows me:

<html>
<head></head>
<body></body>
</html>

To make sure, I didn´t do anything stupid:

I replaced the original extra field code in the item.php with the code above then changed the name of the field.

I copied the default folder "my template/html/com_k2/templates/default" and named the new one "my template/html/com_k2/templates/my override".

Then, in the category settings, I switched to "my override".

Result see above. Maybe I did something wrong?

Thanks,

Ben

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


Powered by Kunena Forum