Problems, need help? Have a tip or advice? Post it here.
12 posts Page 1 of 2
I have a website that has multiple locations and a page that is for scheduling an appointment. I am trying to have each location as a dropdown select option and then send an email to the location email that is set in the locations email editable region. I am not sure how to attach an email to a location and also have all of the location options display with the code below:

Code: Select all
<cms:form name="appoint_form" action='' id="appoint_form" method="post" accept-charset="utf-8" anchor='1'>
                              <cms:if k_success>
                                 <cms:send_mail from=frm_email to='<cms:show email />' subject='New Appointment Request'>
                                    The following was submitted via the Appointment form on FootSurgeon.com:
                                    <cms:show k_success />
                                 </cms:send_mail>
                                 <cms:redirect url='/success.php' />
                                 <cms:else /><cms:if k_error>
                                    <div class="alert alert-danger">
                                       <cms:if k_error_location>Please Choose a location.<br/></cms:if>
                                       <cms:if k_error_first_name>Please enter your first name.<br/></cms:if>
                                       <cms:if k_error_last_name>Please enter your last name.<br/></cms:if>

                                       <cms:if k_error_email>Please enter a valid email address.<br/></cms:if>
                                       <cms:if k_error_phone>Please enter a phone number.<br/></cms:if>

                                       <cms:if k_error_date>Please select an appointment date.<br/></cms:if>
                                    </div>
                                 </cms:if>
                              </cms:if>
                              <cms:input type="dropdown" name="location" opt_values="Please Choose a Location=- | <cms:get_custom_field 'drop' masterpage='locations.php' /> |" required='1' />
                              <div class="clearfix"></div>
                              <cms:input type="text" name="first_name" id="first_name" placeholder="First Name" required='1' />
                              <cms:input type="text" name="last_name" id="last_name" placeholder="Last Name" required='1' />
                              <cms:input type="text" name="email" id="email" placeholder="Email Address" validator='email' required='1' />
                              <cms:input type="text" name="phone" id="phone" placeholder="Phone #" required='1' />
                              <cms:input type="text" name="datepicker" id="datepicker" placeholder="Desired Appointment Date"  required='1' style="width:98%;" />
                              <cms:input class="message" rows="7" cols="70" type='textarea' name="message" id="message" placeholder="Message"></cms:input>
                              <input type="submit" value="submit" class="btn btn-default btn-rounded">
                           </cms:form>
@tonjaggart, change to doublequotes here
to="<cms:show email />"

If the template which has this form is not a location template and therefore doesn't have an editable 'email' the following should generally work - make changes as per format of editable 'drop' in locations.php (it is probably some special format, since there is no direct fetching of locations with cms:pages, isn't it? )
Code: Select all

<cms:if k_success>

<cms:if frm_location = 'location-1' >
   <cms:set email = "<cms:get_custom_field 'email' masterpage='locations.php' page='my-location-1' />" />
<cms:else_if frm_location = 'location-2' />
    <cms:set email = "<cms:get_custom_field 'email' masterpage='locations.php' page='my-location-2' />" />
</cms:if>

<cms:send_mail from=frm_email to=email subject='New Appointment Request'>
</cms:if>


<cms:input type="dropdown" name="location" opt_values="Please Choose a Location=- | <cms:get_custom_field 'drop' masterpage='locations.php' /> |" required='1' />



Next, some people reported that explicit 'root' in path may indicate full hosting path /var/www/html/domain.com. Let me suggest correction like below (assuming success.php is not couch managed template, but it will also work okay if it is):
<cms:redirect url="<cms:show k_site_link />success.php" />
The locations template is a clonable template. How would I set an id for each location dynamically on the location editable regions? Also the get custom field tag is only displaying the first location in the dropdown.
Also the get custom field tag is only displaying the first location in the dropdown.
Because it has no 'page' parameter set, so with missing page parameter gcf takes the first and only page. It is unclear why this piece is there in the first place, because it is expected a loop with cms:pages to get a list of locations.
tonjaggart wrote: The locations template is a clonable template. How would I set an id for each location dynamically on the location editable regions?
Care to reformulate ^this^?




What you can have is a dropdown, generated dynamically with page names like
Code: Select all
<cms:input type="dropdown" name="location" opt_values="Please Choose a Location=- | <cms:pages masterpage='locations.php' /><cms:show k_page_title />=<cms:show k_page_name /><cms:if k_paginated_bottom='0' >|</cms:if></cms:pages>" required='1' />

The above produces opt_values like:
Please Choose a Location=- | Location 1 = location-1 | Location 2=location-2


After submit, in k_success, you get frm_location variable which will have value from dropdown, which will be the k_page_name (is set to the right from '=' ). So a simple request can be used with known page name:
<cms:set email="<cms:get_custom_field masterpage='locations.php' page=frm_location />" />

So you now have the email, fetched from the chosen location page and ready to be used in send_mail.
That makes sense. Thank you so much! Everything is working as it should.
Actually everything works except for the email actually being sent to the email address stored in the editable region.

Code: Select all
<cms:if k_success>
                                 <cms:set email="<cms:get_custom_field masterpage='locations.php' page=frm_location />" />
                                 <cms:send_mail from=frm_email to=email subject='New Appointment Request'>
                                    The following was submitted via the Appointment form on FootSurgeon.com:
                                    <cms:show k_success />
                                 </cms:send_mail>
                                 <cms:redirect url='/success.php' />
                                 <cms:else /><cms:if k_error>
                                    <div class="alert alert-danger">
                                       <cms:if k_error_location>Please Choose a location.<br/></cms:if>
                                       <cms:if k_error_first_name>Please enter your first name.<br/></cms:if>
                                       <cms:if k_error_last_name>Please enter your last name.<br/></cms:if>

                                       <cms:if k_error_email>Please enter a valid email address.<br/></cms:if>
                                       <cms:if k_error_phone>Please enter a phone number.<br/></cms:if>

                                       <cms:if k_error_date>Please select an appointment date.<br/></cms:if>
                                    </div>
                                 </cms:if>
                              </cms:if>
                              <cms:input type="dropdown" name="location" opt_values="Please Choose a Location=- | <cms:pages masterpage='locations.php'><cms:show drop />=<cms:show k_page_name /><cms:if k_paginated_bottom='0' >|</cms:if></cms:pages>" required='1' />
tonjaggart wrote: Actually everything works except for the email actually being sent to the email address stored in the editable region.

Do you mean the problem is with send_mail? Maybe email variable is not getting set? Please run <cms:dump /> or <cms:dump_all /> inside k_success with disabled redirect to see if all values are set correctly before send_mail tag.
It looks like the email isn't being set:

k_cur_form: appoint_form
k_cur_form_method: post
k_cur_form_separator: |
k_submitted: 1
frm_location: bunion-surgery-in-camarillo
frm_first_name: Test
frm_last_name: Test
frm_email: test@test.com
frm_phone: 8053005767
frm_datepicker: 07/06/2016
frm_message: test
k_success: location: bunion-surgery-in-camarillo first_name: Test last_name: Test email: test@test.com phone: 3005767 datepicker: 07/06/2016 message: test
email:
Why 'email' is empty?
Maybe place a scope for the variable like this? I assume, that on locations pages editable 'email' is not empty.
<cms:set email="<cms:get_custom_field masterpage='locations.php' page=frm_location />" scope='parent' />
It was my fault. I forgot to call the email editable region in the get. This fixed it:

Code: Select all
<cms:set email="<cms:get_custom_field masterpage='locations.php' 'email' page=frm_location />" scope='parent' />
12 posts Page 1 of 2