Keyword

How to add k2 extra field inside the content

More
5 years 10 months ago #170879 by Alex
Hi to everyone. I have a question about K2 extra field: it's possible to call inside the content one or more k2 extra fields tag?

If so which tag or call i will need to use? Thanks

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

More
5 years 10 months ago - 5 years 10 months ago #170887 by JoomlaWorks
Replied by JoomlaWorks on topic How to add k2 extra field inside the content
Yes.

To directly output individual extra fields in your K2 overrides, do something like this (e.g. in item.php) to get the extra field name:
echo $this->item->extraFields->EXTRAFIELD_ALIAS_HERE->name;

To get the extra field value you would simply do this:
echo $this->item->extraFields->EXTRAFIELD_ALIAS_HERE->value;
echo $this->item->extraFields->EXTRAFIELD_ALIAS_HERE->rawValue; // for date type only

Simply replace EXTRAFIELD_ALIAS_HERE with the actual alias of the extra field you wish to output.

In modules, use:
echo $item->extraFields->EXTRAFIELD_ALIAS_HERE->value;
echo $item->extraFields->EXTRAFIELD_ALIAS_HERE->rawValue; // for date type only

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Last edit: 5 years 10 months ago by JoomlaWorks.

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

More
5 years 10 months ago #170893 by Alex
Hi Fotis and thanks for your reply. Basically i need to call some of K2 extra field like shortcode to render data inside the article. Example:

Your name: (extra field > Name)

The result will be Your name: Fotis.

How i can do that? Thanks

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

More
5 years 10 months ago #170894 by JoomlaWorks
Replied by JoomlaWorks on topic How to add k2 extra field inside the content
When you say "need to call some of K2 extra field like shortcode to render data inside the article", do you actually mean the WYSIWYG editor? If so, this is not currently possible as it would require a plugin to do that (perhaps a generic plugin to render PHP would work).

However, is there really a point in doing that? The K2 item form is input and the resulting page in the frontend is output. You want to render the output into the input page. It would only confuse your users...

If you explain WHY you want to do this, I might be able to provide a more elegant solution.

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

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

More
5 years 10 months ago #170896 by Alex
Yes WYSIWYG editor. I use JCE that though the configuration option is possible to enable the function to add Php code inside the article.

The purpose about why i am thinking about the above, it's because it could save time to populate some data inside the article avoiding that the user can copy and paste manually all the time. Thanks

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

More
5 years 10 months ago #170898 by JoomlaWorks
Replied by JoomlaWorks on topic How to add k2 extra field inside the content
Then you should be looking at a plugin that copies the extra fields (values) from another item as its own. The gist is that both items should belong to categories that use the same extra fields group so that when you load to edit the item with the copied values, they show up just fine in the K2 item edit form.

Since this is a bit of an edge case, we can custom build the plugin for you if you sponsor it and we can open source it afterwards so it's constantly maintained by either us or other volunteers/users.

If you're interested, send us an email using the contact form here: www.joomlaworks.net/support/contact

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

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
5 years 10 months ago #170899 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic How to add k2 extra field inside the content
Hi Alex,

I have developed the TExtrafield plugin 3 years ago

I think it will help you to add the extra fields inside the content, just with the shortcode {extrafield aliasname}

Where aliasname is the extrafield alias.

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

More
5 years 10 months ago #170900 by JoomlaWorks
Replied by JoomlaWorks on topic How to add k2 extra field inside the content
K2 Community to the rescue! Thank you Mohamed!

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

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
5 years 10 months ago #170901 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic How to add k2 extra field inside the content
Thank you Fotis!
I'm always happy to help K2 community as much as I can.

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

More
5 years 10 months ago #170914 by Alex
Hi Mohamed thanks you very much for your help. I tried just now the plugin and works great. God bless you

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


Powered by Kunena Forum