- Posts: 7
COMMUNITY FORUM
restrict extra field not registred users
- kolmao
- Topic Author
- Offline
- New Member
Less
More
13 years 2 months ago #98492
by kolmao
Replied by kolmao on topic restrict extra field not registred users
It does not work, I'm afraid it is not possible
Please Log in or Create an account to join the conversation.
- BBC
- Offline
- Platinum Member
Less
More
- Posts: 663
13 years 2 months ago #98493
by BBC
Replied by BBC on topic restrict extra field not registred users
This one hides all fields depending if User is logged in, or not.
Try to work with it and make it work for one extra field. Maybe solution is to disable automatic listing od all fields then call tehm all one by one, and remove one special for Guests.
<?php$user =& JFactory::getUser(); if($user->get('guest') == 0) : ?> <?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?> <?php endif; ?>
Try to work with it and make it work for one extra field. Maybe solution is to disable automatic listing od all fields then call tehm all one by one, and remove one special for Guests.
<?php$user =& JFactory::getUser(); if($user->get('guest') == 0) : ?> <?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?> <?php endif; ?>
Please Log in or Create an account to join the conversation.
- kolmao
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
13 years 2 months ago #98494
by kolmao
Replied by kolmao on topic restrict extra field not registred users
@BBC Thanks for your help
I'm not sure how to do that
This is the loop code
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?> <!-- Item extra fields -->
<div class="itemExtraFields">
<h3><?php echo JText::_('Additional Info'); ?></h3>
<ul>
<?php foreach ($this->item->extra_fields as $key=>$extraField):?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<br class="clr" />
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
</div>
Where should I insert the code you posted?
I'm not sure how to do that
This is the loop code
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?> <!-- Item extra fields -->
<div class="itemExtraFields">
<h3><?php echo JText::_('Additional Info'); ?></h3>
<ul>
<?php foreach ($this->item->extra_fields as $key=>$extraField):?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<br class="clr" />
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
</div>
Where should I insert the code you posted?
Please Log in or Create an account to join the conversation.
- BBC
- Offline
- Platinum Member
Less
More
- Posts: 663
13 years 2 months ago #98495
by BBC
Replied by BBC on topic restrict extra field not registred users
Just wrap this (already in item.php):
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
With this "User" code.
But it is just for testing. It works. I used2 browsers, one logged, another not. One show fields for logged, one don´´t.
I cannot make it work for just one field. Mybe you will have better luck.
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
With this "User" code.
But it is just for testing. It works. I used2 browsers, one logged, another not. One show fields for logged, one don´´t.
I cannot make it work for just one field. Mybe you will have better luck.
Please Log in or Create an account to join the conversation.
- BBC
- Offline
- Platinum Member
Less
More
- Posts: 663
13 years 2 months ago #98496
by BBC
Replied by BBC on topic restrict extra field not registred users
Don´t forget
<?php endif; ?>
when you test.
<?php endif; ?>
when you test.
Please Log in or Create an account to join the conversation.
- BBC
- Offline
- Platinum Member
Less
More
- Posts: 663
13 years 2 months ago #98497
by BBC
Replied by BBC on topic restrict extra field not registred users
Because of that i said maybe is good idea to remove original part of code for fields and liste them one by one.
With this code above you can easy hide "div" and "class".
One extra filed = one div/class.
With this code above you can easy hide "div" and "class".
One extra filed = one div/class.
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
13 years 2 months ago #98498
by william white
Replied by william white on topic restrict extra field not registred users
Sorry i havent gotten back to you, i have been buzy at work. I have the code you want almost working and will post it when it is working.
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
13 years 2 months ago #98499
by william white
Replied by william white on topic restrict extra field not registred users
This will work
<?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; ?>
<?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; ?>
Please Log in or Create an account to join the conversation.
- kolmao
- Topic Author
- Offline
- New Member
Less
More
- Posts: 7
13 years 2 months ago #98500
by kolmao
Replied by kolmao on topic restrict extra field not registred users
Great work Willian,
Now hides only the specified field.
Thank you very much, now everything is perfect.
Now hides only the specified field.
Thank you very much, now everything is perfect.
Please Log in or Create an account to join the conversation.
- BBC
- Offline
- Platinum Member
Less
More
- Posts: 663
13 years 2 months ago #98501
by BBC
Replied by BBC on topic restrict extra field not registred users
Thanks. It will be usefull sometimes.
Please Log in or Create an account to join the conversation.