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.
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 »

carasmo wrote: I'm on a mac and I can't figure out what this tortiose is. Does it compare files and then find where to put the stuff in? Can anyone help me get pretty urls. The instructions here just don't work.

1st make sure you have your .htaccess file set up like so:
Lloyd Winthorpe III wrote: Use this slightly modified .htaccess
Options +FollowSymLinks
RewriteEngine on

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule (.*) index.php?page=$1 [QSA]
RewriteRule ^index.php$        index.php
Then download the patched files and overwrite your current one is modules/News with them:
http://forum.cmsmadesimple.org/index.ph ... ttach=1720
http://forum.cmsmadesimple.org/index.ph ... ttach=1720


Then do this to get news title working again:
Elijah Lofgren wrote: To get News Article Title in Page Title like I just got working on this page: http://www.elijahlofgren.com/news/241/56/

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'];
And also make sure that you have the following enabled in config.php

Code: Select all

#------------
#URL Settings
#------------

#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '/';

#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism?  This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = true;

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = true;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page';

Hope this helps,

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. :)
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 »

Hello,

I followed the instructions exactly and it does the same thing as before.

http://www.dropsoul.com/testCMSMS/News/ ... -Plate-21/ - 404 Not found

And no links to the articles more links is missing

http://www.dropsoul.com/testCMSMS/veg-news/
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 »

carasmo wrote: Hello,

I followed the instructions exactly and it does the same thing as before.

http://www.dropsoul.com/testCMSMS/News/ ... -Plate-21/ - 404 Not found

And no links to the articles more links is missing

http://www.dropsoul.com/testCMSMS/veg-news/
Opps, I forgot about the reason that this is a patch and not part of default news.

You need to open up.
News.module.php and change "45" in this line to the id of a page that actually exists on your website (you can find id by going to Content -> Pages):

Code: Select all

		$this->RegisterRoute('/(?P<module>News)\/.*?\/.*\-(?P<articleid>[0-9]+)$/', array('returnid'=>'45'));
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. :)
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 »

Thanks! Thanks! Thanks! Thanks! Thanks! Thanks!

BUT...The pages work,  but the "more" link is gone. Any patches or suggestions for that?
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 »

carasmo wrote: Thanks! Thanks! Thanks! Thanks! Thanks! Thanks!

BUT...The pages work,  but the "more" link is gone. Any patches or suggestions for that?
This should work....

Open modules/News/action.default.php

Find:

Code: Select all

  $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']));
After add:

Code: Select all

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

Hope this helps,

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. :)
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 »

SWEET!

Oh how I wish you could down load your brain into mine!

Tons of Thanks!
climberusa
Forum Members
Forum Members
Posts: 126
Joined: Sun Feb 26, 2006 7:10 pm

Re: Search Engine Friendly URLS with News Module

Post by climberusa »

Hi, I just downloaded your patch and it works great. I was trying to remove 'News/' in the url but it then breaks the path the detail page. Is this possible? I removed it in all three lines:

Code: Select all

                        $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']));
I also tried changing it to something mor relevant to me but it also broke the path. Is there another file or line I'm missing that would allow this?

Appreciate your work on this!
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 »

climberusa wrote: Hi, I just downloaded your patch and it works great. I was trying to remove 'News/' in the url but it then breaks the path the detail page. Is this possible? I removed it in all three lines:

Code: Select all

                        $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']));
I also tried changing it to something mor relevant to me but it also broke the path. Is there another file or line I'm missing that would allow this?

Appreciate your work on this!
Here is an updated version of hte patch that removes 'News' from the URL:
http://dev.cmsmadesimple.org/tracker/do ... 2-24.patch

If you don't want to repatch everything, just do the following.

Replace those 3 lines you pasted with this:

Code: Select all

$onerow->link = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, '', $sendtodetail,'', true, false,'',true, $categorySEO.'/'.$titleSEO.'-'.$row['news_id']);
$onerow->titlelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $row['news_title'], $sendtodetail,'',false,false,'',true,$categorySEO.'/'.$titleSEO.'-'.$row['news_id']);
$onerow->morelink = $this->CreateLink($id, 'detail', $detailpage!=''?$detailpage:$returnid, $moretext, $sendtodetail,'',false,false,'',true,$categorySEO.'/'.$titleSEO.'-'.$row['news_id']);
Then do the following:
In News.Module.php replace the Route Line with this:

Code: Select all

		// SEO URL hack
		$this->RegisterRoute('/.*?\/.*\-(?P<articleid>[0-9]+)$/', array('returnid'=>'45', 'module' => 'News'));
(Remember to change "45" back to your page id)

Hope this helps. :)

Have a great weekend,

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. :)
climberusa
Forum Members
Forum Members
Posts: 126
Joined: Sun Feb 26, 2006 7:10 pm

Re: Search Engine Friendly URLS with News Module

Post by climberusa »

Perfect! Thanks and wow that was a quick response!
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 this and now the breadcrumbs shows home when I'm in a news item.

How to get it working with the correct path?
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 »

carasmo wrote: I did this and now the breadcrumbs shows home when I'm in a news item.

How to get it working with the correct path?
Did you change "45" to the id of the page you want news to show up on?
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. :)
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 »

Thanks!

I completely blanked that.
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 »

Hi there,

Sorry for the trouble, but when I click on the print button (make print button) it prints the return url id, and not the article.
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 »

Okay,

Sorry for the confusion on my part.

The top "print" icon of the printer "printbutton.gif" prints the id page in the return id, which is just a list of all the news items, but the bottom "printlink" prints the actual article. But I need both to work.

What I'm looking for is a way to just get the url (not the a href and a complete link) that the "printlink" makes so I can use the icon of the printer,

Code: Select all

<a href="printurl"><img src="images/cms/printbutton.gif"></a>
-- this goes in the template for the news id page.


Thank you
tntstudio

Re: Search Engine Friendly URLS with News Module

Post by tntstudio »

Elijah,

Thanks again for all this work!

I have a question you seem to be the guy to ask;

Is it possible to incorporate the 'category' the article was posted to in the path of the pretty url instead of 'news'?

I am having a bit of trouble with a website I am working on (http://www.mike-miles.ca) with how news articles are presented.

If I may beg another question: Another issue related (I think) is I have several news categories. I am trying to emulate a news site with articles and have this working about 95%. To that end I have included 'headlines' on pages other then the page designated as the default news category page.

The problem I am experiencing is when I follow a link to an article (in any category) on pages other then the specified default, CMSMS forgets the category entirely (which unfortunately breaks my navigation  :-\) and the end user is taken to a category called "Main News". If you visit the URI I have provided, and you follow the article link in the lone teaser, you will see a live example of what I am referring to.

You can see what category the article originates from (source: cat_here). When you follow the "READ THE FULL ARTICLE »" link at the bottom off the homepage, as opposed to the default news page (http://www.mike-miles.ca/upcoming_events/results/) the breadcrumbs, title, and navigation are lost.

All my news links do use the summarytemplate="template_here.tpl" syntax if that helps at all.

I am not sure if this is possible. If it is, I would very much appreciate if you could provide me some insight. I believe others would certainly appreciate functionality like this.

I am more then happy to trade services if you are willing to look into this further!
Locked

Return to “Modules/Add-Ons”