1

I would like to know how to fake a node in Drupal. I have a table with drawings. The drawings have non unique names. For each drawing I want to be able to create a page using the unique id of the drawing:

like so: http://mysite.com/drawing/100

I don't want to create nodes for each drawing but still be able to have a theme template to show the contents of the drawing record.

How do I do that. And if this is possible how do I access the drawing number in my template page?

Thanks a lot!

1
  • I don't need drawings on the page, the question is how to have a themed node for each drawing without actually creating the nodes.
    – user13622
    Feb 12, 2013 at 8:32

1 Answer 1

0

What you are asking is rather basic module development. Setting up a page that takes an argument.

Check out the Example module, and more specifically the page_example module and page_example_arguments(). That contains the base of what you need.

5
  • Thanks. I looked at the example. What I don't see in the example is where the template file comes in. I want a template like page--drawing.tpl.php to handle the page generation.
    – user13622
    Feb 12, 2013 at 9:06
  • To have a template generate my content for each drawing item, I used the theme_render_template function. Maybe this is also possible using a render array as done in the examples (referenced by enzipher), but I don't know how. So far theme_render_template does what I want.
    – user13622
    Feb 12, 2013 at 10:31
  • You don't necessarily need a tpl.php file when you're generating output in a custom module. You can also generate a render array containing html in your menu callback. If you do want to use template files, implement hook_theme in your module and add a #theme property to your render array (see also api.drupal.org/api/examples/…). Feb 12, 2013 at 10:38
  • Thanks. I do want to use a template file because the html will be complex and I think it will be easier and cleaner to use a template file.
    – user13622
    Feb 12, 2013 at 11:12
  • Can you tell me how to specifiy the template file in hook_theme?
    – user13622
    Feb 12, 2013 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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