July 17, 201214 yr 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 July 17, 201214 yr by ZaLiTH
July 19, 201214 yr 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.
July 19, 201214 yr 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