You might notice that for some reason, when you use the WYSIWYG Editor oprion in a K2 textarea extra field, it is buggy, and you cant access the usual show/hide source button.
This will fix that and get the editor back to the way it normally appears in the main item view. This is accurate in K2 v2.5.4.
In the file: /administrator/components/com_k2/models/extrafield.php at line 208, replace
case 'textarea':
if($active[1]){
$output='<textarea name="K2ExtraField_'.$extraField->id.'" id="K2ExtraField_'.$extraField->id.'" rows="10" cols="40" class="k2ExtraFieldEditor">'.$active[0].'</textarea>';
}
with:
case 'textarea':
if($active[1]){
$editor =& JFactory::getEditor();
$output = $editor->display("K2ExtraField_".$extraField->id."", $active[0], '550', '400', '60', '20', false);
}
That should do it. Cheers.
I love the free AdminPraise Lite admin template for Joomla 1.7+ http://www.adminpraise.com/joomla/admin-templates/free/adminpraise-lite.php
They made some nice updates over the old version, hovever there are some weird css issues that I keep having to fix each time I install it on a new site, so I'm posting them here so I can refer to them easily and hopefully it helps some of yall out!
Most of them relate just to the K2 dashboard icons, and the modal popups for selecting menu item types etc... If I find more, Ill update as I do.
Just post this code at the bottom of the admin template css file: administrator/templates/aplite/css/template.css
/* Jurawa's Fixes */
body.ap-modal{
overflow: auto;
}
.theme6 .icon-wrapper .icon a:hover {
background: #ccc;
}
.theme6 .icon-wrapper .icon a {
background: #fff;
}
.icon-wrapper .icon a, .theme6 .icon-wrapper .icon a {
text-shadow: none;
}
I created this Google Chrome theme because I thought it might help motivate me to actually work on the things I should be working on... Ironically, I definitely should have been working on other things while I made the theme.
Screenshot:

Maybe it will help motivate some of you, and if not, at least the image is hilarious and makes me laugh every time I open a new tab!
Note: works best if you go to the middle of the new tab slider, where the apps are, and assuming you dont use any of them as I dont, just right click and remove them all so each time you open a tab there are not a bunch of icons on top.
Be sure to download the right one for your screen resolution - 13" Macbook Pros are 1280x800px, 15" Macbook Pros are 1440x900px, older iMacs are 1680x1050px, newer iMacs are 1920x1080px.
Thanks to Rami for the original image idea!
Enjoy!
Links to free theme in chrome web store:
Random old rally promo video that I had lying around.
Adding class to body tag based on page alias in Joomla!
Written by JurawaI dont know why this isnt standard, but heres an easy way to add an extra body class based on a page's url alias in Joomla. This makes it very easy to customize the style anything on a page just by adding body.[PAGE ALIAS] before the normal css class/element your targeting.
In your templates index.php file, just before the body tag, add:
<?php
$menu = &JSite::getMenu();
$active = $menu->getActive();
?>
Then, in the body class, leave a space after whatever other classes are there and add:
<?php print $active->alias; ?>
I'm using the T3 Template framework, and my body tag now looks like this:
<body id="bd" class="bd <?php print $active->alias; ?>">
Comes in handy all the time! For example:
body p{
font-size: 14px;
}
body.contact p{
font-size: 16px;
}
Hope it helps!
Just thought I'd re-post this because it was annoyingly hard to find and its a great plugin that provides functionality that I often need - being able to automatically archive, delete or unpublish k2 items based on category.
It defaults to using the publishing date, but with a little tweak you can set it up to use the created date - just change line 72 of k2autoarchiver.php from:
$query .= ' WHERE (a.publish_down > "0000-00-00 00:00:00") AND (a.publish_down < NOW()) AND
to:
$query .= ' WHERE (a.created > "0000-00-00 00:00:00") AND (a.created < NOW()) AND
Thanks to Lukas on the K2 forums. Here is the original post I got the plugin from.
Maybe they will add this functionality in the next version of K2... either way im happy they are actively developing it. The new 2.5 version is great!
[UPDATE 2] Making K2 More Like a True CCK: Custom Admin Templates and Calling Specific Extra Field Data
Written by JurawaI love K2, and Ive 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)
//Look for specific admin template file
jimport('joomla.filesystem.folder');
$componentPath = JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'templates';
$componentFolders = JFolder::folders($componentPath);
$db =& JFactory::getDBO();
$query = "SELECT template FROM #__templates_menu WHERE client_id = 0 AND menuid = 0";
$db->setQuery($query);
$defaultemplate = $db->loadResult();
if (JFolder::exists(JPATH_SITE.DS.'templates'.DS.$defaultemplate.DS.'html'.DS.'com_k2'.DS.'templates'.DS.'admin'.DS.$item->catid))
{
$this->_addPath('template',
JPATH_SITE.DS.'templates'.DS.$defaultemplate.DS.'html'.DS.'com_k2'.DS.'templates'.DS.'admin'.DS.$item->catid);
}
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/templates/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.
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.

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 -->
<?php
//convertArray to use ids as key
$extrafields = array();
foreach($this->item->extra_fields as $item)
{
$extrafields[$item->id] = $item->value;
}
?>
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="/"
target="_blank"><img src="/images/smicons/twitter2.png" alt="Twitter" title="Twitter" /></a>
<!-- Facebook --> <a href="/"
target="_blank"><img src="/images/smicons/fb2.png" alt="Facebook" title="Facebook" /></a>
<!-- Vimeo --> <a href="/"
target="_blank"><img src="/images/smicons/vimeo2.png" alt="Vimeo" title="Vimeo" /></a>
<!-- Youtube --> <a href="/"
target="_blank"><img src="/images/smicons/youtube2.png" alt="Youtube" title="Youtube" /></a>
<!-- Flickr --> <a href="/"
target="_blank"><img src="/images/smicons/flickr2.png" alt="Flickr" title="Flickr" /></a>
<!-- Instagram --> <a href="/"
target="_blank"><img src="/images/smicons/instagram2.png" alt="Instagram" title="Instagram" /></a> <?php endif; ?>
</div>
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.
Embedding The New Soundcloud HTML5 Player Using The Soundcloud API and PHP
Written by JurawaJust found a quick easy way to embed the brand new Soundcloud HTML5 player in a Joomla website I'm working on and I thought I would share.
1. Get an client id by registering an app - http://soundcloud.com/you/apps
2. Use this code in your php file to get all the info for any track on soundcloud:
<?php
ini_set("user_agent", "SCPHP");
function resolve_sc_track($url){
return json_decode(file_get_contents("http://api.soundcloud.com/resolve?client_id=YOUR_CLIENT_ID&format=json&url=".$url), true);
}
// get track data from track url
$track = resolve_sc_track(ANY_SOUNDCLOUD_URL);
?>
Your $track varible will now be an array with all the info from the track. You can check whats in there by going to the url in your browser, or by printing the array in php:
<?php print_r ($track); ?>
3. Pull the track id from the track info array and insert it in the soundcloud HTML5 player code:
<iframe width="100%" height="166" scrolling="no" frameborder="no"
src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com
%2Ftracks%2F'.$track[id].'&auto_play=false&show_artwork=true&color=ff7700"></iframe>
And your set!
Hope this helps out!