So I went and solved my own problem by modifying things
(http://github.com/adsmart/radiant-directory-mailer-extension) and it
turns out that it was a very simply addition. 

Simply change recipients to directory in you mailer part and add
recipients_field. The value of the recipients field is now a list of the
indexes of items in the directory to use as the recipients. 

That is, given a mailer of:
        subject: "Sent from your mailer form" 
        recipient_field: destination
        directory:
          - z...@example.com
          - o...@example.com
        
and the form from my original post, the message will be sent only to the
email address(es) that are selected in the form. 

I do need help with one bit. I'm not well versed on (T|B)DD so I haven't
modified the specs to account for the new behaviour. I'm not quite sure
how to do it. 

Manually keeping the form and the mailer config in sync is more prone to
error than I'd like so I'm thinking of adding a tag that would let you
do:

<r:mailer:select name="destination">
  <r:directory />
</r:mailer:select>

To get the names, I'm not sure if I prefer
        directory:
          - z...@example.com
          - o...@example.com
        names:
          - "First Address"
          - "Second Address"
        
or
        directory:
          - 
            name: "First Address"
            email: z...@example.com
          -
            name: "Second Address"
            email: o...@example.com
        
either approach has its advantages and disadvantages. 

 

On Thu, 2009-04-09 at 23:26 -0700, Adam van den Hoven wrote:
> Hey all, 
> 
> I need some help. I'm trying to make a mailer page where I want to allow
> users to select the recipient. However, I really don't want to expose
> the recipient's address. I was planning on using the following form:
> 
>         <r:mailer:form name="contact">
>           <div class="field">
>             <label for="destination">Destination</label>
>             <div class="input"><r:select name="destination">
>               <r:option value="0">First</r:option>
>               <r:option value="1">Second</r:option>
>             </r:select></div>
>           </div>
>           ... Other stuff ...
>         </r:mailer:form>
>         
> The code suggests that the mailer part is rendered before it is parsed
> as YAML. So I set my mailer to:
> 
>         subject: "Sent from your mailer form" 
>         from_field: email
>         recipients:
>         <r:mailer:if_value name="recipient" equals="0">  -
>         z...@example.com</r:mailer:if_value>
>         <r:mailer:if_value name="recipient" equals="1">  -
>         o...@example.com</r:mailer:if_value>
> 
> But when I run it I get the following error:
> 
>         syntax error on line 4, col 53: `'
> 
> I'd rather not have to customize the extension if I don't have to. 
> 
-- 
Adam van den Hoven
Hybrid Web Developer
Little Fyr Media
p: 604.618.0845
e: adam.vandenho...@gmail.com
w: http://www.littlefyr.com



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

Reply via email to