Keyword

Extra fields from few articles to one content

  • Paweł Rożek
  • Paweł Rożek's Avatar Topic Author
  • Offline
  • New Member
More
9 years 11 months ago - 9 years 11 months ago #133138 by Paweł Rożek
Extra fields from few articles to one content was created by Paweł Rożek
Hello,

I have in one category 3 articles. All articles contain extra field e.g. Name, Age, telephon.
I would like to create dynamic content in other article with extra field from this articles.

Example dynamic content:
[Name form first article] [telephon from first article]
[Name form second article] [telephon from second article]
[Name form third article] [telephon from third article]

What I need for this solution?
Best regards,
Pawel

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 11 months ago #133139 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Extra fields from few articles to one content
Hello Pawel,

You can publish a K2 Content module and show only the extrafields.

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

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

  • Paweł Rożek
  • Paweł Rożek's Avatar Topic Author
  • Offline
  • New Member
More
9 years 11 months ago #133140 by Paweł Rożek
Replied by Paweł Rożek on topic Re: Extra fields from few articles to one content
Hello Krikor,

Thank you for your answer. It's good idea.
But using this modul I can set "show" and "hide" extrafields only.
I have few extrafields in group and a need sometimes show not all extrafields.
As in the above example - only Name and Telephon, not Age.
Is this option available?

BR,
Paweł

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 11 months ago #133141 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Extra fields from few articles to one content
You can override the module's template and create a new one.
In that template you can render each extrafield separately and with its own markup.
<?php echo $this->item->extraFields->EXTRAFIELDALIAS->name ?>
<?php echo $this->item->extraFields->EXTRAFIELDALIAS->value ?>

This code will print an extrafield's name and value.
Be careful, depending on the view $this or $this->item might be used.

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

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

  • Paweł Rożek
  • Paweł Rożek's Avatar Topic Author
  • Offline
  • New Member
More
9 years 11 months ago #133142 by Paweł Rożek
Replied by Paweł Rożek on topic Re: Extra fields from few articles to one content
Thank you for this.
I understand but it is little incomprehensible for me :)
Could you give me more information or links how to do?

BR,
Pawel

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 11 months ago #133143 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Extra fields from few articles to one content
You need to create a new template for the mod_k2_content.
If you are not familiar with overrides you need to read these posts:
nuevvo.com/blog/item/84-k2-inheritance-sub-templating
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

Once you have your new template in your default.php file you need to edit the main extrafields block. Then you have to use the snippet I gave you as a base to build your custom template. Each extrafield has an alias, so use with the code I gave you.

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

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

  • Paweł Rożek
  • Paweł Rożek's Avatar Topic Author
  • Offline
  • New Member
More
9 years 11 months ago #133144 by Paweł Rożek
Replied by Paweł Rożek on topic Re: Extra fields from few articles to one content
Ok, big thank you for you! I will do this, and I write as I do.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 11 months ago #133145 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Extra fields from few articles to one content
You 're welcome Pawel.

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

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

  • Paweł Rożek
  • Paweł Rożek's Avatar Topic Author
  • Offline
  • New Member
More
9 years 10 months ago #133974 by Paweł Rożek
Replied by Paweł Rożek on topic Extra fields from few articles to one content
Hello,
this is code from file \mod_k2_content\name\default.php:
<?php foreach ($item->extra_fields as $extraField): ?>
					<?php if($extraField->value != ''): ?>
					<li class="type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
						<?php if($extraField->type == 'header'): ?>
						<h4 class="moduleItemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
						<?php else: ?>
						<span class="moduleItemExtraFieldsLabel"><?php echo $extraField->name; ?></span>
						<span class="moduleItemExtraFieldsValue"><?php echo $extraField->value; ?></span>
						<?php endif; ?>
						<div class="clr">

						
						</div>
					</li>
					<?php endif; ?>
	        <?php endforeach; ?>
	      </ul>

How modified this code using your proposal?
BR,
Paweł

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 10 months ago #134001 by Krikor Boghossian
Replied by Krikor Boghossian on topic Extra fields from few articles to one content
If you want to show all extrafields then you do not need to change anything.
On the other hand you can delete this loop and use my example.
Remember to change the alias to the proper one.

You will have to render these extrafields one by one. eg.
<?php if($this->item->extraFields->EXTRAFIELDALIAS->value != ''): ?>
<span class="moduleItemExtraFieldsLabel"><?php echo $this->item->extraFields->EXTRAFIELDALIAS->name ?></span>
<span class="moduleItemExtraFieldsValue"><?php echo $this->item->extraFields->EXTRAFIELDALIAS->value ?></span>
<?php endif; ?>

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