----- Original Message -----
From: "Max Clark" <[EMAIL PROTECTED]>
How do I move the header to
a shared component and pass the title method to the shared component?
i.e. <& /shared/header.mhtml &>
Thanks,
Max
==============
Max, I am new to mason and had the same problems you have with titles... I
finally came up with something that works well. I have this setup:
index.html
autohandler
header.html
hitting "index.html" calls the autohandler which includes these lines to
show the header and then index.html:
-----------
<% $m->comp("/header") %>
% $m->call_next();
-----------
header.html includes this to call the title from the source file
(index.html):
-----------
<title><& REQUEST:htmlTitle &></title>
-----------
index.html includes:
-----------
<%method htmlTitle>
<% $siteData{'site_name'} %> - My site title
</%method>
-----------
$siteData is my own "global" that I pass around that includes the name of
the website, so I can say "Joe Smith's Site - My Site Title" -- the reason I
do this is that I am setting up a framework where depending on the URL i can
reuse the code for different sites, so I need to pass the $siteData data --
you don't need this, just remove that.
Oh one other tip -- let's say you want index.html to call one of two
different files depding on a variable $a which can be 1 or 2... and you want
THOSE files to include the title. You do something like this:
index.html
-----------
<& "/index_$a.html" &>
<%method htmlTitle>
<%init>
$m->fetch_comp("/index_$a.html")->call_method('htmlTitle');
</%init>
</%method>
-----------
And include the <%method htmlTitle> in the /index_1.html or /index_2.html
etc.... basically this chains the title name. The reason I am doing this
is that my site is going to be able to do "cobrands", meaning I can have
different looks and feels for index.html depending on what the URL is for
the site -- so index_1.html may look one way and index_2.html may look
another. $siteData will include all of that information and is setup by
autohandler -- it's passed around as a global to everyone.
This was the cleanest way I could come up with to do it. I looked into
doing multiple source paths via apache and the special settings in mason,
but that does not work for my situation as the number of "index_X.html"
sites will be dynamic and I will be adding them all the time... and I don't
want 1,000 different source directories for one occasional file change.
It seems this setup is pretty efficient, just make sure to use the
$m->cache_self option wherever you can. I am getting over 100-200 hits per
second to my front page.
Hope this helps...
-John
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users