Hi There,
I am looking for some thoughts or help with adding specific extra fields to my generic.php
I have searched the forum, and it seems like there is one discussion of it, but it looks a little old as it talks about adding extra fields ( and names) in general. When I looked at the generic template (and activate the option in parameters ) I can get field names and values in my generic.php item list.. all of them, which is great, but my problem is, that I only want two of the fields on the generic list view. ( Namely a date and a venue name )
I have managed to achive this finction and pnly display the fields I want in a specific catagory list view by modifying the category_item.php and specifying for each field (by ID) that I want to display:
<span class="catItemExtraFieldsLabel"><?php echo $this->item->extra_fields[0]->name; ?></span>
But when I try to replicate this code in my generic.php I get no values at all.. Obviously, I am missing something.. oh.. And I am no php coder! I can 'generally' follow along but!! I am hoping someone can look at what I have done and give me some pointers.
Here is the orogional code from generic.php :
<?php if($item->params->get('genericItemExtraFields') && count($item->extra_fields)): ?> <div class="genericItemExtraFields"> <h4><?php echo JText::_('Additional Info'); ?></h4> <ul> <?php foreach ($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="genericItemExtraFieldsLabel"><?php echo $extraField->name; ?></span> <span class="genericItemExtraFieldsValue"><?php echo $extraField->value; ?></span> </li> <?php endforeach; ?> </ul> <div class="clr"></div> </div> <?php endif; ?>
Here is my go at it ( to just dispaly fields 0 and 1 ):
<?php if($item->params->get('genericItemExtraFields') && count($item->extra_fields)): ?> <div class="genericItemExtraFields"> <ul> <li> <span class="catItemExtraFieldsLabel"><?php echo $this->item->extra_fields[0]->name; ?></span> <span class="catItemExtraFieldsValue"><?php echo $this->item->extra_fields[0]->value; ?></span> </li> <li> <span class="catItemExtraFieldsLabel"><?php echo $this->item->extra_fields[1]->name; ?></span> <span class="catItemExtraFieldsValue"><?php echo $this->item->extra_fields[1]->value; ?></span> </li> </ul> <div class="clr"></div> </div> <?php endif; ?>
The formatting I can deal with, but I am just no getting any values through, and when I look at my code for category_item that IS working.( Thanks to searching the forums : )...
<?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?> <!-- Item extra fields --> <div class="catItemExtraFields"> <h3>Event Details</h3> <ul> <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>"> <span class="catItemExtraFieldsLabel"><?php echo $this->item->extra_fields[0]->name; ?></span> <span class="catItemExtraFieldsValue"><?php echo $this->item->extra_fields[0]->value; ?></span> </li> <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>"> <span class="catItemExtraFieldsLabel"><?php echo $this->item->extra_fields[2]->name; ?></span> <span class="catItemExtraFieldsValue"><?php echo $this->item->extra_fields[2]->value; ?></span> </li>
</ul>
<div class="clr"></div> </div> <?php endif; ?>
So my attempt at the generic.php looks pretty close as far as I can see: I can see that the params are different, but the count is the same... The code is the classes is not a problems as far as I can tell.. Yes, Ive removed the loop, but I am specifting the extra_fields[id]...
As I siad, I am obviously missing something so any throughts would be appreaciated.
I am looking for some thoughts or help with adding specific extra fields to my generic.php
I have searched the forum, and it seems like there is one discussion of it, but it looks a little old as it talks about adding extra fields ( and names) in general. When I looked at the generic template (and activate the option in parameters ) I can get field names and values in my generic.php item list.. all of them, which is great, but my problem is, that I only want two of the fields on the generic list view. ( Namely a date and a venue name )
I have managed to achive this finction and pnly display the fields I want in a specific catagory list view by modifying the category_item.php and specifying for each field (by ID) that I want to display:
<span class="catItemExtraFieldsLabel"><?php echo $this->item->extra_fields[0]->name; ?></span>
But when I try to replicate this code in my generic.php I get no values at all.. Obviously, I am missing something.. oh.. And I am no php coder! I can 'generally' follow along but!! I am hoping someone can look at what I have done and give me some pointers.
Here is the orogional code from generic.php :
<?php if($item->params->get('genericItemExtraFields') && count($item->extra_fields)): ?> <div class="genericItemExtraFields"> <h4><?php echo JText::_('Additional Info'); ?></h4> <ul> <?php foreach ($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="genericItemExtraFieldsLabel"><?php echo $extraField->name; ?></span> <span class="genericItemExtraFieldsValue"><?php echo $extraField->value; ?></span> </li> <?php endforeach; ?> </ul> <div class="clr"></div> </div> <?php endif; ?>
Here is my go at it ( to just dispaly fields 0 and 1 ):
<?php if($item->params->get('genericItemExtraFields') && count($item->extra_fields)): ?> <div class="genericItemExtraFields"> <ul> <li> <span class="catItemExtraFieldsLabel"><?php echo $this->item->extra_fields[0]->name; ?></span> <span class="catItemExtraFieldsValue"><?php echo $this->item->extra_fields[0]->value; ?></span> </li> <li> <span class="catItemExtraFieldsLabel"><?php echo $this->item->extra_fields[1]->name; ?></span> <span class="catItemExtraFieldsValue"><?php echo $this->item->extra_fields[1]->value; ?></span> </li> </ul> <div class="clr"></div> </div> <?php endif; ?>
The formatting I can deal with, but I am just no getting any values through, and when I look at my code for category_item that IS working.( Thanks to searching the forums : )...
<?php if($this->item->params->get('catItemExtraFields') && count($this->item->extra_fields)): ?> <!-- Item extra fields --> <div class="catItemExtraFields"> <h3>Event Details</h3> <ul> <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>"> <span class="catItemExtraFieldsLabel"><?php echo $this->item->extra_fields[0]->name; ?></span> <span class="catItemExtraFieldsValue"><?php echo $this->item->extra_fields[0]->value; ?></span> </li> <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>"> <span class="catItemExtraFieldsLabel"><?php echo $this->item->extra_fields[2]->name; ?></span> <span class="catItemExtraFieldsValue"><?php echo $this->item->extra_fields[2]->value; ?></span> </li>
</ul>
<div class="clr"></div> </div> <?php endif; ?>
So my attempt at the generic.php looks pretty close as far as I can see: I can see that the params are different, but the count is the same... The code is the classes is not a problems as far as I can tell.. Yes, Ive removed the loop, but I am specifting the extra_fields[id]...
As I siad, I am obviously missing something so any throughts would be appreaciated.