Keyword

restrict extra field not registred users

  • kolmao
  • kolmao's Avatar Topic Author
  • Offline
  • New Member
More
13 years 10 months ago #98482 by kolmao
I need restrict one extra field (price of article) to all users not registres in the site. Its possible?

 

Thanks in advance,

 

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

More
13 years 10 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
  • kolmao's Avatar Topic Author
  • Offline
  • New Member
More
13 years 10 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.

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

More
13 years 10 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

 

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

  • kolmao
  • kolmao's Avatar Topic Author
  • Offline
  • New Member
More
13 years 10 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

 

 

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

More
13 years 10 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
  • kolmao's Avatar Topic Author
  • Offline
  • New Member
More
13 years 10 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...

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

More
13 years 10 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.

More
13 years 10 months ago #98490 by BBC
@ 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..

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

More
13 years 10 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

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

  • kolmao
  • kolmao's Avatar Topic Author
  • Offline
  • New Member
More
13 years 10 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.

More
13 years 10 months ago #98493 by BBC
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; ?>

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

  • kolmao
  • kolmao's Avatar Topic Author
  • Offline
  • New Member
More
13 years 10 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?

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

More
13 years 10 months ago #98495 by BBC
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.

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

More
13 years 10 months ago #98496 by BBC
Don´t forget

<?php endif; ?>

when you test.

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

More
13 years 10 months ago #98497 by BBC
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.

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

More
13 years 10 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.

More
13 years 10 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; ?>
Attachments:

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

  • kolmao
  • kolmao's Avatar Topic Author
  • Offline
  • New Member
More
13 years 10 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.

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

More
13 years 9 months ago #98501 by BBC
Thanks. It will be usefull sometimes.

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


Powered by Kunena Forum