Sorry for such a late response here.  Just reading through posts I'd missed
while away and came across this.


Aitor Garay-Romero-3 wrote:
> 
>    I see the problem.
> 
>    It would be nice to allow parametrization of snippets, but right
> now that it's not possible.  This behavior can be implemented with a
> custom extension though.
> 
>     /AITOR
> 

This need is one of the main reasons that drove me to create my
Vars/Conditionals Extension.  In my case I had a series of wrapper divs that
made up rounded boxes on my site. There were several variations, and some
had different content inside and/or unique classes that needed to be
applied.  It seemed wrong to have 30 different snippets that were all
variations on the same theme.

My goal was to make snippets more like rails helpers or partials -- which
meant that you needed to be able to pass (and then process) arguments.

I even wrote a special modification to the <r:snippet> tag for this very
reason (though it's not technically necessary)

In the body you'd add:
  <r:snippet name="box" vars="content:text to fill" />
  <r:snippet name="box" vars="content:second text to fill" />

Then in the snippet, you'd add:
  <div class="foo">....
    <r:puts value_for="vars[content]" />
  </div>


If you want to get fancy, you can also pass multiple, optional parameters,
like:
  <r:snippet name="box" vars="content: 'text to fill'; id: myId" />

and:
  <div class="foo"<r:if cond="vars[id]> id="<r:puts value_for="vars[id]"
/>"</r:if>>
    <r:puts value_for="vars[content]" />
  </div>

In this case your snippet adds the id tag to your div IF you include a value
for it.


Feel free to download the extension and try it out:
http://swankinnovations.svnrepository.com/svn/open/radiant/extensions/vars_if/trunk/

Hope this helps!

-Chris


On 9/18/07, Andrea Otto <[EMAIL PROTECTED]> wrote:
> Hi,
> I'd like to know how can I use radiant at the best...
>
> For example: I have a Homepage with a lot of boxes with same graphic.
> How can I deploy this?
>
> My first thought was creating something like this in the body:
>
> <r:snippet name="box">text to fill</r:snippet>
> <r:snippet name="box">second text to fill</r:snippet>
>
> and create a snippet like this:
> <div class="foo">....
>  <r:content>
> </div>
>
> I know that it can't be done... but it is my first use logic...
>
> So... How can I do it?
>
> My only working solution is to create a lot of childs page, all with a
> "mytext" part, put <r:snippet name="box"> in each body, create a snippet
> like this:
> <div class="foo">....
>  <r:content part="mytext">
> </div>
>
> and include all of my childs_box in the homepage with <r:child:each>
>
> Is it the right solution? Or there's a more pratic and fast modus
> operandi, like the first I exposed?
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Radiant mailing list
> Post:   Radiant@lists.radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>
-- 
View this message in context: 
http://www.nabble.com/Radiant-Best-Practice-tf4472903.html#a13265682
Sent from the Radiant - User mailing list archive at Nabble.com.

_______________________________________________
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to