Keyword

Adding an extra field to item.php

  • Robert Peterson
  • Robert Peterson's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago #120674 by Robert Peterson
Adding an extra field to item.php was created by Robert Peterson
I feel silly even asking this, but how can I add a specific extra field to item.php? I'd like to add a field near the item title.

Surely there's a shortcode for this, right?

Thanks!

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
10 years 10 months ago #120675 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Adding an extra field to item.php
Yes there is, get the field alias at first from the backend, lets say it is: ALIAS
then add this code anywhere you want in item.php:
<?php echo $this->item->extraFields->ALIAS->value
if you want to display the field label, use this code snippet:
<?php echo $this->item->extraFields->ALIAS->name

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
10 years 10 months ago #120676 by NAEEM ISHAQ
Replied by NAEEM ISHAQ on topic Re: Adding an extra field to item.php
Mohamed Abdelaziz, Please tell me what to do, I want to display an introduction text for item. which type for extra field has to be selected? and which & where code to be added in the item.php
thanks.

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

  • Robert Peterson
  • Robert Peterson's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago #120677 by Robert Peterson
Replied by Robert Peterson on topic Re: Adding an extra field to item.php

Mohamed Abdelaziz wrote: Yes there is, get the field alias at first from the backend, lets say it is: ALIAS
then add this code anywhere you want in item.php:

<?php echo $this->item->extraFields->ALIAS->value
if you want to display the field label, use this code snippet:
<?php echo $this->item->extraFields->ALIAS->name


Mohammed, thanks so much for the information!

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
10 years 10 months ago #120678 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Adding an extra field to item.php
Hi Naeem,

The introduction text is not an extra field, you can access it by this statement:
<?php echo $this->item->introtext; ?>
in item.php file.
In fact you will find it already there, but you may need to inset a readmore link in the item text to divide it into intro and full text.

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.


Powered by Kunena Forum