I'm using a helper for static pages to add a part to the title on every page. Currently I have the following code at the top of every static page:
<?php $this->set('title_for_layout', $title->output('Nyheter')); ?>
The purpose of $title->output is to append " :: MY WEB SITE NAME". This works fine, but for simplicity I wou开发者_如何学Pythonld rather just call:
$title->title('Nyheter');
At the top of every page to set the title. The problem is that I can't call $this->set() from within the helper. Is there a way to something like this or am I completely on the wrong path here?
At the risk of being too obvious, why do you need the helper? I usually include this kind of title like:
<title><?php echo $title_for_layout . ' :: MY WEB SITE NAME' ?></title>
Plug this right into the layout and you have dynamic and static components the render nicely. For an added twist, you can filter out the " :: " if no $title_for_layout
value exists. Then all you have to worry about is setting the dynamic portion on any page that needs it.
精彩评论