Page 1 of 1
[SOLVED] Adding to/setting page title from within a module
Posted: Wed Sep 21, 2011 9:26 pm
by kidcardboard
Is it possible? I've tried
Code: Select all
$contentobj = $gCms->variables['content_obj'];
$contentobj->mName = "Lorem ipsum | {$contentobj->mName}";
but by the time this code runs the page title has already been set. I could've sworn that I've come across this before and found a solution for it, but I think that was well over a year ago and I can't even remember what project that was for nevermind being able to find it in the forums.
Re: Adding to/setting page title from within a module
Posted: Wed Sep 21, 2011 9:45 pm
by kidcardboard
Right after I posted this I had a hunch where I did it and was right. For anyone else who is curious how to do this it is as follows.
In your page template remove
and replace it with
Code: Select all
{content assign="capturedcontent"}
Then change your title tag to
Code: Select all
<title>{if isset($pagetitle)}{$pagetitle}{else}{title}{/if}</title>
or structure it however you want. Then from within your module you can set {$pagetitle} to whatever you want.
Then replace
with
Re: [SOLVED] Adding to/setting page title from within a modu
Posted: Wed Sep 21, 2011 10:14 pm
by calguy1000
Your instructions are just... well wrong... I blogged and wrote an article about this YEARS ago.
Step 1:
ensure $config['process_whole_template'] = false; in the config.php
Step 2:
In your module template code (usually a detail template) do something like:
{assign var='title' value=$entry->title}
Step 3:
In your page template:
<title>{if isset($title)}{$title}{else}{title}{/if}</title>
Re: [SOLVED] Adding to/setting page title from within a modu
Posted: Mon Sep 26, 2011 3:26 pm
by kidcardboard
That's much easier. Thanks.