Page 4 of 6

Re: Search Engine Friendly URLS with News Module

Posted: Thu Mar 15, 2007 4:37 am
by carasmo
Yes. It'd be great to have the breadcrumb indicate the category one is in. The return Id just goes back to the main, when it ought to go back to the parent category of that article.

Thanks ! I hope this is resolved soon, it's something that I would like too.

Re: Search Engine Friendly URLS with News Module

Posted: Mon Mar 19, 2007 10:33 am
by baselve
Elijah, thanks for your great work. I have still one question.. Is it also possible that the xml/rss feed is feeded with the search engine friendly urls? At the moment the rss feed shows the "old" urls. Hope there is a solution for this, would be great!! ;)

Re: Search Engine Friendly URLS with News Module

Posted: Mon Mar 19, 2007 1:52 pm
by Elijah Lofgren
baselve wrote: Elijah, thanks for your great work. I have still one question.. Is it also possible that the xml/rss feed is feeded with the search engine friendly urls? At the moment the rss feed shows the "old" urls. Hope there is a solution for this, would be great!! ;)
It's possible, but sadly I don't have time at the moment (homework).

I think if you open modules/News/action.rss.php there should be a call to CreateLink() that would match what was changed in action.default.php

Later,

Elijah

Re: Search Engine Friendly URLS with News Module

Posted: Mon Mar 19, 2007 9:34 pm
by baselve
Elijah Lofgren wrote:
baselve wrote: Elijah, thanks for your great work. I have still one question.. Is it also possible that the xml/rss feed is feeded with the search engine friendly urls? At the moment the rss feed shows the "old" urls. Hope there is a solution for this, would be great!! ;)
It's possible, but sadly I don't have time at the moment (homework).

I think if you open modules/News/action.rss.php there should be a call to CreateLink() that would match what was changed in action.default.php

Later,

Elijah
Thank you very much! Adding these lines does the trick!

Code: Select all

			$titleSEO = preg_replace("/[^\w-]+/", "-", $row['news_title']);
            $categorySEO = preg_replace("/[^\w-]+/", "-", $row['news_category_name']);
			$onerow->link = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, '', $sendtodetail,'', true, false,'',true, 'News/'.$categorySEO.'/'.($detailpage!=''?$detailpage:$titleSEO.'-'.$row['news_id']));

Re: Search Engine Friendly URLS with News Module

Posted: Thu Apr 26, 2007 10:06 am
by hadion
My customer ordered windows hosting, so I had to use isapi rewrite. Now my website works well, except the news module.
The rewrite module works well with apache rewrite, so my question is, what needs to be changed in my files to let this module work again?

here is my httpd.ini:

Code: Select all

[ISAPI_Rewrite]

# 3600 = 1 hour
CacheClockRate 3600

RepeatLimit 32

# Block external access to the httpd.ini and httpd.parse.errors files
RewriteRule /httpd(?:\.ini|\.parse\.errors).* / [F,I,O]

# Block external access to the Helper ISAPI Extension
RewriteRule .*\.isrwhlp / [F,I,O]

# Defend your computer from some worm attacks
RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]

#RewriteCond Host: (.*)
#RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [I,R]

#RewriteRule ^(.+)$ index.php\?page=$1 [I,L]
RewriteRule /([^/]+)\.html /index.php\?page=$1 [I,L]
Please help me

Re: Search Engine Friendly URLS with News Module

Posted: Thu Apr 26, 2007 10:43 am
by Pierre M.
Hello hadion,
hadion wrote: My customer ordered windows hosting, ... isapi rewrite. ... httpd.ini ...
I'm sorry, I don't know Windows hosting nor the isapi thing. I'm used to httpd.conf and .htaccess.
This thread demonstrates that non windows hosting rocks. Your customer has ordered something else. Of course he can be disappointed.
But there may be a nice side of the story : if your customer demands windows hosting, he must have good reasons. May be the windows/isapi knowledge that can tune the rewrite ? I'm confident the rewrite rules can work under isapi, I just don't know how.
Pierre M.

Re: Search Engine Friendly URLS with News Module

Posted: Sat Apr 28, 2007 7:21 am
by hadion
Yeah i know linux is better. But my customer allready ordered the hosting before I started with the website. Everything works now, except the news module... Anyone who can help me?

Re: Search Engine Friendly URLS with News Module

Posted: Tue Sep 11, 2007 9:02 am
by Terabyte
hadion wrote: Yeah i know linux is better. But my customer allready ordered the hosting before I started with the website. Everything works now, except the news module... Anyone who can help me?
Use the version 3 of isapi_rewrite. It is almost 99% compatible with the Apache mod_rewrite.

Re: Search Engine Friendly URLS with News Module

Posted: Wed Oct 31, 2007 12:18 pm
by macmukka
Hi

- My first post here, I  use several CMSs and you can tell much from the tone of the community - I havent seen to much annimosity yet here, so I'm liking what I see!

I am doing a favour for a friend who has a CMSMS site. The company that built the site for him are claiming that friendly news urls would be difficult to implement which I thought was probably wrong....

So I am trying to help him out by switching on friendly URLs for the news section.

I have tried all the instructions here, tried patching files, over writing them and making the changes by hand - nothing... The URLs in the news section do not seem to change, I have tried clearing the cache also nothing... stranglely though if I create a new news story this does not appear anywhere or if I change the title of a news story this is not reflected in the front end.

can anyone help me - I am thinking perhaps the changes are not compatiable with the versions of CMS MS and the news module I am using:-

CMSMS - ver 1.2
News - ver 2.5.1

Any help would be just great.

Thanks -

Re: Search Engine Friendly URLS with News Module

Posted: Mon Jan 21, 2008 11:43 am
by Courty
Just spent an hour working through the examples and got it all working on CMSMS 1.2.3

Elijah, your a legend !!! thanks for your work on this.

Courty  8)

Re: Search Engine Friendly URLS with News Module

Posted: Mon Jan 21, 2008 12:41 pm
by macmukka
care to share courty? ;-)

Re: Search Engine Friendly URLS with News Module

Posted: Mon Jan 21, 2008 3:13 pm
by carasmo
I did it too a while back, but I couldn't get the templates to work. So only the default, any other wouldn't work.

Please share what you did.

Re: Search Engine Friendly URLS with News Module

Posted: Tue Jan 22, 2008 10:02 am
by Courty
Hi Guys,

Yes, no problem...

You have to edit 4 files from the Modules / News folder..
action.default.php
action.details.php
News.module.php
and action.rss.php

action.default.php
Find

Code: Select all

$onerow->titlelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $row['news_title'], $sendtodetail, '', false, false, '', true, $prettyurl);
$onerow->morelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $moretext, $sendtodetail, '', false, false, '', true, $prettyurl);
and REPLACE it with

Code: Select all

// SEO URL Hack
    $titleSEO = preg_replace("/[^\w-]+/", "-", $row['news_title']);
    $categorySEO = preg_replace("/[^\w-]+/", "-", $row['news_category_name']);

     $onerow->link = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, '', $sendtodetail,'', true, false,'',true, 'News/'.$categorySEO.'/'.($detailpage!=''?$detailpage:$titleSEO.'-'.$row['news_id']));
     $onerow->titlelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $row['news_title'], $sendtodetail,'',false,false,'',true,'News/'.$categorySEO.'/'.($detailpage!=''?$detailpage:$titleSEO.'-'.$row['news_id']));
     $onerow->morelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $moretext, $sendtodetail,'',false,false,'',true,'News/'.$categorySEO.'/'.($detailpage!=''?$detailpage:$titleSEO.'-'.$row['news_id']));

// SEO URL HACK

//                      $onerow->titlelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $row['news_title'], $sendtodetail, '', false, false, '', true, $prettyurl);
//                      $onerow->morelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $moretext, $sendtodetail, '', false, false, '', true, $prettyurl);

action.detail.php
Find

Code: Select all

$onerow->title = $row['news_title'];
and REPLACE it with

Code: Select all

$this->news_title = $row['news_title'];
News.module.php
Find

Code: Select all

	function SetParameters()
	{
And ADD after the {

Code: Select all

// SEO URL hack
            $this->RegisterRoute('/(?P<module>News)\/.*?\/.*\-(?P<articleid>[0-9]+)$/', array('returnid'=>'133'));
            $this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)\/d,(?P<detailtemplate>.*?)$/');
		$this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)\/d,(?P<detailtemplate>.*?)$/');
 		$this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)\/(?P<returnid>[0-9]+)$/');
 		$this->RegisterRoute('/[nN]ews\/(?P<articleid>[0-9]+)$/');
 		$this->RegisterRoute('/[nN]ews\/(?P<action>rss)\/(?P<category>.*?)$/', array('showtemplate'=>'false'));

action.rss.php

Find

Code: Select all

		while ($dbresult && $row = $dbresult->FetchRow())
		{
			$onerow = new stdClass();

			$sendtodetail = array('articleid'=>$row['news_id']);
			$onerow->link = $this->CreateLink($id, 'detail', $returnid, '', $sendtodetail,'',true,false,'',true,'news/'.$row['news_id']);
			$onerow->id = $row['news_id'];
			$onerow->title = $row['news_title'];
			$onerow->content = $row['news_data'];
			$onerow->summary = $row['summary'];
			$onerow->strippedcontent = strip_tags($onerow->content);
			$onerow->strippedsummary = strip_tags($onerow->summary);
			$onerow->postdate = $row['news_date'];
			$onerow->gmdate = gmdate('r', $db->UnixTimeStamp($row['news_date']));
			$onerow->startdate = $row['start_time'];
			$onerow->enddate = $row['end_time'];
			$onerow->category = $row['news_category_name'];

			$entryarray[]= $onerow;
		}
and REPLACE it with

Code: Select all

		while ($dbresult && $row = $dbresult->FetchRow())
		{
			$onerow = new stdClass();

			$sendtodetail = array('articleid'=>$row['news_id']);
                  $titleSEO = preg_replace("/[^\w-]+/", "-", $row['news_title']);
                  $categorySEO = preg_replace("/[^\w-]+/", "-", $row['news_category_name']);
			$onerow->link = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, '', $sendtodetail,'', true, false,'',true, 'News/'.$categorySEO.'/'.($detailpage!=''?$detailpage:$titleSEO.'-'.$row['news_id']));
                  //$onerow->link = $this->CreateLink($id, 'detail', $returnid, '', $sendtodetail,'',true,false,'',true,'news/'.$row['news_id']);
			$onerow->id = $row['news_id'];
			$onerow->title = $row['news_title'];
			$onerow->content = $row['news_data'];
			$onerow->summary = $row['summary'];
			//$onerow->strippedcontent = strip_tags($onerow->content);
			//$onerow->strippedsummary = strip_tags($onerow->summary);

			$onerow->strippedcontent = $row['news_data'];
			$onerow->strippedsummary = $row['summary'];


			$onerow->postdate = $row['news_date'];
			$onerow->gmdate = gmdate('r', $db->UnixTimeStamp($row['news_date']));
			$onerow->startdate = $row['start_time'];
			$onerow->enddate = $row['end_time'];
			$onerow->category = $row['news_category_name'];

			$entryarray[]= $onerow;
		}

I've played with the spacing and code layout so you will have to look / search the files by hand, don't use an automated tool.

You will need the standard Pretty URL's .htaccess file and Pretty URL's already working for articles etc.
The hack also fixes the RSS feed for the new URLs's.
Both Old style URL's still work so SEO is not affected.

These files are from CMSMS version 1.2.3 "Black Rock" (upgraded from 1.2.2), on Apache and Red Hat with MySQL 5 back end (not that it should make a difference..)

I have not added the hack to take out the article number so URL's look like http://mysite.com/News/General/my-story-[b]12[/b].shtml, I did look at the code but it didn't work + I ran out of time to fix it.

if you want to see it working, have a look at http://www.avicraft.co.uk

Remember to make a backup of the files BEFORE you edit them, I normally copy the file to the same folder and append the date so action.default.php becomes action.default.php.210107, then edit the original file...

Let me know if you have a problem..

Regards

Courty  8)

Re: Search Engine Friendly URLS with News Module

Posted: Tue Jan 22, 2008 3:42 pm
by Courty
carasmo wrote: I did it too a while back, but I couldn't get the templates to work. So only the default, any other wouldn't work.

Please share what you did.
Found a bug.. the Pretty URL's won't work if you have the directive {news detailpage="pagealias"} switched on, you need to just use {news} on the News page - other then that, custom templates appear to work (as long as you follow the normal coding)

Courty  8)

Re: Search Engine Friendly URLS with News Module

Posted: Wed Apr 30, 2008 1:27 pm
by relic
Courty wrote: I've played with the spacing and code layout so you will have to look / search the files by hand, don't use an automated tool.

You will need the standard Pretty URL's .htaccess file and Pretty URL's already working for articles etc.
The hack also fixes the RSS feed for the new URLs's.
Both Old style URL's still work so SEO is not affected.

These files are from CMSMS version 1.2.3 "Black Rock" (upgraded from 1.2.2), on Apache and Red Hat with MySQL 5 back end (not that it should make a difference..)

I have not added the hack to take out the article number so URL's look like http://mysite.com/News/General/my-story-[b]12[/b].shtml, I did look at the code but it didn't work + I ran out of time to fix it.

if you want to see it working, have a look at http://www.avicraft.co.uk

Remember to make a backup of the files BEFORE you edit them, I normally copy the file to the same folder and append the date so action.default.php becomes action.default.php.210107, then edit the original file...

Let me know if you have a problem..

Regards

Courty  8)
Courty,

Thanks allot for that.. but just a few questions, i am in the process of setting up an online magazine styled website (content is based on the news module) now things are working fine, apart from the display of articles, what i get is just the "text" of an article displayed on a blank white page, so its not including the site template, any ideas?

Also, is it possible to remove the "news" out of the url. e.g instead of /news/cat/title i want /cat/title is this possible?

I am running cmsms "black rock"

thanks in advance

Dave

EDIT: changed page ID and it works nicely!! ;D