- Posts: 5
COMMUNITY FORUM
How to add k2 extra field inside the content
- Alex
-
Topic Author
- Offline
- New Member
If so which tag or call i will need to use? Thanks
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
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 :)
Please Log in or Create an account to join the conversation.
- Alex
-
Topic Author
- Offline
- New Member
- Posts: 5
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.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
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.
- Alex
-
Topic Author
- Offline
- New Member
- Posts: 5
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.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
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
-
- Offline
- Platinum Member
- Joomla Developer
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.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
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
-
- Offline
- Platinum Member
- Joomla Developer
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.
- Alex
-
Topic Author
- Offline
- New Member
- Posts: 5
Please Log in or Create an account to join the conversation.
- Alex
-
Topic Author
- Offline
- New Member
- Posts: 5
Please Log in or Create an account to join the conversation.
- Mohamed Abdelaziz
-
- Offline
- Platinum Member
- Joomla Developer
I'm good, thanks!
If it is a k2 extra field, most probably yes.
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.
- Okan
-
- Offline
- New Member
- Posts: 8
This one doesn't work with k2 tools module.
K2 plugins enabled.
It gives nothing.
And yes i used my own allias instead of "EXTRAFIELD_ALIAS_HERE"
<?php echo $item->extraFields->EXTRAFIELD_ALIAS_HERE->value; ?>
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
I would recommend doing a K2 template override for item.php. A much better solution if you ask me...
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Stephan Tensen
-
- Offline
- New Member
- Posts: 6
I'm a newbie, but very excited about the good things K2 can do ;-)
At the moment I'm trying to display one or more extra fields in the content. I tried using the first method in my override version of category_item.php. I tried it in two ways. See below. It's about the extra field with the alias Prijs. I added TEST1 above the code and TEST2 below the code, to make sure I'm editing the right file. I see TEST1 and TEST2 but the code in between seems to do nothing.
I also downloaded and installed the plugin TExtrafield from Mohammed, but no result either when putting {extrafield Prijs} in the editor of the introtext of the item. So clearly I must be doing something completely wrong ;-) I set display Extra Fields off, because I don't want it to show ALL extra fields. Is that correct? What can I be doing wrong?
TEST1
<?php if($this->item->extraFields->Prijs->value != ''): ?>
<div class="itemExtraFieldswrapper">
<div class="itemExtraFieldsLabel"> <?php echo $this->item->extraFields->Prijs->name; ?></div>
<div class="itemExtraFieldsValue"><?php echo $this->item->extraFields->Prijs->value; ?></div>
</div>
<?php endif; ?>
<?php echo $this->item->extraFields->Prijs->value; ?>
TEST2
Please Log in or Create an account to join the conversation.