views:

180

answers:

2

We've created a custom module for organizing and publishing our newsletter content.

The issue I'm running into now -- and I'm new to theming and Drupal module development, so it could just be a knowledge issue as opposed to a Drupal issue -- is how to get each newsletter themed.

At this point the URL structure of our newsletter will be:

/newsletters/{newsletter-name}/{edition-name}/{issue-date} which means that we can create template files in our theme using filenames like page-newsletters-{newsletter-name}-{edition-name}.tpl.php, which is great. The one issue I'm running into is that all of the content comes through in the $content variable of the theme. I'd like to have it come through as different variables (so that I can, inside the theme, place certain content in certain areas.)

Is there a proper way for doing this?

Edit: To answer some questions: The issue is a node (there are issue, edition and newsletter nodes) and the path is being set using hook_menu with wildcards and a router.

A: 

If there were better documentation for template preprocess functions, Drupal would be a lot more accessible - as it is, you need to piece together the information from a lot of different explanations. One place to start is here:

http://drupal.org/node/223430

but if you take the time to work through the tutorial below, you'll find you can do most things:

http://11heavens.com/theming-the-contact-form-in-Drupal-6

lazysoundsystem
The tutorial seems to be on the right path. Will try to work through tomorrow and see how we end up.
Michael T. Smith
Or another option, perhaps easier, is to display the node as a View, and use the Views module's template suggestions to interact with each individual field.
lazysoundsystem
Unfortunately it looked like the tutorial mostly focused on themes and not on modules itself. It was a good tutorial though.
Michael T. Smith
A: 

The best answer I could find was to add a check inside of phptemplate_preprocess_page to send the vars back to the module and have them be updated.

Like so:

function phptemplate_preprocess_page(&$vars) {
    if (module_exists('test_module')) {
        _test_module_injector($vars);
    }
}

then in my test_module.module file I created this function:

function _test_module_injector(&$vars) {
    $vars[] = call_to_other_functions_to_load_vars();
}

It seemed to work. I wish there was a way to do this without having to touch the theme's template.php file, but otherwise this works well.

Michael T. Smith
What's the problem with touching the template.php file? This is where theming related coding is meant to be done.
lazysoundsystem

related questions