I have a custom PHP application I've written that accesses an API via SOAP, processes some data from the web service, and outputs an HTML table with the results. I'm an experienced WordPress developer and have been able to add my application's functionality into WP sites by creating A custom theme and adding the PHP/HTML code directly into the homepage template.

I now have someone asking me to add this to a Drupal site (v 7.34) - the end goal is to have the HTML table that the application outputs display on the Drupal site's homepage. The site is running the Porto 2.0.3 theme if that makes a difference.

I am pretty new to Drupal and I'd like to know what the best way to accomplish this is. I looked into adding PHP directly into a block, but my application consists of 2 files (an API class and the actual code that produces the output) so I'm not sure that's a good option.

My searching leads me to believe that creating a custom module is the best path (especially since I don't want future updates to the Porto theme to break the functionality) but I'd like to confirm that before I wander down that path. Or is is better/easier to override the homepage template to add my code?

I'd really appreciate some advice from experienced devs - not looking to be spoon fed and perfectly willing to do my own research, but a helping hand from people familiar with this system would be a huge help.


The best way forward is to go ahead and create a new module. You can find the steps from this link .It also shows you how to create a block from code.

You can add your files in the module and then make a function call which returns the table and add it as your block content. You can then include your block in the home page from admin interface in any region that you want it to be.

Hope it helps.


you could include it in one of the template files page--front.tpl.php, html--front.tpl.php, node--front.tpl.php depending on its scope, and so long it was a sub-theme, upgrading would not break that, but a custom module is probably the best route - most would argue that that type of processing should be kept out of the theme layer.

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