Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
Hello,

I'm hoping to be able to accept photo uploads on comment submissions. I've got that part working using the extended comments and a data bound form (for the securefile image upload). Now I want to send an email to the site admin to notify them that a comment has been posted. I want to include the uploaded file in this email so that the admin can make a quick decision to approve the comment or reject it.

Right now the email sends fine, I just can't include the securefile image.

When I do a <cms:dump/> for the variables that are available right after the form has submitted, I can see the securefile input (frm_photo), but when I try to put the image link into an email, it doesn't work.
Code: Select all
k_cur_form: kformname0
k_cur_form_method: post
k_cur_form_separator: |
k_cur_form_mode: create
k_submitted: 1
frm_k_author: Maiden Voyage
frm_k_email: hello@yourmaidenvoyage.com
frm_relationship:
frm_k_comment: test
frm_photo: 1
frm_recaptcha_test:
k_success: k_author: Maiden Voyage k_email: hello@yourmaidenvoyage.com relationship: k_comment: test Comment Photo: 1 recaptcha_test:
k_process_comment_success: 1
k_process_comment_error: 0


Comment Submission Processing Code
Code: Select all
<cms:send_mail from=k_email_from to=k_email_to subject='New Comment' html='1'>
                  <img src="<cms:show k_site_link/>img/logo.png" alt="App logo" width="350" />
                  <h1>New Comment Posted</h1>
                  <p>A new comment has been posted and needs to be reviewed.</p>
                  <p><strong>Name: </strong><cms:show frm_k_author /></p>
                  <p><strong>Email: </strong><cms:show frm_k_email /></p>
                  <p><strong>Relationship: </strong><cms:show frm_relationship /></p>
                  <p><strong>Comment: </strong></p>
                  <p><cms:show frm_k_comment /></p><br>
                  <cms:show_securefile 'frm_photo'>
                     <cms:if file_is_image>
                        <p><strong>Image Upload</strong></p>
                        <img src="<cms:cloak_url link=file_id thumbnail='1' />" />
                     </cms:if>
                  </cms:show_securefile>

                  <p><strong>Approval Link: </strong></p>
                  <a href="<cms:show k_admin_link />?o=comments&q=list&status=0"><cms:show k_admin_link />?o=comments&q=list&status=0</a>
               </cms:send_mail>


Extended Comment / DataBound Form
Code: Select all
<?php require_once( 'admin/cms.php' ); ?>
<cms:template title='Stop Comments' clonable='1' hidden='1'> 

    <cms:editable name='relationship' label='Relationship to Place' order='1' type='text' />
    <cms:editable
    name='photo'
    label='Comment Photo'
    allowed_ext='png, jpg, jpeg, tiff'
    max_size='2048'
    max_width='10000'
    max_height='10000'
    width='400'
    height='400'
    type='securefile'
    thumb_width='100'
    show_preview='1'
    use_thumb_for_preview='1' />
   
</cms:template>

<?php COUCH::invoke(); ?>


Any guidance that could be provided would be greatly appreciated!
Hi,

I think I can see what is causing the code to fail.
I'll, however, need to see more of your form's code - specifically that around the <cms:send_mail> routine - to suggest the required change.

Please post it here and I'll try to fix it.
Hello KK,

Thank you for the reply. Here's the entire form element

Code: Select all
<cms:form method="post" masterpage='stop_comment.php'
       mode='create'
       enctype='multipart/form-data'
       method='post'
       anchor='0'>

         <cms:if k_success >
            <cms:process_comment />
            <cms:if k_process_comment_success>
            <cms:dump />
            <cms:show_securefile 'frm_photo'>
            <cms:dump />
         </cms:show_securefile>
               <cms:send_mail from=k_email_from to=k_email_to subject='New Comment' html='1'>
                  <img src="<cms:show k_site_link/>img/logo.png" alt="App logo" width="350" />
                  <h1>New Comment Posted</h1>
                  <p>A new comment has been posted and needs to be reviewed.</p>
                  <p><strong>Name: </strong><cms:show frm_k_author /></p>
                  <p><strong>Email: </strong><cms:show frm_k_email /></p>
                  <p><strong>Relationship: </strong><cms:show frm_relationship /></p>
                  <p><strong>Comment: </strong></p>
                  <p><cms:show frm_k_comment /></p><br>
                  <cms:show_securefile 'frm_photo'>
                     <cms:if file_is_image>
                        <p><strong>Image Upload</strong></p>
                        <img src="<cms:cloak_url link=file_id thumbnail='1' />" />
                     </cms:if>
                  </cms:show_securefile>

                  <p><strong>Approval Link: </strong></p>
                  <a href="<cms:show k_admin_link />?o=comments&q=list&status=0"><cms:show k_admin_link />?o=comments&q=list&status=0</a>
               </cms:send_mail>

               <div class="k_successmessage">
                  <div class="alert alert-success" role="alert">
                     Your story has been shared and will appear on the app after it has been approved.
                  </div>
               </div>
            <cms:else />
               <div class="k_errormessage">
                  <div class="alert alert-danger" role="alert">
                     There were errors while processing your story submission:
                     <cms:show k_process_comment_error />
                  </div>
               </div>

            </cms:if>

         <cms:else />

            <cms:if k_error >
               <div class="k_errormessage">
                  <div class="alert alert-danger" role="alert">
                     <h2>Fields incomplete!</h2>
                     <ul>
                        <cms:each k_error >
                           <li><cms:show item /></li>
                        </cms:each>
                     </ul>
                  </div>
               </div>
            </cms:if>
         </cms:if>

         <div class="row">
            <div class="col-sm-1"></div>
            <div class="col-sm-5">
               <cms:input type="text" class="form-control" placeholder="Name" name="k_author" required="1"/>
            </div>

            <div class="col-sm-5">
               <cms:input type="text" validator="email" class="form-control" placeholder="Email (Optional)" name="k_email"/>
            </div>
            <div class="col-sm-1"></div>
           </div>
         <div class="row" style="padding-top:20px;">
            <div class="col-sm-1"></div>
            <div class="col-sm-10">
               <cms:input type="text" class="form-control" placeholder="Relationship to Place (Optional)" name="relationship"/>
            </div>
            <div class="col-sm-1"></div>
         </div>
         <div class="row" style="padding-top:20px;">
            <div class="col-sm-1"></div>
            <div class="col-sm-10">
               <cms:input type="textarea" class="form-control" id="exampleFormControlTextarea1" rows="8" placeholder="Please share your experience while at this stop today" validator_msg="required=Please enter something as comment" required="1" name="k_comment"/>         
            </div>
            <div class="col-sm-1"></div>
         </div>

         <div class="row" style="padding-top:10px;">
            <div class="col-sm-1"></div>
            <div class="col-md-3" id="uploadPic">
               <img src="/img/upload.png" style="float:left; height:30px; padding-right:15px;padding-left:20px;" alt="">
               <p style="color:#FE615A">Upload a Picture</p>
               <cms:input name="photo" type="bound" />
            </div>

            <div class="col-md-5">
               <div style="text-align: center; margin: auto;">
                  <cms:input name='recaptcha_test' type='recaptcha'/>
               </div>
            </div>
            <div class="col-md-1">
               <cms:input type="submit" class="btn btn-primary button" value="Submit Story" name="submit"/>
            </div>
         <div class="col-sm-1"></div>
      </div>

      </cms:form>
Thanks.

Please try the following modification -
Code: Select all
<cms:if k_success >
    <cms:process_comment />
    <cms:if k_process_comment_success>
   
        <cms:comments page_id=k_page_id limit='1' show_unpublished='1'>
            <cms:dump />
           
            <cms:show_securefile 'photo'>
                <cms:dump />
             </cms:show_securefile>
             
        </cms:comments>

     ..
     ..

In the code above, we have explicitly used a <cms:comments> block to fetch back the latest comment that was posted.
This should provide the right context that <cms:show_securefile> tag requires to work correctly (please note we are using 'photo' as its parameter and not 'frm_photo' as in the original code).

I haven't actually run this code but it should work in theory.
Please try using it and let me know how it goes.

Hope it helps.
KK,

Thank you for the guidance. That snippet gives me the correct context for the secure file image, but the comment tag only shows me the most recently published comment. The show_unpublished='1' attribute has no effect.
Could you please try adding the 'approved' param as follows? -
Code: Select all
<cms:comments page_id=k_page_id limit='1' show_unpublished='1' approved='0'>

Please let me know if this helps.
That worked great! Thank you KK
You are welcome :)
8 posts Page 1 of 1
cron