Showing the News Article Title in the title when using the detailpage parameter.

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Showing the News Article Title in the title when using the detailpage parameter.

Post 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}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
moorezilla

Re: Showing the News Article Title in the title when using the detailpage parame

Post by moorezilla »

This works great! Just tried it out. Thanks, am.
User avatar
FantomCircuit
Forum Members
Forum Members
Posts: 75
Joined: Fri Nov 10, 2006 1:34 am

Re: Showing the News Article Title in the title when using the detailpage parameter.

Post by FantomCircuit »

Why is it necessary to capture the content in step 2? I can't seem to get my head around it :S
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Showing the News Article Title in the title when using the detailpage parame

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
User avatar
FantomCircuit
Forum Members
Forum Members
Posts: 75
Joined: Fri Nov 10, 2006 1:34 am

Re: Showing the News Article Title in the title when using the detailpage parameter.

Post 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*
vilkis

Re: Showing the News Article Title in the title when using the detailpage parame

Post by vilkis »

This method is also useful if one wants change title of page for news, search results and so on.
anthony
Forum Members
Forum Members
Posts: 37
Joined: Thu Jun 22, 2006 12:50 am

Re: Showing the News Article Title in the title when using the detailpage parameter.

Post by anthony »

Has anybody got this working in 1.3?  Doesn't seem to work for me.
flack
New Member
New Member
Posts: 9
Joined: Sat Jul 01, 2006 5:02 pm

Re: Showing the News Article Title in the title when using the detailpage parameter.

Post by flack »

Worked great for me!
cmsmadesimple version 1.3.1

I did exactly as in calguy1000´s post.

// Flack
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Showing the News Article Title in the title when using the detailpage parame

Post by calguy1000 »

I'm gonna have to repost on how to do this in 1.4 (it'll be simpler).
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
alby

Re: Showing the News Article Title in the title when using the detailpage parame

Post 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
viebig

Re: Showing the News Article Title in the title when using the detailpage parame

Post 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

Code: Select all

<h1>{$pagetitle}</h1>
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
alby

Re: Showing the News Article Title in the title when using the detailpage parame

Post 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
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: Showing the News Article Title in the title when using the detailpage parameter.

Post by RonnyK »

But the -call is intended for the header, not for the address-bar.... There is used..

Or am I reading wrong?

Ronny
viebig

Re: Showing the News Article Title in the title when using the detailpage parameter.

Post 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
gianpiero
Forum Members
Forum Members
Posts: 221
Joined: Sun Jan 07, 2007 4:32 pm

Re: Showing the News Article Title in the title when using the detailpage parameter.

Post by gianpiero »

Please,
can I assume that it works on latest V. "cmsmadesimple-1.4.1-full" ?

thanks in advance
gianpiero
Post Reply

Return to “Tips and Tricks”