- Posts: 90
COMMUNITY FORUM
Adding HTML code into Extra Fields
- Jock
-
- Offline
- Premium Member
<?php echo $extraField->value; ?>
to this:
<?php echo JHTML::_('content.prepare', $extraField->value); ?>
Please Log in or Create an account to join the conversation.
- Odin Mayland
-
- Offline
- Platinum Member
- Posts: 404
Please Log in or Create an account to join the conversation.
- Odin Mayland
-
- Offline
- Platinum Member
- Posts: 404
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.
- Odin Mayland
-
- Offline
- Platinum Member
- Posts: 404
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.
- Odin Mayland
-
- Offline
- Platinum Member
- Posts: 404
{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.
- matthew turner
-
- Offline
- Senior Member
- Posts: 66
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.
- josh tischer
-
- Offline
- New Member
- Posts: 5
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.
- Odin Mayland
-
- Offline
- Platinum Member
- Posts: 404
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.
- Odin Mayland
-
- Offline
- Platinum Member
- Posts: 404
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.
- josh tischer
-
- Offline
- New Member
- Posts: 5
Please Log in or Create an account to join the conversation.
- Odin Mayland
-
- Offline
- Platinum Member
- Posts: 404
Please Log in or Create an account to join the conversation.
- matthew turner
-
- Offline
- Senior Member
- Posts: 66
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.
- Odin Mayland
-
- Offline
- Platinum Member
- Posts: 404
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.
- matthew turner
-
- Offline
- Senior Member
- Posts: 66
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.
- josh tischer
-
- Offline
- New Member
- Posts: 5
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.
- Odin Mayland
-
- Offline
- Platinum Member
- Posts: 404
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.
- Odin Mayland
-
- Offline
- Platinum Member
- Posts: 404
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.
- matthew turner
-
- Offline
- Senior Member
- Posts: 66
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.
- matthew turner
-
- Offline
- Senior Member
- Posts: 66
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.
- Johnno Church
-
- Offline
- New Member
- Posts: 1
Please Log in or Create an account to join the conversation.