- Posts: 7
COMMUNITY FORUM
restrict extra field not registred users
- kolmao
- Topic Author
- Offline
- New Member
Less
More
13 years 2 months ago #98482
by kolmao
restrict extra field not registred users was created by kolmao
I need restrict one extra field (price of article) to all users not registres in the site. Its possible?
Thanks in advance,
Thanks in advance,
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 #98483
by william white
Replied by william white on topic restrict extra field not registred users
You can create an override of either the category view or the item view, whichever your using or both, and usethis method to hide the content of an extra field
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 #98484
by kolmao
Replied by kolmao on topic restrict extra field not registred users
Thanks for your reply.
But insert this code
<?php $user =& JFactory::getUser(); ?>
<?php if($user->get('guest') ==0 ): ?>
--- extra fields code ....
<?php endif; ?>
Dont hide all the fields? I need only hide the field of price to guest, but they can see the rest of fields.
But insert this code
<?php $user =& JFactory::getUser(); ?>
<?php if($user->get('guest') ==0 ): ?>
--- extra fields code ....
<?php endif; ?>
Dont hide all the fields? I need only hide the field of price to guest, but they can see the rest of fields.
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 #98485
by william white
Replied by william white on topic restrict extra field not registred users
Put the jfactory statement above the foreach loop
inside the foreach loop first test for this->extrafield->name = 'name'
then test if the user is guest
show it if not guest
else
show it
endif
endif
endforeach
inside the foreach loop first test for this->extrafield->name = 'name'
then test if the user is guest
show it if not guest
else
show it
endif
endif
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 #98486
by kolmao
Replied by kolmao on topic restrict extra field not registred users
Thanks again,
Can you tell me the code for test the field name?, I dont know this
Thank you very much for your help
Can you tell me the code for test the field name?, I dont know this
Thank you very much for your help
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 #98487
by william white
Replied by william white on topic restrict extra field not registred users
something like <?php if($extraField->name == 'YourFieldName'): ?> should work
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 #98488
by kolmao
Replied by kolmao on topic restrict extra field not registred users
This is the code whith the new lines:
<?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 $user =& JFactory::getUser(); ?>
<?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; ?>">
<?php if($extraField->name == 'Price'): ?>
<?php $user =& JFactory::getUser(); ?>
<?php if($user->get('guest') ==0 ): ?>
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<br class="clr" />
<?php endif; ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
But now, with user logged, show only the "Price" and whith guests hide all fields
Sorry for the inconvenience...
<?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 $user =& JFactory::getUser(); ?>
<?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; ?>">
<?php if($extraField->name == 'Price'): ?>
<?php $user =& JFactory::getUser(); ?>
<?php if($user->get('guest') ==0 ): ?>
<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
<br class="clr" />
<?php endif; ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
But now, with user logged, show only the "Price" and whith guests hide all fields
Sorry for the inconvenience...
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 #98489
by william white
Replied by william white on topic restrict extra field not registred users
please see friend request and pm me
Please Log in or Create an account to join the conversation.
- BBC
- Offline
- Platinum Member
Less
More
- Posts: 663
13 years 2 months ago #98490
by BBC
Replied by BBC on topic restrict extra field not registred users
@ William, why such hush-hush attitude ?
It is not first time you help someone through private messages. Write it here in public. It can help someone other..
It is not first time you help someone through private messages. Write it here in public. It can help someone other..
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 #98491
by william white
Replied by william white on topic restrict extra field not registred users
@bbc - I dont have hush hush....Im not quite as fast as others, so i like to get the entire file or links to the page sometimes so i can test it...and i dont want to ask for access etc in the forum.
@kolmao I think if you combine the statements into something like
<?php if($extraField->name == 'Price' && $user->get('guest') ==0 ): ?>
it will work for you (not tested)
Lots of good help with phphere
@kolmao I think if you combine the statements into something like
<?php if($extraField->name == 'Price' && $user->get('guest') ==0 ): ?>
it will work for you (not tested)
Lots of good help with phphere
Please Log in or Create an account to join the conversation.