Page 1 of 3
Showing the News Article Title in the title when using the detailpage parameter.
Posted: Mon Nov 05, 2007 9:06 pm
by calguy1000
Actually, this is a variation on another example I wrote on how to display the article template, but it's very useful to know that you can change the title area of a detail page, when using the 'detailpage=' parameter of the news or any other module. Here it is in just a few simple steps:
1) Modify your news detail templates and add this line:
Code: Select all
{assign var='detail_title' value=$entry->title}
2) Capture your page content in a variable
a) Add this code into the section of your page template:
Code: Select all
{capture assign='captured_content'}{content}{/capture}
b) Replace the {content} tag lower in your template with {$captured_content}
3) Replace the title section of your page template to look something like this:
Code: Select all
{if isset($detail_title)}
<title>{sitename} - {$detail_title}</title>
{else}
<title>{sitename} - {title}</title>
{/if}
Re: Showing the News Article Title in the title when using the detailpage parame
Posted: Mon Nov 05, 2007 9:16 pm
by moorezilla
This works great! Just tried it out. Thanks, am.
Re: Showing the News Article Title in the title when using the detailpage parameter.
Posted: Mon Nov 19, 2007 12:15 am
by FantomCircuit
Why is it necessary to capture the content in step 2? I can't seem to get my head around it :S
Re: Showing the News Article Title in the title when using the detailpage parame
Posted: Mon Nov 19, 2007 12:34 am
by calguy1000
It's an 'order of execution' thing.... unless you execute the news module early, the smarty variable for the page title won't be adjusted until after the ... tag is already set.... therefore you need to do the capture stuff, ahead of the title.
Re: Showing the News Article Title in the title when using the detailpage parameter.
Posted: Mon Nov 19, 2007 5:59 am
by FantomCircuit
Ahh, i see now. I have implimented this on a big site and it is working well. I never would have figured this out myself
*applauds calguy*
Re: Showing the News Article Title in the title when using the detailpage parame
Posted: Mon May 26, 2008 7:50 am
by vilkis
This method is also useful if one wants change title of page for news, search results and so on.
Re: Showing the News Article Title in the title when using the detailpage parameter.
Posted: Mon Jun 30, 2008 3:18 pm
by anthony
Has anybody got this working in 1.3? Doesn't seem to work for me.
Re: Showing the News Article Title in the title when using the detailpage parameter.
Posted: Fri Jul 25, 2008 3:35 pm
by flack
Worked great for me!
cmsmadesimple version 1.3.1
I did exactly as in calguy1000´s post.
// Flack
Re: Showing the News Article Title in the title when using the detailpage parame
Posted: Fri Jul 25, 2008 3:39 pm
by calguy1000
I'm gonna have to repost on how to do this in 1.4 (it'll be simpler).
Re: Showing the News Article Title in the title when using the detailpage parame
Posted: Tue Aug 19, 2008 1:16 pm
by alby
FOR CMSMS 1.4+
1. Layout > Templates
Copy your template in new template: page-news and substitute {title} row with:
Code: Select all
{if isset($pagetitle)}<title>{$pagetitle} :: {sitename}</title>
{else}<title>{title} :: {sitename}</title>
2. Content > Pages
Create a new page for display news detail: page-news
WITH template page-news
3. config.php
Turn false to: $config['process_whole_template'] =
false;
4. Call your news with:
{cms_module module='News' [... options ...]
detailpage='pagina-news'}
Alby
Re: Showing the News Article Title in the title when using the detailpage parame
Posted: Wed Aug 20, 2008 6:38 pm
by viebig
alby wrote:
FOR CMSMS 1.4+
1. Layout > Templates
Copy your template in new template: page-news and substitute {title} row with:
Code: Select all
{if isset($pagetitle)}<title>{$pagetitle} :: {sitename}</title>
{else}<title>{title} :: {sitename}</title>
2. Content > Pages
Create a new page for display news detail: page-news
WITH template page-news
3. config.php
Turn false to: $config['process_whole_template'] =
false;
CMSMS Jamaica
4. Call your news with:
{cms_module module='News' [... options ...]
detailpage='pagina-news'}
Alby
Hello Alby
That is working just great but I´m facing something strange (i dont know if its me :>)
That works:
Code: Select all
{if isset($pagetitle)}<title>{$pagetitle} :: {sitename}</title>
{else}<title>{title} :: {sitename}</title>
but if try after that somethign like
It doesnt work.. any hints..
ps.
This works too
Code: Select all
{if isset($pagetitle)}<title>{$pagetitle}{$pagetitle}{$pagetitle} :: {sitename}</title>
{else}<title>{title} :: {sitename}</title>
the problem resides on the second call
Re: Showing the News Article Title in the title when using the detailpage parame
Posted: Wed Aug 20, 2008 8:01 pm
by alby
viebig wrote:
the problem resides on the second call
humm, confirm

I don't know if is the second call or in body process
Alby
Re: Showing the News Article Title in the title when using the detailpage parameter.
Posted: Wed Aug 20, 2008 8:08 pm
by RonnyK
But the -call is intended for the header, not for the address-bar.... There is used..
Or am I reading wrong?
Ronny
Re: Showing the News Article Title in the title when using the detailpage parameter.
Posted: Thu Aug 21, 2008 2:31 am
by viebig
Sorry guys,
I get confused onthat new template processing.
It wont work on body, not this way, but it will work in any part of the head section.
I did a workaround like:
Code: Select all
{content block='meta_description' wysiwyg='false' assign='meta_description'}
{content block='meta_keywords' wysiwyg='false' assign='meta_keywords'}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<__html xmlns="http://www.w3.org/1999/xhtml">
<head>
{if isset($pagetitle)}
{capture assign='the_pagetitle'}{$pagetitle} - {sitename}{/capture}
{else}
{capture assign='the_pagetitle'}{title} - {sitename}{/capture}
{/if}
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="{$meta_description|strip_tags|summarize:30:""|trim}"/>
<meta name="keywords" content="{$meta_keywords}" />
<title>{$the_pagetitle}</title>
{stylesheet}
</head>
</__body>
{content assign='mycontent'}
<div id="outer">
<div id="header">
<h1>Guilherme Viebig</h1>
<h2>Web Standards, Acessibilidade e SEO</h2>
</div>
<div id="menu">
{menu template="minimal_menu.tpl" number_of_levels=1}
<div class="clear"></div>
</div>
<div id="content">
<div id="primaryContentContainer">
<div id="primaryContent">
{breadcrumbs}
{if isset($pagetitle)}
>> {$pagetitle}
{/if}
<h1>
{if isset($pagetitle)}
{$pagetitle}
{else}
{title}
{/if}
</h1>
this works, but if I put the $the_pagetitle variable on body section it wont work
Re: Showing the News Article Title in the title when using the detailpage parameter.
Posted: Fri Nov 21, 2008 10:37 am
by gianpiero
Please,
can I assume that it works on latest V. "cmsmadesimple-1.4.1-full" ?
thanks in advance
gianpiero