Keyword

Using Extra Fields with a custom php script loaded via jumi?

  • Jeff Whitmore
  • Jeff Whitmore's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 10 months ago #69374 by Jeff Whitmore
I've been a Jumi user for awhile now. It makes adding custom php scripts a snap in Joomla.

You used to be able to make fairly simple arrays inside your Joomla content. They recently updated Jumi though so the old method of making arrays doesn't work anymore

An example of the old Jumi method for adding an array to your Joomla content for your custom php script to use.

{jumi [modules/mod_jumi/jumi_instrument.php]
0. Model [25th Anniversary]
1. Size [12" wide, 1" thick, 37" long]
2. Weight [7 lbs, 0 oz]
3. Body Wood [Chambered basswood]
}

Basically the old plugin recognized the first set of square brackets was your custom php script and then the remaining sets of square bracketed items become your array for your php script.

The new Jumi has changed the method for creating arrays. It's not a whole lot different but different enough it will confuse my non-technically inclined content maintainers.

I've never really liked the way I had to create those arrays anyways. If one of my content maintainers accidentally delete a opening or closing square bracket then it would mess things up.

K2 seems to be a perfect solution for entering the data.

I really want to use K2 and the extra fields to store the data. I noticed if I create the extra fields in K2 then it gets stored in a field in the db.

[{"id":"1","value":"25th Anniversary"},{"id":"2","value":"12\" wide, 1\" thick, 37\" long"},{"id":"3","value":"7 lbs, 0 oz"},{"id":"4","value":"Chambered basswood"}]

Is there a simple pre built K2 method or K2 function I can call to clean that up and parse or explode that into a php array?

I could take the time to write my own but If there is something simple using already written K2 code that would be awesome!

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

  • Jeff Whitmore
  • Jeff Whitmore's Avatar Topic Author
  • Offline
  • Junior Member
More
14 years 6 months ago #69375 by Jeff Whitmore
Ok since then I've gotten this too work not needing jumi. I ended up coping the ~/components/com_k2/templates/default directory to ~/templates/rt_musicman/html/com_k2/templates/ directory. I then created a copy of that default directory called instruments. I then applied instruments as my template over ride for my k2 category.. from there you can edit the appropriate file. I edited item.php since I want to edit the item view.

I now recognize that [{"id":"1","value":"25th Anniversary"},{"id":"2","value":"12\" wide, 1\" thick, 37\" long"},{"id":"3","value":"7 lbs, 0 oz"},{"id":"4","value":"Chambered basswood"}] is just a json string so add a little json_decode magic and then you have an array jumi or your custom php code can use. Voila.

Oversimplified but that was the answer I was looking for and ended up discovering the answer myself.

Currently I'm looking at ~/administrator/components/com_k2/lib/JSON.php to see if can figure out how to use those functions to break it down into an even simpler array.

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

More
13 years 9 months ago #69376 by Ian Powney
Hi Aaron

Did you get this to work, if you did could you let me know what you changed

Thanks in advance
Ian

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

More
13 years 9 months ago #69377 by william white
you can get the extra fields like this if it suits your needs
$custom = $this->item->extra_fields;
and then addressing extra fields for the item like
echo $custom[1]->value;
I havent read up on JSON.php but i bet it parses the field into an array for you

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

More
13 years 9 months ago #69378 by Ian Powney
Thanks for comments William, I have 2 joomla plugins that are arrays that do not explode in K2 front end, they are both similar to this {something|something|something}
I would really like to use these within the K2 extra fields type textarea, one plugin is a shopping cart the other is a contact us
I am pretty sure that JSON is responsible for stripping the html tags and have tried all the other posts about extra fields to no avail
I am using v2.3 if that makes any difference

Any help would be appreciated

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

More
13 years 9 months ago #69379 by william white
Say you have the fields in jos_k2
text - name
text - address
testarea - description
You would refer to the text area like this i think echo $custom[2]->value;
and it would contain your values something|something|something
You would have to parse it from there...
This is my guess, untested

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

More
12 years 10 months ago #69380 by Jock
Did anyone get anywhere with this?

 

I am trying to use the following syntax in extrafields to generate images with an enlarge/layer option:

 

{gallery width=708 height=140 alignment=left orientation=horizontal overlay=1}/images/image.jpg{/gallery}

 

All it is outputting, however, is the syntax I mentioned above.

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


Powered by Kunena Forum