[SOLVED] How can I display News title in Page title ?
[SOLVED] How can I display News title in Page title ?
My general template currently has the standard thing :
ACME Company - {title}
So when I display a News with title "New Office in New York" on page "Company News" , I only get "ACME Company - Company News" in page title.
I'd like to get "ACME Company - Company News - New Office in New York" in title - so Google would index it better...
(using php4 and CMSMS 0.11.2)
How can I achieve this ?
ACME Company - {title}
So when I display a News with title "New Office in New York" on page "Company News" , I only get "ACME Company - Company News" in page title.
I'd like to get "ACME Company - Company News - New Office in New York" in title - so Google would index it better...
(using php4 and CMSMS 0.11.2)
How can I achieve this ?
Last edited by fredt on Mon May 19, 2008 5:45 pm, edited 1 time in total.
Re: How can I display News title in Page title ?
Please... Can't this been achieved 
Can you give me a starting point ?
(Desperate) Fred

Can you give me a starting point ?
(Desperate) Fred
Re: How can I display News title in Page title ?
I believe that there is no option right now which would do what you want. I was sure this would work somehow (creating a detailpage and a single news template with special head-tags) but it didn't work as expected since I would need two modules-tags for News on one page which does not work with my install (0.12.1) ... maybe someone else has a good idea on how to grab parts of the {content} and push it to {title} if needed. Maybe this should be a feature request for an attribute in title.
Regards,
Nils
Regards,
Nils
Re: How can I display News title in Page title ?
I think the only real "clean" way to do this is the make a module API callback.
Obviously, you could hack the title tag/plugin apat and stuff it in there. However, I usually look for a cleaner solution...
The title is sitting in
$gCms->variables['pageinfo']->content_title. Now, the problem is that you need to get that changed out before the {title} tag is rendered. This, of course, will most likely happen BEFORE the {content} tag that you're going to spit the news out in is rendered. So, you're going to have to get in there earlier in the rendering loop.
TemplatePostCompile is probably your best bet, though it's not tested. I would add that to the news module (or better yet, make your own one-off module that does this one thing) and then do a bit of quick url parsing to figure out the news article. Then query, overwrite the existing title, and done.
A little less hacky, plus you get under the CMSMS hood a little more.
I'll see what I can do about getting a callback to use in the future to make it about 10,000x easier.
Obviously, you could hack the title tag/plugin apat and stuff it in there. However, I usually look for a cleaner solution...
The title is sitting in
$gCms->variables['pageinfo']->content_title. Now, the problem is that you need to get that changed out before the {title} tag is rendered. This, of course, will most likely happen BEFORE the {content} tag that you're going to spit the news out in is rendered. So, you're going to have to get in there earlier in the rendering loop.
TemplatePostCompile is probably your best bet, though it's not tested. I would add that to the news module (or better yet, make your own one-off module that does this one thing) and then do a bit of quick url parsing to figure out the news article. Then query, overwrite the existing title, and done.
A little less hacky, plus you get under the CMSMS hood a little more.

I'll see what I can do about getting a callback to use in the future to make it about 10,000x easier.
Re: How can I display News title in Page title ?
Pheewwww.... THAT's a start point. I'll have no excuse not trying.
So... let's go under the hood
. I'll post an update later (success or ...success)
.
So... let's go under the hood


Re: How can I display News title in Page title ?
OK, I'm going crazy. I thought I had found a solution, but there must be something wrong somewhere. 
If I add this to News.module.php, in Class New :
1. It works ONLY IF $config['debug'] = true; in config.php (I have "MyTitle" on browser title);
2. And it applies to ALL pages - not only those with News
Arggghhh, I see why while writing this: I display News in left margins on all pages.
OK, forget this Point 2.
In the complete solution:
I first get the News title in TemplatePostCompile function and write it in a global PageInfo variable (no url parsing!) :
I've copied function.title.php ({title} tag) to function.title_news.php, which displays $pageinfo->content_title_news - so now I have a title_news tag.
Then I display my News page through a "My_News" template, with
... but, alas, alas, i only works if Debug is True.
Will you help me ?
(Oops - almost forgot : running 0.11.2 under Apache 1.3.34 and php 4.4.2)

If I add this to News.module.php, in Class New :
Code: Select all
function TemplatePostCompile()
{
global $gCms;
$gCms->variables['pageinfo']->content_title = "MyTitle";
}
2. And it applies to ALL pages - not only those with News

OK, forget this Point 2.
In the complete solution:
I first get the News title in TemplatePostCompile function and write it in a global PageInfo variable (no url parsing!) :
Code: Select all
//get the current Article ID from smarty
$local_smarty_id = $gCms->smarty->id;
$local_articleid = $gCms->smarty->params[$local_smarty_id . "articleid"];
if ($local_articleid <> "") {
//Query the db and get the title
$myquery = "SELECT mn.*, mnc.news_category_name FROM ".cms_db_prefix()."module_news mn LEFT OUTER JOIN ".cms_db_prefix()."module_news_categories mnc ON mnc.news_category_id = mn.news_category_id WHERE status = 'published' AND news_id = ?";
$mydb = $this->cms->db;
$mydbresult = $mydb->Execute($myquery, $local_articleid);
while ($myrow = $mydbresult->FetchRow())
{
$mytitle = $myrow['news_title'];
}
//Add Current News Title to smarty vars as : content_title_news - will be displayed by the new "Title_News" tag (extending Title)
$gCms->variables['pageinfo']->content_title_news = $mytitle;
}
Then I display my News page through a "My_News" template, with
Code: Select all
<title>General title - {title} : {title_news}</title>
Will you help me ?
(Oops - almost forgot : running 0.11.2 under Apache 1.3.34 and php 4.4.2)
Re: How can I display News title in Page title ?
Thta's because debugging mode cancels the caching of pages. You have to use some smarty magic to get around that one (insert maybe?)fredt wrote: 1. It works ONLY IF $config['debug'] = true; in config.php (I have "MyTitle" on browser title);
Mambo sucks, that's why I am here.
Now they call it Joomla, but it still sucks!
CMSMS rules!
Now they call it Joomla, but it still sucks!
CMSMS rules!
Re: How can I display News title in Page title ?
Thanks for your prompt answer.
I've been looking in code and forum - couldn't find a way to achieve this. Can you please point me out to an example ?
(Pages displaying News are NOT checked as Cached).
... I now have the feeling function TemplatePostCompile() should be told which template to process... Any clue on this ??
I've been looking in code and forum - couldn't find a way to achieve this. Can you please point me out to an example ?
(Pages displaying News are NOT checked as Cached).
... I now have the feeling function TemplatePostCompile() should be told which template to process... Any clue on this ??
Re: How can I display News title in Page title ?
This option would be nice!
Very Nice!
i've been checking google all day and trying to check if they index CMSMS websites in a good way.
it seems that it doenst want to index the news pages and that a pitty!!
the current raking of the website im building totally relies on tha (34 pages of results)
If i can put the news title in the topic, that would help certainly
i keep my fingers crossed for the full release of cmsms!!
Regards,
Rick - Amsterdam
Very Nice!
i've been checking google all day and trying to check if they index CMSMS websites in a good way.
it seems that it doenst want to index the news pages and that a pitty!!
the current raking of the website im building totally relies on tha (34 pages of results)
If i can put the news title in the topic, that would help certainly
i keep my fingers crossed for the full release of cmsms!!

Regards,
Rick - Amsterdam
Re: How can I display News title in Page title ?
This patch may help you (though didn't help me):
* News Module Patch [#1325] Adds Article Title to Page Title
Not sure if my problem is related to server settings, or if this patch just doesn't work in Black Rock...
* News Module Patch [#1325] Adds Article Title to Page Title
Not sure if my problem is related to server settings, or if this patch just doesn't work in Black Rock...
Re: How can I display News title in Page title ?
This patch from Elijah solved my issue : http://forum.cmsmadesimple.org/index.ph ... 50175.html
Thanks A LOT, Elijah !
Thanks A LOT, Elijah !