Page 1 of 2

Get News Article Title Displayed in Page Title

Posted: Sat Feb 10, 2007 1:17 am
by Elijah Lofgren
To get News Article Title in Page Title like I just got working on this page: http://www.elijahlofgren.com/news/241/56/

Update: The instructions below are now outdated. No source modification is necessary. See this post:  http://forum.cmsmadesimple.org/index.ph ... l#msg58559


1. Open modules/News/action.detail.php
2.Find this line:

Code: Select all

$onerow->title = $row['news_title'];
3.After that line add this code on a new line:

Code: Select all

$this->news_title = $row['news_title'];
4.Log into your CMSMS Admin Panel
5.Go to "Extensions » User Defined Tags"
6.Click the "Add User Defined Tag" link.
7.In the "*Name:" field paste this name (can really be anything as long as no spaces or special chars):

Code: Select all

add_news_title_to_page_title
8.In the "*Code" field paste this:

Code: Select all

global $gCms;
$module =& $gCms->modules['News']['object'];
if (isset($module->news_title))
{
	$text = $module->news_title;
	if (function_exists('str_ireplace'))
	{
		$params['content'] = str_ireplace('<title>', '<title>'.$text. ' - ', $params['content']);
	}
	else
	{
		$params['content'] = eregi_replace('<title>', '<title>'.$text. ' - ', $params['content'] );
	}
}
9.Click the "Submit" button
10.Now go to "Extensions » Events"
11.Click on the "ContentPostRender" link (Description is "Sent before the combined html is sent to the browser") URL will be like: /admin/editevent.php?action=edit&module=Core&event=ContentPostRender
12.From the dropdown  select "add_news_title_to_page_title"
13.Click the "Add" submit button.

Whew, now when a news article is viewed, the page title should have the article title in it.

Hope this helps someone,

Elijah

Re: Get News Article Title Displayed in Page Title

Posted: Sat Feb 10, 2007 2:36 am
by carasmo
Wowie! :) Thanks!

Re: Get News Article Title Displayed in Page Title

Posted: Sat Feb 10, 2007 2:55 am
by carasmo
Works wonderfully! Thanks again. Very, very helpful mod. Easy to understand directions.

Re: Get News Article Title Displayed in Page Title

Posted: Sat Feb 10, 2007 2:57 am
by Elijah Lofgren
carasmo wrote: Works wonderfully! Thanks again. Very, very helpful mod. Easy to understand directions.
Glad I could help. :)

Re: Get News Article Title Displayed in Page Title

Posted: Mon Feb 12, 2007 10:47 pm
by PatDeLux
Worked fine on first try.Thanks !!!  ;D

Re: Get News Article Title Displayed in Page Title

Posted: Wed Feb 21, 2007 6:57 pm
by carasmo
How to get the pretty urls to work with news?

news-title-is-the-url

I really, really need it.

Re: Get News Article Title Displayed in Page Title

Posted: Sat Feb 24, 2007 6:32 pm
by tntstudio
Dear Elijah Lofgren,

Thank you this has helped me very much too! I have been having trouble with CMSMS's news plugin for sometime now, and this is one of the solutions I have been looking for.

Re: Get News Article Title Displayed in Page Title

Posted: Tue Mar 06, 2007 7:26 pm
by reidjazz
Elijah,
God has blessed you with many gifts...great coding, generosity...I'm sure there are others.

Many thanks! It's the small things that make the biggest difference most of the tiime!

Todd Reid

Re: Get News Article Title Displayed in Page Title

Posted: Thu Mar 22, 2007 4:48 pm
by brainpoo
You.

Are.

Awesome.


Thank you so much, I've been looking for this solution.  This is totaly great, and thank you so much!

Re: Get News Article Title Displayed in Page Title

Posted: Tue Mar 27, 2007 1:54 pm
by calguy1000
Elijah, it'd be cool if you made this a bit more generic.  Such that if you wanted to add stuff to the page title, you could just add things into smarty in either the page template, news, questions, etc, etc. and then use your UDT to handle modifying the title tag.

i.e. this could be added to the questions module detail template:

Code: Select all

{assign var='title_str' value=$record->question}
and then your UDT could use the value from smarty in the str_ireplace, etc.

Code: Select all

global $gCms;
smarty =& $gCms->getSmarty();
$text = $smarty->get_template_vars('title_str');
if (function_exists('str_ireplace'))
{
   ...
}

I'd love to include a UDT like this with the core.
else
{
   ...
}

Re: Get News Article Title Displayed in Page Title

Posted: Wed Apr 04, 2007 5:57 pm
by Elijah Lofgren
Turin wrote: This has stopped working in 1.0.5.
You'll probably need to edit the News file again.

Re: Get News Article Title Displayed in Page Title

Posted: Wed Apr 18, 2007 5:53 am
by yankee80
Thanks, this worked great!

Our SEO guy says that NOT displaying unique titles for news-details pages is an SEO catastrophe.

I think there should be a checkbox called "display news title in browser title" or smth. Who should I email this suggestion to?

Kind regards
Eric

Re: Get News Article Title Displayed in Page Title

Posted: Tue May 08, 2007 7:55 pm
by pgoneill
Just did this and it's working in 1.0.6.  Thanks for the tip, great work!

Re: Get News Article Title Displayed in Page Title

Posted: Tue May 08, 2007 9:14 pm
by moorezilla
yeah... this kicks ass. nice work.

this going to make it into 1.1?

Re: Get News Article Title Displayed in Page Title

Posted: Tue May 08, 2007 9:32 pm
by Elijah Lofgren
moorezilla wrote: this going to make it into 1.1?
Modifying the source code is no longer necessary: http://forum.cmsmadesimple.org/index.ph ... l#msg58559 :)