Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
I knew I would ran into some troubles ;)...

so I want to set up a contact form with a checkbox where one can select to whom the message goes. Most of the recipients are saved in a database (or better clonable template ;)), just the site admin is not in this, so I have to make a little work around. Problem is when I read out the recipients via <cms:each> I only get the recipients from the template, not the adress for the admin. Only when I select only the admin I get his adress. Here is the code:

Input field for the form:
Code: Select all
<cms:input 
name="recipients"
label="Send to"
desc="Select recipients. Select 'Site Admin' for website related issues."
opt_values="
<cms:pages masterpage='php/WHATEVER.php' page_name='SOMEONE'><cms:show k_page_title/>, (<cms:show city/>)</cms:pages>=SOMEONE |
<cms:pages masterpage='php/WHATEVER.php' page_name='SOMEONE2'><cms:show k_page_title/>, (<cms:show city/>)</cms:pages>=SOMEONE2 |
...
Site Admin=admin"
type='checkbox'
required='1'
/>


This I use to read out the adresses saved in the clonable template and - which is not really working and therefore my problem - to insert the adress for the admin should he be selected as well.

Code: Select all
<cms:each frm_recipients as='recipient'>
<cms:if recipient='admin'>something@admin.com,<cms:else />
<cms:pages masterpage='php/WHATEVER.php' page_name="<cms:show recipient/>"><cms:show email/>, </cms:pages></cms:if>
</cms:each>


Any help would be muchly appreciated!
Hi Klaus,

While I can see what you are trying to do, I have doubts if it is the most efficient way of doing it.

Can you please post (or PM me) the exact form code?
Let me take a look at it and perhaps we can find a better method.

Thanks
Thank you very much!

Here you go (and for some reason it's also not working, although I use the same form for a different page...)

Code: Select all
<cms:form enctype="multipart/form-data" method="post" class="k_form" action='#contact' anchor='0'>
<cms:if k_success >
<cms:set recipients_mail="<cms:each frm_recipients as='recipient'><cms:pages masterpage='php/cms_shihan.php' page_name="<cms:show recipient/>"><cms:show email/>, </cms:pages></cms:each>"/>
<div class="k_successmessage">
<cms:set feedback_subject="Message from <cms:show frm_name/>"/>
<cms:send_mail from=frm_email to="<cms:show recipients_mail/>" subject=feedback_subject>
name: <cms:show frm_name />
email: <cms:show frm_email />
---
message:
<cms:show frm_message />
</cms:send_mail>
Your message has been sent. Thank you for your interest!
</div>
<cms:else/>   
<cms:if k_error >
<div class="k_errormessage">
<ul>
<cms:each k_error >
<li><cms:show item /></li>
</cms:each>
</ul>
</div>
</cms:if>   
<cms:fieldset>
<cms:input type="text"
name="name"
label="Name"
maxlength="100"                       
required='1'
validator='min_len=3'/>
<cms:input type="text"
name="email"
label='Email'
maxlength="100"
validator='email'
required='1' />
<cms:input
name="recipients"
label="Send to"
desc="Select recipients."
opt_values="
<cms:pages masterpage='php/cms_shihan.php' page_name='cbrandozzi'><cms:show k_page_title/>, Joden (<cms:show city/>)</cms:pages>=cbrandozzi |
<cms:pages masterpage='php/cms_shihan.php' page_name='fpegoraro'><cms:show k_page_title/>, Joden (<cms:show city/>)</cms:pages>=fpegoraro |
<cms:pages masterpage='php/cms_shihan.php' page_name='lraini'><cms:show k_page_title/>, Joden (<cms:show city/>)</cms:pages>=lraini |
<cms:pages masterpage='php/cms_shihan.php' page_name='dgermano'><cms:show k_page_title/>, Chuden (<cms:show city/>)</cms:pages>=dgermano |
<cms:pages masterpage='php/cms_shihan.php' page_name='mgermano'><cms:show k_page_title/>, Chuden (<cms:show city/>)</cms:pages>=mgermano |
<cms:pages masterpage='php/cms_shihan.php' page_name='are'><cms:show k_page_title/>, Chuden (<cms:show city/>)</cms:pages>=are |
<cms:pages masterpage='php/cms_shihan.php' page_name='araccanelli'><cms:show k_page_title/>, Chuden (<cms:show city/>)</cms:pages>=araccanelli"
type='checkbox'
required='1'
/>
<cms:input type="textarea" cols="35" rows="10" name="message"
required='1'
label='Message'></cms:input>
<cms:input
type="text"
required='1'
validator='regex=/^blue$/i'
class="input-text required-entry"
id="human"
name="human"
label='Please confirm'
desc="Are you human? Is the sky blue or green? (4 characters required)"/>
</cms:fieldset>
<cms:input type="submit" value="Send" name="submit"/>
</cms:if>
</cms:form>
No better method found? ;)
Apologies for the delay, Klaus.

I think I found the problem.
Please modify your original code from this -
<cms:each frm_recipients as='recipient'>
<cms:if recipient='admin'>something@admin.com,<cms:else />
<cms:pages masterpage='php/WHATEVER.php' page_name="<cms:show recipient/>"><cms:show email/>, </cms:pages></cms:if>
</cms:each>

to this -
<cms:each frm_recipients as='recipient' sep=',' >
<cms:if recipient='admin'>something@admin.com,<cms:else />
<cms:pages masterpage='php/WHATEVER.php' page_name="<cms:show recipient/>"><cms:show email/>, </cms:pages></cms:if>
</cms:each>

As it happened, somewhere down the versions, the default separator of check-boxes in forms got changed from the documented '|' (pipe) to ',' (comma) - this is what was causing your code to misbehave.

This was done to make is easier to use the submitted values in emails. I'll get the docs updated.

As an aside, one different way of handling your use-case could be to create a (dummy) cloned page for the admin account. This way we can handle the k_success simply as
<cms:set recipients_mail="
<cms:pages masterpage='WHATEVER.php' page_name=frm_recipients ><cms:show email />, </cms:pages>
"/>
No cms:each would be required as the page_name parameter of cms:pages accepts a comma-separated string of names (which is how the check-box submitted value is).

Hope this helps.
Hi KK,

thanks for the help. But unfortunately it doesn't solve the problem... I get every adress I want if I just put that part of the code plain on the site. But if I include it like I did together with the contact form no mail will arrive. Maybe there could be something else preventing it from sending the mails? Or maybe cms:send_mail supports only one recipient?

By the way, I bought the commercial license for that site -> http://www.hokiryu.net. One has to support this wonderful CMS!... Since it's open source "now" I won't get any file to authenticate it, right? So I just remove the link in the footer and I'm done?
By the way, I bought the commercial license for that site -> http://www.hokiryu.net. One has to support this wonderful CMS!.
Thank you very much indeed, Klaus :)
Your support helps a lot.

So I just remove the link in the footer and I'm done?
Yes, that is it.

Coming to the problem at hand -
cms:send_mail supports sending mails to multiple recipients so that shouldn't be an issue.
Wonder what happens when you select only one recipient?
Does the mail go through?

I suggest you please try out sending mail by hard-coding multiple recipient addresses and see what happens.

Keep us posted.
Thanks again.
So the problem must lie somewhere else, not even the hardcoded messages go through :/. No difference between one or multiple recipients. Any suggestions?
Klaus, could you grant me FTP access to your site please?
Let me do some troubleshooting of my own.

Thanks
Any luck yet?
10 posts Page 1 of 1