[support] Templating in Drupal 5.1 - the cleanest way to do it?
Cyberswat
cyberswat at gmail.com
Tue Apr 10 20:10:18 UTC 2007
That's what I was looking for ... Thanks!
On 4/10/07, Larry Garfield <larry at garfieldtech.com> wrote:
>
>
> #################################################
> module code - mymod.php
> #################################################
>
> function mymod_foo() {
> $data = array('foo' => 'bar');
> return theme('foo_or_something', $data);
> }
>
> function theme_foo_or_someting($data) {
> return "something you do with $data that generates a string";
> }
>
> #################################################
> template.php code
> #################################################
>
> function phptemplate_foo_or_something() {
> return _phptemplate_callback('foo_or_something', $data);
> }
>
>
> #################################################
> foo_or_something.tpl.php
> #################################################
>
> <h1>I want to output value of $foo here</h1>
>
> (In this case $foo will have a value of 'bar').
>
> Cheers.
>
> --Larry Garfield
>
> On Tue, 10 Apr 2007 12:47:28 -0600, Cyberswat <cyberswat at gmail.com> wrote:
> > I have another question regarding this subject. If I create a custom
> > module
> > how do I use the templating engine to work with the output of the
> module?
> > I
> > know this code is bad, but it summarizes what I would like to do. Any
> > help
> > is appreciated as I'm starting to feel dense from not being able to
> figure
> > this out.
> >
> > #################################################
> > module code - mymod.php
> > #################################################
> >
> > function mymod_menu($may_cache) {
> > $items = array();
> > $items[] = array('path' => 'mymod_view',
> > 'title' => t('mymod_view'),
> > 'callback' => 'mymod_foo',
> > 'type' => MENU_LOCAL_TASK,
> > 'access' => user_access('view mymod'),
> > 'weight' => 0,
> > );
> > return $items;
> > }
> >
> > function mymod_foo() {
> > $data = array('foo' => 'bar');
> > return $data;
> > }
> >
> > #################################################
> > template.php code
> > #################################################
> >
> > function phptemplate_mymod_foo() {
> > return _phptemplate_callback('mymod_foo');
> > }
> >
> > #################################################
> > mymod_foo.tpl.php
> > #################################################
> >
> > <h1>I want to output value of $data['foo'] here</h1>
> >
> >
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
--
Kevin Bridges
http://www.kevinbridges.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20070410/0c338ba2/attachment.htm
More information about the support
mailing list