Keyword

Extra Fields?

More
13 years 2 weeks ago #99878 by william white

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

  • jmcruznet
  • jmcruznet's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 2 weeks ago #99879 by jmcruznet
Replied by jmcruznet on topic Extra Fields?
This is the item.php from templates/html/com_k2?

William White said:
williamwhitejr.com/index.php?option=com_k2&view=item&amp...

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

More
13 years 2 weeks ago #99880 by william white
Replied by william white on topic Extra Fields?
Yes, best to put it in an override directory so changes wont be lost if you reinstall k2

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

  • jmcruznet
  • jmcruznet's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 2 weeks ago #99881 by jmcruznet
Replied by jmcruznet on topic Extra Fields?
It's giving me an error. I made a few tweaks though.

 

<?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):?>            <!-- 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(); ?> <strong><?php if($extraField->name == "Price" && $user->get('guest') ==1) { ?></strong> <!-- 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="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>                    <span class="itemExtraFieldsValue"><?php echo ($extraField->type=='date')?JHTML::_('date', $extraField->value, JText::_('K2_DATE_FORMAT_LC')):$extraField->value; ?></span>                </li>                <?php endif; ?>            <?php endforeach; ?>            </ul>        <div class="clr"></div>      </div>      <?php endif; ?>

 

The error is Parse error: syntax error, unexpected T_ENDIF

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

  • jmcruznet
  • jmcruznet's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 2 weeks ago #99882 by jmcruznet
Replied by jmcruznet on topic Extra Fields?
I figured out the error. But the extra-field is still showing to Guest users, I'm guessing it's my extra_field name.. How do i find or know my extra_field_name if i named it Price? Thanks in advance for everything too.

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

More
13 years 2 weeks ago #99883 by william white
Replied by william white on topic Extra Fields?
check the spelling and capitalization of the extra field name

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

  • jmcruznet
  • jmcruznet's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 2 weeks ago #99884 by jmcruznet
Replied by jmcruznet on topic Extra Fields?
How do i find my extra field name? I named my custom field 'Price'.

I already have tried changing the name to this:


<strong><?php if($extraField->name == "Price" && $user->get('Guest') ==1): ?></strong>
<strong><?php if($extraField->name == "itemExtraFields" && $user->get('Guest') ==1): ?></strong>
<strong><?php if($extraField->name == "itemExtraFieldsValue" && $user->get('Guest') ==1): ?></strong>

Nothing worked..

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

  • jmcruznet
  • jmcruznet's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 2 weeks ago #99885 by jmcruznet
Replied by jmcruznet on topic Extra Fields?
any idea? anyone?

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

  • jmcruznet
  • jmcruznet's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 2 weeks ago #99886 by jmcruznet
Replied by jmcruznet on topic Extra Fields?
I got it! Thanks a Billion! anyway, here's the refined code for your code William White:

 

<?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):?>

<?php $user =& JFactory::getUser(); ?><?php if ($user->guest): ($extraField->name == "itemExtraFields")?>

<?php else: ?>                   <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->type=='date')?JHTML::_('date', $extraField->value, JText::_('K2_DATE_FORMAT_LC')):$extraField->value; ?></span>                </li>                <?php endif; ?>            <?php endforeach; ?>            </ul>        <div class="clr"></div>      </div>      <?php endif; ?>

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


Powered by Kunena Forum