-1

I have written a custom module which creates a link on the page.

When you clicking the link

<a href="path_to_module/lib/script.php?lotOfparameters=value>
  Do it
</a>

a php file is called, where all the logic of the module is done (create a node with predefined field values, create a pane for panels module and other stuff).

But i think this isn´t the recommend way to to this in Drupal. Doing this in the .php file is tooking sometimes a lot of time, so a progress bar would be nice for exmaple.

So I am looking for the best way to do logic when a button is clicked on the site.

EDIT: I think that was a bad description for my problem, so i try to make this better.

In my Templates, e.g. page.tpl.php and node.tpl.php, I´m printing a link to create a button. If the buttons gets clicked I want to do some stuff, i think what exactly is irrelevant. But I'm doing this with a direct link to a .php file in the link. In this .php file all things are executed. And I think THIS isnt the best way to do things in drupal.

closed as primarily opinion-based by Mołot, Free Radical, Bala, AjitS, Letharion Dec 16 '13 at 20:20

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • While this link (drupal.org/node/102338) is for Drupal 6, it gives a great overview of Drupal's menu system and callbacks and so forth that detail how (IMHO) you should set up logic for when a button/link is clicked on your site. – Jimajamma Dec 15 '13 at 19:12
  • There's so many problems with the approach to solution here, that it's hard to know where to begin. Scrap everything, and start reading from the link Jimajamma gave you. – Letharion Dec 16 '13 at 20:20
3

Extremely broad question, so an extremely broad answer...

Use the Batch API.

If you need more code examples than the docs page provides, the examples module has a lot of good, related code.

0

What @Clive said -- that's the best way to execute a long process in manageable chunks -- but if you also want to kick this off in the background without reloading the page, you'll want to use the Ajax framework to execute it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.