Search Engine Friendly URLS with News Module

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm
Location: Florida

Re: Search Engine Friendly URLS with News Module

Post 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.
baselve

Re: Search Engine Friendly URLS with News Module

Post 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!! ;)
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am
Location: Deatsville, AL

Re: Search Engine Friendly URLS with News Module

Post 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
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
baselve

Re: Search Engine Friendly URLS with News Module

Post 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']));
hadion
Forum Members
Forum Members
Posts: 17
Joined: Thu Apr 26, 2007 10:02 am

Re: Search Engine Friendly URLS with News Module

Post 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
Pierre M.

Re: Search Engine Friendly URLS with News Module

Post 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.
hadion
Forum Members
Forum Members
Posts: 17
Joined: Thu Apr 26, 2007 10:02 am

Re: Search Engine Friendly URLS with News Module

Post 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?
Terabyte
Forum Members
Forum Members
Posts: 79
Joined: Fri Aug 18, 2006 8:57 am

Re: Search Engine Friendly URLS with News Module

Post 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.
macmukka
New Member
New Member
Posts: 6
Joined: Tue Oct 30, 2007 8:05 pm

Re: Search Engine Friendly URLS with News Module

Post 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 -
Courty
Forum Members
Forum Members
Posts: 15
Joined: Thu Jan 10, 2008 9:29 am
Location: London, UK

Re: Search Engine Friendly URLS with News Module

Post 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)
www.debinternet.co.uk - UK based CMSMS & Full Access Linux Webhosting, Site Design and Custom Coding..
macmukka
New Member
New Member
Posts: 6
Joined: Tue Oct 30, 2007 8:05 pm

Re: Search Engine Friendly URLS with News Module

Post by macmukka »

care to share courty? ;-)
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm
Location: Florida

Re: Search Engine Friendly URLS with News Module

Post 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.
Courty
Forum Members
Forum Members
Posts: 15
Joined: Thu Jan 10, 2008 9:29 am
Location: London, UK

Re: Search Engine Friendly URLS with News Module

Post 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)
www.debinternet.co.uk - UK based CMSMS & Full Access Linux Webhosting, Site Design and Custom Coding..
Courty
Forum Members
Forum Members
Posts: 15
Joined: Thu Jan 10, 2008 9:29 am
Location: London, UK

Re: Search Engine Friendly URLS with News Module

Post 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)
Last edited by Courty on Tue Jan 22, 2008 3:44 pm, edited 1 time in total.
www.debinternet.co.uk - UK based CMSMS & Full Access Linux Webhosting, Site Design and Custom Coding..
User avatar
relic
Forum Members
Forum Members
Posts: 34
Joined: Fri Dec 08, 2006 9:59 am
Location: New Zealand

Re: Search Engine Friendly URLS with News Module

Post 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
Last edited by relic on Wed Apr 30, 2008 2:42 pm, edited 1 time in total.
Locked

Return to “Modules/Add-Ons”