Plugin: PipeBomb
Posted: 26 February 2010 04:14 PM   [ Ignore ]  
Summer Student
Total Posts:  8
Joined  01-16-2008

This plugin allows you to run simple switch/case expressions within a small tag footprint.

{exp:pipebomb switch="{dynamic_variable}" cases="1|2|3|4" values="Number One|Number Two|Number Three|Number Four"

You can also access ExpressionEngine cookies, making it very useful for the multi-language add-ons that rely on them (e.g., you can now have multi-language in LG Polls by just piping the poll_detail answer values. The following example was for an English/Spanish/Portuguese site using Mark Huot’s Simple Translator extension.):

{poll_answers}
<li class='a-{answer_count}'>
    <
label for="lg-polls-answer-{answer_id}">{answer_input} <span class="answer">{exp:pipebomb switch="lang" switch_type="cookie" cases="|_es|_pg" values="{answer}"}</span></label>
</
li>
{/poll_answers} 

And if you want to get really creative, you can loop and pipe a whole HTML fragment between categories tags:

{exp:pipebomb switch="{screen_name}" cases="Peter|Paul|Mary" values="{categories backspace='1'}<h3><a href='{path='>{category_name}</a></h3>|{/categories}"

For the curious, the PipeBomb name evolved from the way it works under the covers: it basically explodes piped values and plucks those values out of the array for display based upon the switch/case parameters.

NOTE: Just as I went to publish, I noticed that a very similar plugin called Switchee was recently released. I believe the two plugins are suitably different to coexist. PipeBomb is a small, crude device meant for quick, dirty jobs whereas Switchee is more of an industrial-strength switch/case utility.

File Attachments
pi.pipebomb.php.zip  (File Size: 2KB - Downloads: 126)
Profile