- Posts: 21
COMMUNITY FORUM
Extra Fields?
- jmcruznet
-
Topic Author
- Offline
- Junior Member
Please Log in or Create an account to join the conversation.
- Yiota
-
- Visitor
Please Log in or Create an account to join the conversation.
- jmcruznet
-
Topic Author
- Offline
- Junior Member
- Posts: 21
Please Log in or Create an account to join the conversation.
- Yiota
-
- Visitor
Then open item.php and locate the following block.
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?> <!-- Item extra fields --> <div class="itemExtraFields"> <h3><?php echo JText::_('K2_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->type=='date')?JHTML::_('date', $extraField->value, JText::_('K2_DATE_FORMAT_LC')):$extraField->value; ?></span> </li> <?php endforeach; ?> </ul> <div class="clr"></div> </div> <?php endif; ?>
Replace it with this one and change the bolded part with your own.
<?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?> <!-- Item extra fields --> <div class="itemExtraFields"> <h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3> <ul> <?php foreach ($this->item->extra_fields as $key=>$extraField): ?> <?php if ($extraField->id=='EXTRAFIELD_PRICE_ID'): echo ''; ?> <?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; ?>
Make sure that the first block matches the one I have pasted, which is of the default K2 template. If you have made changes, make the appropriate ones to the new code as well. All you need to pay attention to is the if part.
Please Log in or Create an account to join the conversation.
- jmcruznet
-
Topic Author
- Offline
- Junior Member
- Posts: 21
function extraFields(){ $mainframe = &JFactory::getApplication(); $itemID=JRequest::getInt('cid',NULL); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $catid = JRequest::getVar('id'); $category = & JTable::getInstance('K2Category', 'Table'); $category->load($catid); require_once(JPATH_COMPONENT_ADMINISTRATOR.DS.'models'.DS.'extrafield.php'); $extraFieldModel= new K2ModelExtraField; $extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup); $output='<table class="admintable" id="extraFields">'; $counter=0; if (count($extraFields)){ foreach ($extraFields as $extraField){ $output.='<tr><td align="right" class="key">'.$extraField->name.'</td>'; $output.='<td>'.$extraFieldModel->renderExtraField($extraField,$itemID).'</td></tr>'; $counter++; } } $output.='</table>';
Please Log in or Create an account to join the conversation.
- Yiota
-
- Visitor
Please Log in or Create an account to join the conversation.
- jmcruznet
-
Topic Author
- Offline
- Junior Member
- Posts: 21
So if my PRICE ID is 1, ill change the bold part to <?php if ($extraField->id=='1'): echo ''; ?> ? Because i tried already both but still the price field doesn't show-up on the table. =/
Please Log in or Create an account to join the conversation.
- Yiota
-
- Visitor
Please Log in or Create an account to join the conversation.
- jmcruznet
-
Topic Author
- Offline
- Junior Member
- Posts: 21
Please Log in or Create an account to join the conversation.
- jmcruznet
-
Topic Author
- Offline
- Junior Member
- Posts: 21
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
- Posts: 3722
Please Log in or Create an account to join the conversation.
- jmcruznet
-
Topic Author
- Offline
- Junior Member
- Posts: 21
William White said:
williamwhitejr.com/index.php?option=com_k2&view=item&...
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
- Posts: 3722
Please Log in or Create an account to join the conversation.
- jmcruznet
-
Topic Author
- Offline
- Junior Member
- Posts: 21
<?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
-
Topic Author
- Offline
- Junior Member
- Posts: 21
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
- Posts: 3722
Please Log in or Create an account to join the conversation.
- jmcruznet
-
Topic Author
- Offline
- Junior Member
- Posts: 21
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
-
Topic Author
- Offline
- Junior Member
- Posts: 21
Please Log in or Create an account to join the conversation.
- jmcruznet
-
Topic Author
- Offline
- Junior Member
- Posts: 21
<?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.