Keyword

[SOLVED] Extra fields groups in different places

More
8 years 7 months ago #147755 by Kewwel Oliveira
Replied by Kewwel Oliveira on topic [SOLVED] Extra fields groups in different places
How to display separate groups on the item page?
Which code for this? I remember there was one that showed only the result of the field. I needed that exhibits the entire group.

prntscr.com/8k1w7k

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 7 months ago #147768 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] Extra fields groups in different places
You cannot actually.
One group per K2 category can only be assigned.
You can however render specific sets extrafields in our template

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

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

More
8 years 5 months ago #149592 by Kewwel Oliveira
Replied by Kewwel Oliveira on topic [SOLVED] Extra fields groups in different places
I forgot to mention that I'm using k2v3.

How to Display in a particular area, only one group?

I have 3 groups with 20 field types each, if I set this manually will take a lot of work.

I tried several times to edit the code of extra fields, but without success.

I believe that with this implement, we can have better templates to specific sites of real estate, cars and directories.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #149608 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] Extra fields groups in different places
<?php foreach ($this->item->extraFieldsGroups as $extraFieldGroup): ?>
	  	<h4><?php echo $extraFieldGroup->name; ?></h4>
	  	<ul>
			<?php foreach ($extraFieldGroup->fields as $key=>$extraField): ?>
			<?php if($extraField->output): ?>
			<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->output; ?></span>
			</li>
			<?php endif; ?>
			<?php endforeach; ?>
		</ul>
		<?php endforeach; ?>

As you can see each group is rendered sequentially.
You can check the groups's id and depending on the group's id render (or don't) the fields.

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

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

More
8 years 5 months ago #149615 by Kewwel Oliveira
Replied by Kewwel Oliveira on topic [SOLVED] Extra fields groups in different places
Yes, I am using this code. Where it that I set the group id? I am newbie php, sorry.
It is this part that I can not to set to display only one group and not three.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #149629 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] Extra fields groups in different places
Checking $extraFieldGroup->id == ID will do the trick.

Eg:

[/code]
<?php foreach ($this->item->extraFieldsGroups as $extraFieldGroup):
$extraFieldGroup->id == ID:
// Regular loop
endif;
endforeach;
?>
[/code]

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

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

More
8 years 5 months ago #149642 by Kewwel Oliveira
Replied by Kewwel Oliveira on topic [SOLVED] Extra fields groups in different places
I inserted this code, but not works. I changed ID for 2 ( ID of group).
I do correctly?

[/code]
<?php foreach ($this->item->extraFieldsGroups as $extraFieldGroup):
$extraFieldGroup->id == 2:
// Regular loop
endif;
endforeach;
?>
[/code]

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #149656 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] Extra fields groups in different places
This is just a dummy code, if you entered the correct code (proper if/ then/ else) then it should work fine.

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

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

More
8 years 5 months ago #149663 by Kewwel Oliveira
Replied by Kewwel Oliveira on topic Extra fields groups in different places
Excuse me Krikor, but as I said earlier I am new to php and still do not understand anything, so the difficulty. My strong it is only css.
I copied your code and just changed the ID for the group id. K2 kept the original code, but still did not work. I have 3 groups with id's 1-3.
I tried to use this: [code} <? Php echo $ extraFieldGroup [2];?> [/ Code]

I know I am abusing your good will, but what is the code ready to make this happen?

Excuses and thank you for your attention

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 5 months ago #149675 by Krikor Boghossian
Replied by Krikor Boghossian on topic Extra fields groups in different places
This is the code that you should use:
<?php foreach ($this->item->extraFieldsGroups as $extraFieldGroup): ?>
<?php if($extraFieldGroup->id == 2): ?>
	<h4><?php echo $extraFieldGroup->name; ?></h4>
	<ul>
	<?php foreach ($extraFieldGroup->fields as $key=>$extraField): ?>
	<?php if($extraField->output): ?>
	<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->output; ?></span>
	</li>
	<?php endif; ?>
	<?php endforeach; ?>
</ul>
<?php endif; ?>
<?php endforeach; ?>

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