We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

SplitAndWrap plugin

Development and Programming

jensa's avatar
jensa
109 posts
17 years ago
jensa's avatar jensa

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

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

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

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
17 years ago
Matt Weinberg's avatar Matt Weinberg

This is great– I was doing this explicitly in PHP. Thanks!

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
17 years ago
Mark Bowen's avatar Mark Bowen

Yup me too! I had done this some time back and always meant to write it up as a plugin but just never got around to it so very glad that J has saved us all that trouble!! 😊

Best wishes,

Mark

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
17 years ago
Matt Weinberg's avatar Matt Weinberg

Just implemented this on a project–worked great!

       
Martin de Wit's avatar
Martin de Wit
150 posts
17 years ago
Martin de Wit's avatar Martin de Wit

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:

       
jensa's avatar
jensa
109 posts
17 years ago
jensa's avatar jensa

Hmmm… I’m not escaping the input, so that’s why it’ll break. I probably should add that. Could you use Single quotes instead?

J

       
jensa's avatar
jensa
109 posts
17 years ago
jensa's avatar jensa

I did a quick update. Could you try with this one?

J

       
Martin de Wit's avatar
Martin de Wit
150 posts
17 years ago
Martin de Wit's avatar Martin de Wit

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 😉

       
jensa's avatar
jensa
109 posts
17 years ago
jensa's avatar jensa

Did you try using single quotes on the string instead?

       
Martin de Wit's avatar
Martin de Wit
150 posts
17 years ago
Martin de Wit's avatar Martin de Wit

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….

       
slorenz's avatar
slorenz
38 posts
16 years ago
slorenz's avatar slorenz

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/

       
jensa's avatar
jensa
109 posts
16 years ago
jensa's avatar jensa

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

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen
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

       
slorenz's avatar
slorenz
38 posts
16 years ago
slorenz's avatar slorenz

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?

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.