Keyword

Change K2 Item view for Extra Fields

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
6 years 3 weeks ago #167353 by George Nasis
Change K2 Item view for Extra Fields was created by George Nasis
Hallo,

I am trying to build something like that of the attached image.

To be more specific I want to to build a K2 Item view for a override of a template which will show recipes.

I need two extra fields to be displayed in different way, like the image.

Is this possible?

thank you

image attachment

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 3 weeks ago #167364 by Krikor Boghossian
Replied by Krikor Boghossian on topic Change K2 Item view for Extra Fields
Yes,

You can render each field separately and add the markup and styling you want.
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L168-L173

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
6 years 2 weeks ago #167407 by George Nasis
Replied by George Nasis on topic Change K2 Item view for Extra Fields
Hallo Krikor!

Thank you for the cheesheet!

I read it but I cannot figure out how to do what I want. To be more specific I want to display many values of an extra field type to a list. For example

Ingredient A
Ingredient B
Ingredient C

of an extra field called Ingredients (but what type?)

I have written this code
<?php $ingredients='';
	if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
		<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
			<?php if($extraField->value != '' && $extraField->name=='Ingredients') $ingredients = $extraField->value; ?>
		<?php endforeach; ?>
		<?php
		$ingredient = explode(';',$ingredients);
		$ingredients='';
		foreach($ingredient as $value){
			$ingredients.='<li>'.$value.'</li>';
		}
		?>
	<?php endif; ?>

and to display them this one
<div class="menuCustEx clearfix">
		<div class="perc50 pull-left">
			<h3 class="st-page-heading">Ingredients</h3>
			<ul class="check">
				<?php
					echo $ingredients;
				?>	  			
			</ul>	
		</div>
	</div>

But It is not working as I was expecting..

Am I missing something?A specific extra field type to insert multiple values?

Thank you a lot

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 2 weeks ago #167418 by Krikor Boghossian
Replied by Krikor Boghossian on topic Change K2 Item view for Extra Fields
What is $ingredients or var_dump($ingredients) showing you?
What does the raw value of the extrafield printing?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • George Nasis
  • George Nasis's Avatar Topic Author
  • Offline
  • Elite Member
More
6 years 2 weeks ago #167434 by George Nasis
Replied by George Nasis on topic Change K2 Item view for Extra Fields
Hi Krikor,

many thanks for your interest.

It was so easy finally..I had just to add the li tags of every ingredient and to add rows at the extra field properties (I used textarea) :D :D :D

I give this info if someone else wants to achieve this

Thanks again!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
6 years 2 weeks ago #167444 by Krikor Boghossian
Replied by Krikor Boghossian on topic Change K2 Item view for Extra Fields
Kudos George!!

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum