This is a common request, that causes a lot of confusion since cmsms changed the way the templates are processed.
This recipe apply to just for the News Module, but any other modules that are template driven.
1. process_whole_template must be disabled in config.php
open your config.php, and look for this line:
Code: Select all
$config['process_whole_template'] = true;
Code: Select all
$config['process_whole_template'] = false;
2. Assign the news title to a smarty variable
Go to Content -> News
click on "Detail Template" tab
edit your template (in most cases the default is named 'Sample', do it for every news detail template you have)
in the top of your template put this code
Code: Select all
{assign var='pagetitle' value=$entry->title}
I´m talking about the templates on Layout -> Templates
first get rid of the useless {process_pagedata} if it exists on your first line
Let's capture the content... put this in templates first line:
Code: Select all
{content assign="capturedcontent"}
Code: Select all
{$capturedcontent}
Code: Select all
<title>{sitename} - {title}</title>
Code: Select all
<title>{if isset($pagetitle)}{sitename} - {$pagetitle}{else}{sitename} - {title}{/if}</title>
On 1st step we disabled the process_whole_template directive, that,in a few words, make the the head section be processed before everything else, so when you call the news module on body, the head section is already done, so there´s no way to change the title.
By disabling this directive, we can set a variable inside any other place(modules, tags, content blocks, etc...), and it will be accessible in the head section by typing {$pagetitle}.
We can do a lot of cool things that way.
5. The best way available to display the news detail page
Create a News page and use the detailpage parameter, for example
You can put anything on the content(since the {content} will be replace for the news details). If you want this page to be visible on menu I reccomend that you add some content, like {news} so when the visitor get´s there he´ll see some content, or you can just go to the Option Tab and unmark the show on menu option.
Code: Select all
{news category="General" detailpage="news"}
6. A little bit more
I generally let the / title tag inside my cmsms template, something like:
Code: Select all
</__body>
{breadcrumbs}
<h1>{title}</h1>
<div>{content}</div>
<__body
so let´s use that {$pagetitle} again:
Code: Select all
</__body>
{breadcrumbs}
<h1>{$pagetitle}</h1>
<div>{content}</div>
<__body
Code: Select all
</__body>
{breadcrumbs}
<h1>
{if isset($pagetitle)}
{$pagetitle}
{else}
{title}
{/if}
</h1>
<div>{content}</div>
<__body
I just remembered another thing, the breadcrumbs.... this is bad because, dont matter the news detail I´m reding and the breadcrumb will always show something like:
Code: Select all
Home -> News
Code: Select all
Home -> News -> The title of the news
Code: Select all
</__body>
if{isset($pagetitle)}
{breadcrumbs} -> {$pagetitle}
{else}
{breadcrumbs}
{/if}
<h1>
if{isset($pagetitle)}
{$pagetitle}
{else}
{title}
{/if}
</h1>
<div>{content}</div>
<__body>
Let´s hope that in a near future this things can be achivied in a easier way.
Please, comment it, feedback is always appreciated.
And a special cheer to people that read this whole post! (write cheers on the end of your reply so I know that you´re read all that crap)
Regards
Viebig