I needed a user friendly way to create a slideshow for a client site. Adding images to a text field (from the EE upload system) is pretty straight forward and easy to learn, so I figured I’d just separate the images using commas and do some parsing on this.
I couldn’t find a suitable plugin for this, so I made my own. It’ll take a string, split it on a character (using the PHP explode method) and allow you to wrap code around it like this:
{exp:splitandwrap char="," str="image1.jpg,image2.jpg,image3.jpg"}
{splitted}
{/exp:splitandwrap}
The above will output three image tags based on the string. This is my first EE plugin so I’m eager for some feedback. I searched for a while but found nothing, so I figured this would be the easiest way, but maybe theres an easier way to do this? (Works with the imgsizer plugin as well)
Files and more info here: http://www.flashgamer.com/2008/03/my_first_ee_plugin.html
J
Hi Jensa,
Hmm could have sworn I replied to this earlier on! Obviously I must be going mad.
Just to say excellent work on your first plugin, hopefully the first of many. I’m sure this will come in really really handy for a lot of people so watch out for the feature requests from this point on in!! 😊
Great plugin though. Will probably find a use for this myself at some point. Will reference yourself if I do.
Best wishes,
Mark
Yeah great plugin! Good work! :cheese:
I do have a little problem. I had a string starting and ending with a “, and the string was ignored. I got no split results whatsoever. When I deleted the quotation marks in the entry it worked again. Unfortunately I have a lot of quotation marks all over the place.
Is there any change on a fix? Maybe something like " somwhere. I’m not very good at php :sick:
Unforunately…. nothing. But thanks a lot for trying on such short notice!! Thats really great 😊
I have also tried it directly with php and I sort of run into the same problem there. Besides that I have my template set to pre process php so I’d really love your plugin to work. But I’m in no rush 😉
Yes, the single quotes work fine. But I really need the double quotes. I could also swap them for &html; thingies but I’d really don’t want to do that. That would make it less user friendly. I also have to keep in mind that someone at any given time will put in a double quote anyway which will result in an ugly error.
I am getting the idea that PHP just can’t handle any string presented from EE like this that contains double quotes. I started a discussion over here.
I’ll continue go on there….
jensa: This plugin is exactly what our site needed. Thanks for making it!
Quick question. I am using this to make a list of article researcher names which get used quite frequently. I wanted to make a list of all the names on one page, but if a name is used more than once it repeats the query results. How would I only get this to put a researcher’s name once??
Here is the URL for reference: http://techlab.bu.edu/resources/authorindex/
Hi @slorenz. Glad it works. As for outputting each name just once - it’s not possible but you could easily modify it to be so?
The plugin is actually just 14 lines of actual code, so if you now a little PHP, you could easily re-write it to support that as well. I’m busy atm so I can’t do it myself.
J
jensa: This plugin is exactly what our site needed. Thanks for making it! Quick question. I am using this to make a list of article researcher names which get used quite frequently. I wanted to make a list of all the names on one page, but if a name is used more than once it repeats the query results. How would I only get this to put a researcher’s name once?? Here is the URL for reference: http://techlab.bu.edu/resources/authorindex/
I’m not putting down jensa’s plugin at all as it is a great addition to ExpressionEngine and one I use myself many times on sites but I’m just wondering if perhaps there wouldn’t be a better way for you to go about doing what you are doing?
I’m just wondering how you are getting the authors names into a string in the first place to be doing things like this. Are the authors not in a weblog somewhere? Just thinking that perhaps a SQL query might be a better way to go on this one perhaps?
Best wishes,
Mark
The authors are entered using Mark Huot’s multi drop-down list extension. When making a new entry, users can click from the list who authored that particular academic article.
I was using SplitAndWrap to display all the articles pertaining to one author (not “posted by” author, mind you). Is there a better way to do this other than writing a new extension or SQL code from scratch?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.