Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display extra fields in article with K2

currently I've got Jreviews installed and I'd like to replace it by K2 to list specialized shops with addresses, phones, maps, opening hours ...

With K2 I guess I'll need to define extra custom fields to hold those specific information. No problem.

But, how may I configure things to have those fields displayed in the detailed article/items for a specific shop ?

Many thanks,

Tibi.

like image 670
Tibi Avatar asked Oct 05 '10 07:10

Tibi


1 Answers

// In the item template you can skip this first line...
$this->item->extra_fields = K2ModelItem::getItemExtraFields($this->item->extra_fields);

$extraFlds = array();
if ( $this->item->extra_fields ){
  foreach ( $this->item->extra_fields as $key=>$extraField ){
     $extraFlds[ $extraField->name ] = $extraField->value;
  }
}

Then you can access your extra fields in the associate array like $extraFlds['my field']

like image 69
Hari Honor Avatar answered Sep 26 '22 08:09

Hari Honor