Hi All,

I'm getting very lost in searching for a good way in adding simple buttons to my site. I did have Button Field installed and I added several buttons on a node. I then used rules to run a php script when the button was clicked. The issue was with the AJAX and that it was running the first script no matter which button was clicked. Even the Button Comparison was not helping - It would even run when the Search button on the site was clicked.

So I abandoned that Idea, as there seems to be issues when it comes to multiple buttons.

I then have since tried to add a Form Submit button as Custom Content in the Panels. I can achieve a button displayed on the content type but I'm not sure how I would call the php script for it.

Some additional information:
I have a Content Type that for each instance of it I want several buttons added to its view. Each button will run a PHP script when clicked. The reason for these PHP scripts is that it will grab the current Node ID and then do a series of SQL calls then generate a Word document using the PHPWord library. These scripts were working if I enabled the rules to the Button Fields one by one but I was getting issues as mentioned above.

I have been following Drupal books, such as the definitive guide to drupal 7, Udemy Courses and online material. Each seem to cover the very basic stuff such as views & nodes then jump onto module development - I'm just looking for a way to have multiple buttons attached to a node to run php scripts.

I would like to overcome this and learn rather than to have someone else just hand me the solution. So all suggestions welcome.

Thanks

Comments

Sagar Ramgade’s picture

Hi,

You will have to add the node id in your button CSS ID and then in your jQuery where it is making an Ajax call needs to fetch the node id and send it to the URL.

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form