[support] Using the node theme or a template from custom module

Blair Wadman blair at wadmanconsulting.com
Wed May 30 18:38:12 UTC 2012


If you pass this through a theme function, you can then create a custom template file.  

Something like this:

function example_page(){
 $data = 'Lorem ipsum etc';
 $output = theme('my_custom_template', $data);

 return $output;
}

Then you can create a template in your theme layer called my_custom_template.tpl.php
In there, you can print $data and wrap it in the <p> tags. 

Don't forget to clear cache and rebuild theme registry. 

Cheers

Blair 

---

Blair Wadman   |   Wadman Consulting Limited
w: wadmanconsulting.com
w: befused.com




On Wednesday, 30 May 2012 at 15:34, Joel Willers wrote:

> Since it's not a node, it won't render like a node. Does it use page.tpl.php? Sadly, I'm no expert in template files. I'd be interested in the solution to this, so if you figure it out, could you respond and post it? Thanks!
> 
> Joel 
> 
> 
> -----Original Message-----
> From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On Behalf Of DTH
> Sent: Monday, May 28, 2012 4:43 PM
> To: support at drupal.org (mailto:support at drupal.org)
> Subject: [support] Using the node theme or a template from custom module
> 
> I've got a custom module for D7. On some pages, it returns html. I'm using this in the page callback
> 
> function example_page(){
> return array(
> "#type" => "markup",
> "#markup" => "<p>Lorem ipsum etc</p>",
> );
> }
> 
> It works fine, but the page (obviously) doesn't use my node.tpl file, and so it looks different from the rest of the site. It's not that the node.tpl file is particularly complex, but it does some things like wrap the node content in divs that have styling applied to them etc.
> 
> I could use #prefix and #suffix to wrap the above output in these divs, but is there either a) some way to reuse my node template or b) what's the best way to create a quick clone of the node template that can be reused in render arrays every time I want to output pages from my module. Do I have to call a theme function by #theme or is there a way to use an actual template file?
> --
> [ Drupal support list | http://lists.drupal.org/ ]
> -- 
> [ Drupal support list | http://lists.drupal.org/ ]
> 
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120530/7b3dd617/attachment.html 


More information about the support mailing list