Keyword

Adding HTML code into Extra Fields

More
13 years 9 months ago #76453 by Jock
Replied by Jock on topic Adding HTML code into Extra Fields
Yup ... so you change:

 

<?php echo $extraField->value; ?>

 

to this:

 

<?php echo JHTML::_('content.prepare', $extraField->value); ?>

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76454 by Odin Mayland
Replied by Odin Mayland on topic Adding HTML code into Extra Fields
Thank you.

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76455 by Odin Mayland
Replied by Odin Mayland on topic Adding HTML code into Extra Fields
When adding code into the extra fields, are you putting it into the "default value" for the "textarea" type?

 

I can only get the code to function if I put it into the k2 item's extra field tab directly.  This seems to not be the point of the extra field associated with a category.  I don't want to past in the code into each k2item.  I want to apply an extrafield to the whole category of items.

 

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76456 by Odin Mayland
Replied by Odin Mayland on topic Adding HTML code into Extra Fields
Which extra field type are you using for your code?

Jock said:
Hi Josh,

 

I am trying desperately to add some {gallery},{/gallery} code in an extra field but it is simply outputting the syntax.

 

I tried what you suggested above but it is not doing the job. I am using K2 2.4.1Is there something im missing here?

 

Many thanks if anyone has time to help me out here!

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76457 by Odin Mayland
Replied by Odin Mayland on topic Adding HTML code into Extra Fields
This is what I want to type into the textarea type extra field:

{modal url=http://www.primocraft.com/images/primo-craft-custom-bar-layouts.png}<img alt="mt_ignore:primocraft-master-bar-layout-icon" src="/images/primocraft-master-bar-layout-icon.jpg" height="76" width="88" />{/modal}

 

But when I save the extra field it reverts to:

{modal url=http://www.primocraft.com/images/primo-craft-custom-bar-layouts.png},{/modal}

 

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76458 by matthew turner
Replied by matthew turner on topic Adding HTML code into Extra Fields
Hi Modernmagic,

Please read the full posts re gallery plugins in extrafields here :

community.getk2.org/forum/topics/simple-image-gallery-does-not

All done via template over rides.... various options posted...

 

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76459 by josh tischer
Replied by josh tischer on topic Adding HTML code into Extra Fields
If the image html tag is being removed you need to ensure that html is allowed for that field when its saved.

 

originally when I worked on this issue I found that you needed to allow html content in the if statement before the variables are set then saved to the database.

 

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

 

You can always put in a die() command and print_r sections just after the variables are set so you know whats about to be saved, then adjust as needed. The below should help.

 

//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);

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76460 by Odin Mayland
Replied by Odin Mayland on topic Adding HTML code into Extra Fields
I have made the replacements to the extrafield.php as you described.

 

Now the code stays as is and nothing is stripped out in the extra fields editor.  Thank you Josh.

 

But even after the extra field group is assigned to the category, the code does not appear in the item editor extra field tab. And therefore does not appear in the frontend.

 

If I past the same code in the item editor extra field it works in the frontend.

 

1. Is the code from the extra field editor suppossed to be automatically copied into the item editor extra field tab?

2. If so then maybe there is something wrong that wont let it update.  Is there a cache for the extra fields?

3. The extra field title updates from the extra fields editor into the item extra field tab, but not the code in the textbox. Does that help solve this issue?

 

Here is the code for reference:

{modal url=http://www.primocraft.com/images/primo-craft-custom-bar-layouts.png}<img alt="mt_ignore:primocraft-master-bar-layout-icon" src="/images/primocraft-master-bar-layout-icon.jpg" height="76" width="88" />{/modal}

 

 

 

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76461 by Odin Mayland
Replied by Odin Mayland on topic Adding HTML code into Extra Fields
I don't know if this helps but I added a new item in that same category and the extra field's code gets automatically placed in the item extra fields tab.   And it works on the front end.

 

Therefore it appears that there is a saved state for the first item.  I have cleared the joomla cache, unpublished and republished the extra field but the code never gets updated.  However, the extra field's Name gets updates, as I have changed it to verify what gets updated.

 

 

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76462 by josh tischer
Replied by josh tischer on topic Adding HTML code into Extra Fields
Have you tried testing with an extra field without the editor? Its my guess that the editor is causing issues. Try it in a normal text input not a text area.

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76463 by Odin Mayland
Replied by Odin Mayland on topic Adding HTML code into Extra Fields
I think that the terminology and naming of k2 features is getting confusing.  Maybe some screenshots would help.











 

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76464 by matthew turner
Replied by matthew turner on topic Adding HTML code into Extra Fields
Hi Modernmagic,

Just a thought but this could easily be done without using a plug in (which negates the need to fix/hack something....)

Have you tried using the built in "Link" extra field, with show in a light box as the display option, then use CSS to hide the text/replace with icon ?

 

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76465 by Odin Mayland
Replied by Odin Mayland on topic Adding HTML code into Extra Fields
Mat, gee that's a good idea too! :-)  seriously.

 

I will give it a try but my issue doesn't seem to be what is in the box, it seems to be that the info in the box is not getting sent to the k2 item extra field.

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76466 by matthew turner
Replied by matthew turner on topic Adding HTML code into Extra Fields
Hi Modernmagic,

Thanks :) I try not to do core hacks as it means re doing things for clients when doing updates etc...

I have spent the last couple of hours on this and I think it is a Json encode specific issue (try searching google :json encode html) as it is used by K2 to create tidy extrafield arrays that can be stored in the database and called into the template in pairs - name, value, which means lots of core hacks to alter and could lead to a security issue......not a good thing !

I think that this is why Joomlaworks created the link extrafield the way that they did - because it works with the Json encode system, rather than overriding it (by splitting the html into seperate blocks : link text, url etc then arranging them inside of the html afterwards)

I did try all of the "hacks" in these posts (and more from my previous projects and some googling), and got varied results but no complete success..

 

 

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76467 by josh tischer
Replied by josh tischer on topic Adding HTML code into Extra Fields
So according to your screenshot its not showing in the Category display right?

 

Have you checked to make sure that the extra fields are displayed in the Category listings?

 


modernmagic said:

I think that the terminology and naming of k2 features is getting confusing.  Maybe some screenshots would help.











 

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76468 by Odin Mayland
Replied by Odin Mayland on topic Adding HTML code into Extra Fields
Under "Item view options" the extrafields is set to show for both the categories.

 

I got it working.  Here are the steps I have to take.

1. open Item

2. click save

 

That's all I did and now when I check the front end, the extra fields show up as they should.  Of course the problem is that I would have to go through all the items to "update" them so that they show the extra fields.

 

That makes me think that there is a db of data that I am unable to purge if I make a change to the extra fields.

 

 

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76469 by Odin Mayland
Replied by Odin Mayland on topic Adding HTML code into Extra Fields
Mat,

 

The problem with this solution is that the "lightbox" displays the image at too small of a size to read the text.



nonumbers.com 's Modalizer extension allows me to display the popup with colorbox which looks like this:

 

At this point the Modalizer code is working but it required a core hack to allow code in the textarea.

 

So if I could make the lightbox fill the screen with the image then I would figure out how to add an icon to the link extrafield and use this method.
mat said:

Hi Modernmagic,

Just a thought but this could easily be done without using a plug in (which negates the need to fix/hack something....)

Have you tried using the built in "Link" extra field, with show in a light box as the display option, then use CSS to hide the text/replace with icon ?

 

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76470 by matthew turner
Replied by matthew turner on topic Adding HTML code into Extra Fields
Hi Modernmagic,

I will look into that... must be a way of altering/overriding the Lightbox size.

I tend to resize images to 800x600 so have not had any issues.. I will look at this in the morning

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #76471 by matthew turner
Replied by matthew turner on topic Adding HTML code into Extra Fields
Hi Modernmagic,

Another alternative....

If this is to be the same "icon" modalizer plugin for all of the items within a category(s), and you dont want to have to manually add it to every item in the category individually.....

Create/edit an override template for the category, add the code to run a Custom Code module ( from Joomlaworks) within the k2 item template, this module can execute plugins, and PHP - it has worked on all the plugins that I have needed to run so far....so in theory should work for this situation too.. ;)

Set the module to display in all pages or just the menu link for the required category...

And all items within the category now have the icon and the plugin as required - and only 1 file to edit : item.php and 1 module to maintain/edit

Let me know if you need the module in item.php code snippet....

 

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #76472 by Johnno Church
Replied by Johnno Church on topic Adding HTML code into Extra Fields
Hi there, I am trying to insert a table into the extra field of my K2 category and find myself pulling teeth over this. I have scoured many threads and attempted many hacks with zero success. The code is stripped and displayed as plain text. I am using K2 2.4.1 just to let you know. I would really like your advice as I am not fluent with .php...Thanks in advance...

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum