Loops in templates
Posted: 27 March 2008 04:36 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  165
Joined  09-29-2007

The only way of putting repetative numerical values into templates is either by hard-coding them in or by enabling and using php to do it. I always try to avoid enabling php in templates for security purposes, and hard-coding in for example a drop-down select box with 100 values is never fun.

So i have developed a loop plugin that solves the problem by allowing you to perform loops in your templates. Its a free download here:

http://www.putyourlightson.net/projects/loop

 Signature 

* Get the Sitemap Module and improve your site’s SEO

More Add-ons: Multi Language, iWebApp, Stand-Alone Image Editor, Landing Page, LogMeIn, Loop Plugin, Session Variables

Profile
 
 
Posted: 27 March 2008 04:38 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15489
Joined  05-15-2004

Interesting, but shouldn’t that go in the Plugins forum?

 Signature 

Everything will be good in the end. If it’s not good, it’s not the end.

Profile
MSG
 
 
Posted: 27 March 2008 05:04 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Hi Ben,

Great Add-On!

A few notes:
1) when using the plugin inside a weblog tag (or query tag), the {count} variable will show the weblog’s {count} variable, you could change yours to something like {loop_count} or {counter}.
2) you might also want to start prefixing your EE Add-Ons smile

Now let’s see if we can use this plugin to easily create multiple columns of weblog entries cool smirk

Cheers!

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 27 March 2008 05:31 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  165
Joined  09-29-2007

thanks for the suggestions.  i’ve changed the file name to pi.for_loop.php and the variable to {loop_count}.

please feel free to post any cool uses of the plugin, i expect there might be a few!!

 Signature 

* Get the Sitemap Module and improve your site’s SEO

More Add-ons: Multi Language, iWebApp, Stand-Alone Image Editor, Landing Page, LogMeIn, Loop Plugin, Session Variables

Profile
 
 
Posted: 27 March 2008 05:41 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Hi ben,

From the Developer Guidelines: (although I don’t think it is a requirement)

“Choose a prefix that is unique to your identity as a developer or company”

...so why not pi.bc_loop.php or pi.pylo_loop.php?

I just tested the plugin with some rating value (0 to 5), pretty cool.

{exp:loop start="0" end="{rating}" increment="1"}
<img src="star.gif" />
{/exp:loop}

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 27 March 2008 05:44 AM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

Hi Ben,

Looks set to be a really great little add-on! Well done.

One little thing though and this is me just nitpicking but on your page it says “repetative numerical” instead of “repetitive numerical” wink

Great plugin though and definitely one I will use so thanks for that.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 27 March 2008 05:48 AM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  165
Joined  09-29-2007

...so why not pi.bc_loop.php or pi.pylo_loop.php?

i think the file name and the exp tag should be intuitive so that it is easier to understand when seen in a template.  for_loop actually describes it pretty well since three values (initial, limit, increment) have to be set, and i assume most people have heard of a for loop, but maybe not…?

@mark: that really is nitpicking but i’ll change it just for you!!

 Signature 

* Get the Sitemap Module and improve your site’s SEO

More Add-ons: Multi Language, iWebApp, Stand-Alone Image Editor, Landing Page, LogMeIn, Loop Plugin, Session Variables

Profile
 
 
Posted: 27 March 2008 05:54 AM   [ Ignore ]   [ # 7 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006
ben c - 27 March 2008 05:48 AM

@mark: that really is nitpicking but i’ll change it just for you!!

So shoot me wink

Actually just kidding, don’t shoot me please!! I have just always been one to notice spelling mistakes and sometimes I really should just keep my g*b shut. Working in radio advertising it has become a staple part of everyday life for me unfortunately!

I’ll bet I’ve probably made some mistakes in this post anyway so will cower off into the corner now!!

Again, great plugin (shouldn’t this word really be plug-in?) though so thanks for that!

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 27 March 2008 05:55 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  879
Joined  02-05-2002

Ben,

The name being so intuitive is exactly why you should prefix it wink

Again from the Guidlines:

When your class or filename is a common word, or might quite likely be identically named in another PHP script, provide a unique prefix to help prevent collision. Always realize that your end users may be running other add-ons or third party PHP scripts.

I’m not trying to annoy you, just hoping that all EE devs start prefix their add-ons with a personal prefix like the Guidelines propose.
Most EE devs are already doing this…

*ducks and starts updating his own add-ons wink

 Signature 

Member of the EE Pro Network

Profile
 
 
Posted: 27 March 2008 06:02 AM   [ Ignore ]   [ # 9 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  165
Joined  09-29-2007

haha, ok i’ll consider it, thanks cocoa

cheers mark!

 Signature 

* Get the Sitemap Module and improve your site’s SEO

More Add-ons: Multi Language, iWebApp, Stand-Alone Image Editor, Landing Page, LogMeIn, Loop Plugin, Session Variables

Profile
 
 
Posted: 27 March 2008 06:35 AM   [ Ignore ]   [ # 10 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006
ben c - 27 March 2008 06:02 AM

cheers mark!

I’m sure you don’t really mean that! wink
I can hear you scraping away at my Avatar on screen trying to gouge out my eyes!! grin

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 27 March 2008 10:02 AM   [ Ignore ]   [ # 11 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15869
Joined  06-03-2002

Moved to the Plugins forum.  Ben, after you’ve assembled the feedback and are happy with your plugin, don’t forget to submit it to the Add-On Library!

 Signature 
Profile
MSG
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65087 Total Logged-in Users: 37
Total Topics: 82227 Total Anonymous Users: 20
Total Replies: 441926 Total Guests: 217
Total Posts: 524153    
Members ( View Memberlist )