Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Custom Fields in Joomla K2

Featured Replies

As the title suggests, I'm looking for a way to add a new field to articles created with K2 in Joomla. The site I'm working on is using Joomla 2.5.6, and a custom front end theme.

 

If possible, I would like to add the new field (called 'subtitle') into the admin template directly below the default 'title' field. From there I can pull it into the front end template and display the title/subtitle in the various places they're used.

 

Does anybody know offhand how I can accomplish this? Or perhaps have a handy link to a tutorial that covers this?

 

Just for the record, I did find a post here that seems to cover what I need.. But I tried it just now and it didn't seem to work, not sure if I did something wrong or if it simply won't work for the latest versions of Joomla (post is dated April 2011).

Edited by ZaLiTH

If possible, I would like to add the new field (called 'subtitle') into the admin template directly below the default 'title' field. From there I can pull it into the front end template and display the title/subtitle in the various places they're used.

 

Hiya,

 

As far as I'm aware, you can't actually move the position of the K2 extra fields input fields. You need to fill in the information as normal, then go the the extra fields tab to input your data. It's a bit painful.

 

As far as getting that information into your template, you need to create a K2 template override, which you can do by copying the default K2 template folder (components > com_k2 > templates > default) across to your template folder (templates > yourtemplatename > html > com_k2 > templates). Rename the folder (from default), then add the following PHP into said template, wherever you want the extra field content to appear (you can wrap it in <p> tags or <h2> tags, whatever you like):

 

<?php echo $this->item->extra_fields[0]->value; ?>

 

The 0 refers to the ID of the extra field relating to the category. If you've got three extra fields in an extra fields group, those three fields have the ID of 0, 1, and 2 respectively. If you've got another group assigned to a different category, the ID's will be 0, 1, and 2 for that category as well.

 

You'll usually need to add it into the item template, and the category item template.

 

Go to the Joomla back end, navigate to your category settings, and then set the template to your new template (top right, at the top of the K2 settings sidebar).

 

Hope that all makes sense. Let me know if you have any trouble.

  • Author
Hope that all makes sense. Let me know if you have any trouble.

Thanks for the detailed response, I'm still learning my way around Joomla's structure, but I do follow what you're saying.. Unfortunately I don't have time to look into this right now (I'm moving house this weekend), but once I've settled into my new place I'll tackle this again and see what comes of it. :) Hopefully I can do that early next week.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.