Another thing I've done that can work well is to store something like
__TITLE__ in the page title, and then write a %filter section at the
end of autohandler which replaces that content with something from the
%stash (a global variable I set up that gets cleared at the start of
each request). It looks like this:
init.handler # I break this into a separate file so I can inherit
from it even from non-visual components, such as Ajax callbacks. You
can also just set all this stuff up in the .pl file that contains your
Handler.
<%init>
local(%stash) = (); # reset the stash at the start of every request
</%init>
autohandler
<%flags>
inherit => 'init.handler'
</%flags>
<head><title>__TITLE__</title></head>
<body>...
% $m->call_next;
</body>
<%filter>
my $title = 'My Site: ' . ($stash{title}||'');
s/__TITLE__/$title/;
</%filter>
page.html
<%init>
$stash{title} = 'This page title';
</%init>
blah blah
I realize this is kind of a hacky way around using methods + the like,
but it allows me to avoid having to use a %shared section in my
page.html if the contents of the title need to come from the database
(e.g. for an article page).
--Mark
On Oct 15, 2009, at 9:10 AM, Jonathan Swartz wrote:
> As other folks said, it's best to use methods or attributes to
> communicate in this way:
>
> http://www.masonhq.com/docs/manual/Devel.html#object_oriented_techniques
>
> The 'our' variable doesn't work because it is restricted to a
> particular file.
>
> On Oct 14, 2009, at 8:04 AM, Jackie Hamilton wrote:
>
>> Is there a way to pass a variable from the dhandler up to the
>> autohandler?
>>
>> I'm building a site where the autohandler constructs the html page
>> (including the page title) but the dhandler is the one that actually
>> figures out what the page content and title is supposed to be. I
>> can't figure out how to pass the $title info over. I've tried a
>> shared section in the dhandler:
>>
>> <%shared>
>> our $subpageTitle;
>> </%shared>
>>
>> And $subpageTitle gets set in the %init block of the dhandler.
>>
>> However I can't seem to access $subpageTitle in the autohandler... I
>> just get an error about "Global symbol "$subpageTitle" requires
>> explicit package name". Not sure what package name to give it for
>> the dhandler....
>>
>> Thanks!
>>
>> -kira
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart
>> your
>> developing skills, take BlackBerry mobile applications to market and
>> stay
>> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
>> http://p.sf.net/sfu/devconference_______________________________________________
>> Mason-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/mason-users
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart
> your
> developing skills, take BlackBerry mobile applications to market and
> stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Mason-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mason-users
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users