Monday, March 28, 2011

Enable HTML in joomla k2 extra fields

K2 is a wonderful CCK and content replacement for the standard joomla content. In fact I am using it with k2mart to create some awesome shopping cart goodnes. Of course the shopping cart I am converting from is a Custom CMS/E-commerce system that has tons of custom html pieces in the product buy now pages.

Specifically I needed the ability to choose several custom messages that have little html to open new windows, highlight messages etc.

There are community links for an older version of k2 here

These don't work in the latest so here is an updated working html hax for K2 v2.4.1!

Open up Administrator/components/com_k2/models/extrafield.php

//line 32 
if (!$row->bind(JRequest::get('post')))
 

//around line 53 look for 
$objects = array ();
$values = JRequest::getVar('option_value');
$names = JRequest::getVar('option_name');

Replace with the following (if you have questions see documentation)
 //line 32 - replaced
if (!$row->bind(JRequest::get('post',JREQUEST_ALLOWHTML)))


//around line 53 - replaced
$objects = array ();
$values = JRequest::getVar('option_value','','post','string',JREQUEST_ALLOWRAW);
$names = JRequest::getVar('option_name','','post','string',JREQUEST_ALLOWRAW);
 


Stumble Upon CodePyro

14 comments:

Marcola said...

Hi I'm try your solution but nothing change.

I only need to change the extrafield.php ?

Thanks!

Elvis Sedić said...

This hack doesn't work for me either.

When I make changes I lost my wysiwyg editor in content tab, also there is still just textarea in custom fields tab.

I'm using K2 2.4.1, Joomla 1.5.22 and JCE Editor 1.5.7.11.

Josh Tischer :: CodePyro said...

This hack just adds the ability to save html in the custom fields it does not show the editor

Anonymous said...

worked great thanks - now I can add a reference to a video icon for videos like this:
Video

Now The text 'Video' appears in the admin dropdown but the class none will make it disappear on the site so only the icon shows. I use this in conjunction with the K2 Content wall module that can call the specific field and your good to go.

Said Akhmedabayev said...

Hello what would be solution for K2 2.5.5 version on Joomls 2.5

Hernan Aros said...

This works great, I'm using Joomla! 2.5.4, K2 version 2.5.6

Thanks!

Anonymous said...

for me it's not working! tell me plz what to do?

Josh Tischer :: CodePyro said...

What version of k2 and Joomla are you using? Can you send me the copy of your extrafield.php file

/components/com_k2/models/extrafield.php

info AT codepyro.com

Anonymous said...

I am using last version with joomla 2.5.6 extrafield.php I can send tomorrow. But i did everything like u said changed 32 line and 51 (it wasn't 53 in my file ) so but nothing happened

Rafayel said...

ew how to send u my Extrafield.php file??? it's more than 4.096 chars... tell me mail or something maybe?

Josh Tischer :: CodePyro said...

Yea, zip and email it. Email typically blocks php files.

info AT codepyro.com is my addy

Anonymous said...

Thank you! Work perfect!

Anonymous said...

Your are awesome!!
Thank you very much!!

Anonymous said...

It works perfectly!!! Thank you very much <3

Post a Comment