I love K2, and I've played with a lot of other CCK solutions, some are great but often its more than you need when K2 is almost perfect and you dont want to start from scratch building a whole app through another CCK.
In this case, I needed to customize (read: simplify) the backend of K2 for a client and I realized it would be so great if I could control the backend template per category just like I can for the frontend. So I put together this hack. Its not perfect, but it works.
This way, I can have some categories whose admin pages show their extra fields in the first tab, or perhaps just the text editor and video settings, depending on what I need for that content, without confusing the client with lots of options they dont need.
In theory, this setup combined with extra fields and the ability to call specific extra field data in frontside K2 templates basically makes K2 as versatile as any CCK, without the need to build it all up from scratch. For most projects, K2 is a perfect base, and with these two additions I can customize it more than I ever might need. Of course, either of these might be useful to you on its own as well.
Part A: Adding Custom Admin Templates
I previously had a more roundabout way of doing this posted here, but this way is much easier!
Step 1: In the file administrator/components/com_k2/views/item/view.html.php paste the following code just after
$this->assignRef('form', $form); (around line 307)
Step 2: To initiate the override, duplicate the folder and contents of /administrator/components/com_k2/views/item/tmpl, move it to templates/MY_TEMPLATE/html/com_k2/admin and rename the new folder with the category id you want to override. Then edit the enclosed file default.php (the template for the k2 item backend screen) as much as you want to change the admin appearance for that category.
Click the link below for an example of admin view for editing a specific category with the admin item view override. Notice the extrafield tab is now first, I removed the unnecessary tabs, and renamed the remaining ones.
http://jurawa.com/notes/item/27-update-making-k2-more-like-a-true-cck-custom-admin-templates-and-calling-specific-extra-field-data
Part B: Calling Specific Extra Field Data on the Frontend
Note: Ive actually only used this in the item view, but Id imagine it would work fine in the category_item view as well. UPDATE: it works fine there too.
Note 2: I had a different method posted here before but I found out a better way to do it. The old way put the extra field data in an array based on the ordering of the fields but that meant that if you wanted to reorder the fields - something that I couldnt figure out at first but is possible, just for some reason you have to click order at the top of the column before it lets you - anyway, this would change the array and therefore break the template you made based on the specific extra fields. This way, the extrafield values are based on their ids, so you can reorder all you want and they will still work fine.
Step 1: Make a new K2 template - copy the folder and contents from components/com_k2/templates/default to templates/[your joomla template]/html/com_k2/templates and rename it.
Step 2: In the item.php file in your new template insert the following code just after K2 Plugins: K2BeforeDisplayContent is called. Note: Basically this just puts all the extra field data for this item in an array so you can access it. I dont know if it matters where you place this, but it has be be sometime before you try to use your extra fields in the template.
<!-- Call to prepare extra fields -->Step 3: Now you can use the following bit of code anywhere to call any extra field value by its id.
<?php echo $extrafields[13];?>The array value in the brackets after the variable will correspond to the id of the extra field. you can see these in the backend extra fields view.
Just to get you started, an example of how I used this was to make a custom social media link section on a site thats easily updated by the client - just by putting in the links they want for each item in the extra fields of that category, rather than having to try and use the editor. It also checks if there is any value in each before displaying the icon:
<div class="artistSocialMedia"> <!-- Twitter --> <a href="/"
The next step will be to figure out how to make all this into a plugin, but im far from that at the moment...
Also, I havent tried it yet, but combined with the fields for k2 extension this could be pretty sweet.
Thats it for now, hope it helps some of you... let me know in the comments what you think.
Also, check out other web/joomla/k2 related posts on my blog: http://jurawa.com/notes
This plugin adds blog pingback functionality to Joomla, just like the ones you find in Wordpress.
A Ping is a message is used to let other people know that you have published new content on your site. The ping message is sent to different Update Servers of your choice, which in turn processes your ping to make your new post show up in different blog listings like Technorati and Google Blogs for example.
So why would you want to ping? One word: Traffic!
The more you let everyone know you have new posts, the more traffic to your site you'll expect. A ping also notifies different search engines that your site has updated.
The BlogPing Plugin is configured with Ping-o-matic by default, but you can add as many Update Services as you wish. The best thing about Ping-o-matic is that it automatically forwards your ping to 11 other Update Services and search engines.
HOW DOES IT WORK?
The plugin is triggered everytime your page gets visited, to see if theres any new posts made since the last ping. If it finds new content, a ping is sent to the Update Services you've specified. You can just sit back and relax while the plugin automatically promotes your website.
INSTALLATION
BlogPing is installed like any other extension. It consists of one simple plugin that makes the job for you. One installation file for all Joomla versions (J1.5-J1.7) makes it dead simple to install.
CONFIGURATION
The BlogPing is configured to work out of the box, after you've enabled the plugin. You could still tweak the settings of your choice:
* Specify which categories to ping. Some or all?
* Enter a list of Update Services to use.
* Settings to ping on new posts or new and updated posts
* Enable or disable display of messages in backend.
REQUIREMENTS
* Works on Joomla 1.5+
* PHP 5 required
LANGUAGES INCLUDED
* English
* Swedish
If you don't know what ping is, then you really missed something. This is something that almost every blogging plattform uses. A ping i basically a shout out to an update server, that your site has fresh content. The updateserver will then list your article automatically to it's blogpost listings.
Hopefully your ping will get You tons of new visitors, that you otherwise never would have reached.