custom button in cmsb to perform custom action

4 posts by 3 authors in: Forums > CMS Builder
Last Post: March 1, 2013   (RSS)

By zaba - February 25, 2013

Hi Guys,

I have an order table that stores the orders taken from a sagepay cart script, it records the name of the purchaser, address, email, and details of the order after it has been sent to sagepay. What my client has asked for is a "button to press" once they are viewing a particular order, they can press the button that basically fires an email off to the email address saying that the order has been despatched.

This button itself can be basically trigger a handle script that will sit on the server passing to it the num, the script can pull all the data based on the num passed to it and send out the email.

My question is can I add such a button to the cms (its not a question of writing the handle script to do the work) so basically the button action is /performmyscript.php?num=xx and the script would return them back to the cms record they are currently viewing, with some means of saying despatch email sent.

Im not sure this is possible or how I would go about doing it, it only needs to appear on the orders section of the cms.

By Dave - February 25, 2013

Hi zaba, 

And here's a more low-tech solution as well so you have some options.  Just add a new separator field in the Section Editor and enter this for HTML:<tr>

 <td colspan='2'>
   <?php if (!$GLOBALS['RECORD']): ?>
      Save record first to send email.
    <?php else: ?>
      <a href="/script.php?<?php echo $GLOBALS['RECORD']['num']; ?>">Send email</a>
    <?php endif ?>
  </td>
</tr>

Then either redirect or link people back to the edit page when you are done: 

/cmsAdmin/admin.php?menu=orders&action=edit&num=123

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By zaba - March 1, 2013

Thanks guys,

I decided to go for Daves Simpler option, by adding the class"button" to the a href I was able to format it like the buttons in the cms.

I also added in my script an Update Table Orders to change the status to dispatched before returning back to the cms page from whence I came (and thus showing it as dispatched).

It all works a charm.

Really thanks very much for your suggestions.