[development] how to create channel based template callback

Wang Zi Feng frank.zifeng at gmail.com
Thu Oct 1 06:49:54 UTC 2009


Hi Andrew, thanks for your instruction.

I tried what you suggested. by using modulename_preprocess_page() theme
hook, different template page.tpl.php file could be implemented by different
path request.

Could you also see the code for me, I wonder if any better way to get same
result?

the hook_menu path is games, and it will invoke page-games.tpl.php when
visit ?q=games link.

function showpath_preprocess_page(&$variables){

if(drupal_strtolower(arg(0))=='games'){
    $suggestions[] = 'page-games';
    $variables['template_files']=$suggestions ;



}
}

THanks for your kind help

Frank




2009/9/28 andrew morton <drewish at katherinehouse.com>

> I'm not totally clear what you're trying to do but it seems like you
> could use a preprocess hook (e.g. modulename_preprocess_page()) to
> alter the 'template_files' variable that the theme system uses to find
> candidate files. I'd suggest reviewing the code in
> template_preprocess_page() to see how the list of candidates is
> assembled.
>
> andrew
>
> On Mon, Sep 28, 2009 at 3:34 AM, wang zifeng <frank.zifeng at gmail.com>
> wrote:
> > Hey Guys, first I am new to drupal development and try to learn
> everything
> > about drupal by scratch. My questions might be easy to you but still hard
> > for me, so any reply is welcomed and appreciated.
> >
> > Recently, I am going to create a customize module that to show all the
> blog
> > members with their avatars triggering by hook_menu ‘?q=blog’ path.
> >
> > I write the code as what the drupal module development guide taught,
>  first
> > to use hook_menu to route the path as well as the callback function, then
> > use hook_theme to state the template, and then use theme() function in
> the
> > customize function to call template, last is use template_preprocess
> > function to create the variables before it pass to template file.
> >
> > But I found, all the variables that passed to the template file was
> packed
> > into ‘contents’ region finally and placed into the template file. In
> other
> > words, I can’t change the variable into other region, so that let me
> create
> > a fully customize template for a specific path.
> >
> > For a clearer understanding of my problem:
> >
> > For example, like the difference between page.tpl.php and
> > page-front.tpl.php, the second one could be fully customized with
> regions.
> >
> >  If I want to call page-blogmember.tpl.php trigger by ‘?q=blogmember ‘ to
> > show all the blog avatars but with a fully customized region template,
> how
> > can I do.  Like creating customized channel by ?q=video or ?q=game.
> >
> > Thanks
> >
> > Frank
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.drupal.org/pipermail/development/attachments/20091001/52802724/attachment-0001.htm>


More information about the development mailing list