Page 1 of 4

Pretty URLS running .... but... one question!

Posted: Mon Jun 25, 2007 4:38 pm
by raul.lnx
Hello:

I have running pretty urls in www.snowboard-zamora.net , but only works in "pages" when you click in the main menu. It's possible set pretty urls for NEWS ? For example i have this new:

http://www.snowboard-zamora.net/index.p ... eturnid=15

It's posible to change it , in a similar web as this ??

http://www.snowboard-zamora.net/news/ti ... otice.html


??? THANKS !

I only need one example .

I have test this line into .htaccess, but don't works ...

RewriteRule ^(.+).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01returnid=$2 [QSA]

Re: Pretty URLS running .... but... one question!

Posted: Mon Jun 25, 2007 8:24 pm
by cyberman

Re: Pretty URLS running .... but... one question!

Posted: Mon Jun 25, 2007 10:22 pm
by raul.lnx
Ok thanks ! but i've tried it and news doesn't work :S

My section in .htaccess is this:


#############################


Options +FollowSymLinks
RewriteEngine on

# 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 ^(.+).html$ index.php?page=$1 [QSA]

# 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 ^(.+).html %{REQUEST_URI}/ [R=301,L]

# rewrite for news
#RewriteRule ^([0-9]*).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1 [NC,L]
RewriteRule ^([0-9]*)/([0-9]*).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01returnid=$2 [NC,L]


All rewrites works, but news doesn't :(  ¿ any idea ?

I put the mouse over de title news, and the link is the same , doesn't change ......

Re: Pretty URLS running .... but... one question!

Posted: Tue Jun 26, 2007 9:43 am
by raul.lnx
OK, now NEWS module is running with pretty URLs:

http://www.snowboard-zamora.net/index.p ... eturnid=15

and

http://www.snowboard-zamora.net/noticia ... .html  are the same webpage.......


But, why in the title of the News, the link is the firts ??? Must I change news template ???

Re: Pretty URLS running .... but... one question!

Posted: Tue Jun 26, 2007 10:16 am
by raul.lnx
NOW RUNNING !!!!!


Change this line in action.default.php

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

add before

------------NEW LINES--------
if ($this->cms->config['assume_mod_rewrite'] == true)
{
$onerow->titlelink = "cms->config['page_extension'] . "\">" . $row['news_title'] . "";
}
else
{
$onerow->titlelink = $this->CreateLink($id, 'detail', $returnid, $row['news_title'], $sendtodetail,'',false,false,'',true);
}
-------------------------------------


Now the new link in the title os news will be :

http://URL/noticias/ID/RETURNID.html  :D

GOOD LUCK !

Re: Pretty URLS running .... but... one question!

Posted: Tue Jun 26, 2007 10:22 am
by Pierre M.
Hello,

@doc writters :
the documentation about pretty URLs really needs to be clarified : this link to the tip for the news is the third place I discover about pretty URLs in the doc within a week. No wonder why users may be confused.
I think everything about pretty URLs should stand in one Howto. What do you think ? (yes, I should ask in the doc forum or in the wiki discussion, but I'm lazy)

Pierre M.

Re: Pretty URLS running .... but... one question!

Posted: Tue Jun 26, 2007 10:37 am
by raul.lnx
Yes, i think the same . All about pretty URLS must be in the same section ( post forum or wiki ) ...... Sorry .......

Re: Pretty URLS running .... but... one question!

Posted: Fri Sep 28, 2007 3:28 am
by relic
raul.lnx wrote: NOW RUNNING !!!!!


Change this line in action.default.php

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

add before

------------NEW LINES--------
if ($this->cms->config['assume_mod_rewrite'] == true)
{
$onerow->titlelink = "cms->config['page_extension'] . "">" . $row['news_title'] . "";
}
else
{
$onerow->titlelink = $this->CreateLink($id, 'detail', $returnid, $row['news_title'], $sendtodetail,'',false,false,'',true);
}
-------------------------------------


Now the new link in the title os news will be :

http://URL/noticias/ID/RETURNID.html  :D

GOOD LUCK !
Hi there...

did you only put that code in action.default.php because i tired this.. but if will not work for me??

cheers,

dave

Re: Pretty URLS running .... but... one question!

Posted: Tue Nov 20, 2007 2:26 pm
by giggler
Isn't that the default pretty url for news? Where you able to make it the following:

/news/id/news-title-name.html

Re: Pretty URLS running .... but... one question!

Posted: Mon Nov 26, 2007 6:59 pm
by raul.lnx
In a few days i'll post the solution to make pretty URLS NEWS TITLES to :

"www.website.com/news/$id/title_of_news.html"

The default url in CMS is /news/$id/$returnid.html

Re: Pretty URLS running .... but... one question!

Posted: Tue Nov 27, 2007 5:34 pm
by raul.lnx
Hello:

Now i have running again pretty title urls with CMS 1.2.0


Edit:  modules/News/action.default.php

Near line 294

Code: Select all

    $prettyurl = 'noticias/'.$row['news_id'].'/'.$row['news_title'];  <-- OUR NEW LINE

   // $prettyurl = 'news/'.$row['news_id'].'/'.($detailpage!=''?$detailpage:$returnid);  <--- COMMENT THIS LINE


Edit: /lib/misc.functions.php

Code: Select all

          if( !$mapped && !$allow_unknown )
                {
/**               trigger_error('Parameter '.$key.' is not known... dropped',E_USER_WARNING);**/   <--- COMMENT THIS LINE
                  continue;
                }

I am using .htaccess, and i have this line to TITLE LINKS:

RewriteRule ^noticias/([0-9]*)/(.+).html$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01 [NC,L]


Now, you can see my website www.snowboard-zamora.net , and put the mouse over TITLE LINKS and see the TARGET in your Status Var.

Title links will be similar to :

http://www.snowboard-zamora.net/noticia ... _LINK.html

GOOD LUCK

Re: Pretty URLS running .... but... one question!

Posted: Tue Nov 27, 2007 7:34 pm
by giggler
Cool, that's improved. Is there a way to take out the spaces (20%)? I know in smarty, you can do it with replace or something...

Re: Pretty URLS running .... but... one question!

Posted: Tue Nov 27, 2007 9:07 pm
by raul.lnx
You can do it with this two lines:

Code: Select all

//MI HACK
    $row['news_title'] = str_replace(' ', '_', $row['news_title']); <--- THIS LINE REPLACE SPACE WITH _ FOR LINK
    $prettyurl = 'noticias/'.$row['news_id'].'/'.$row['news_title'];
// FIN DE HACK

And some lines below: ( about 319 )

Code: Select all

#CreateLink($id, $action, $returnid='', $contents='', $params=array(), $warn_message='', $onlyhref=false, $inline=false, $add ........................

// MI HACK
    $row['news_title'] = str_replace('_', ' ', $row['news_title']);
// FIN

    $onerow->link = $this->CreateLink($id, 'detail', $deta .................... 

You can wee now the links into my website :D It's COOL !

www.snowboard-zamora.net

Re: Pretty URLS running .... but... one question!

Posted: Tue Nov 27, 2007 9:28 pm
by giggler
Awesome work!! They need to include this into the next release. The filename is SOOOO important for SEO (along with title tag also). I have done a site using /id/listid.html and once it was changed to /cat-name/list-name.html, it started to show up higher on google.

So glad you did this and thank you SO much for sharing!

Re: Pretty URLS running .... but... one question!

Posted: Tue Nov 27, 2007 11:03 pm
by Badyl
Works grat! thx

My portal based on news - this function is very very useful.

[edit]

Is there a little bug - if the topic of news have a "?" - the news not display

Is there any soluttion for this ?