• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Pretty URL's for News Category Browse Links?
PostPosted: Wed Jan 28, 2009 11:12 am 
Offline
New Member

Joined: Mon Jan 26, 2009 11:30 pm
Posts: 2
Searching for a way to change the News Category links to be a bit more readable, not much luck unfortunately.

Anybody have any handy tips for this?

Code:
{news sortby="news_category" browsecat="1"}


produces links like:

Code:
index.php?mact=News,cntnt01,default,0&cntnt01sortby=news_category&cntnt01sortasc=true&cntnt01detailpage=&cntnt01category_id=13&cntnt01returnid=15


Many thanks if you can help.


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Mon Dec 20, 2010 9:46 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
Sorry to be so late with a response, but I did this with a UDT and a modification to my .htaccess file.

First I created a UDT called news_category_url
Code:
$name = preg_replace(array("/ /", "/[^A-Za-z0-9-\-]/", "/--/"),array("-", "", "-"),$params['name']);
$id = $params['id'];
echo 'blog/category/'.$id.'/'.$name.'.htm';

You will need to change the .htm in the code above to whatever extension you are using on your site.

Then edit your News Category Template.
Find:
Code:
{if $node.count > 0}
   <a href="{$node.url}">{$node.news_category_name}</a> ({$node.count}){else}<span>{$node.news_category_name} (0)</span>{/if}

Change it to:
Code:
{if $node.count > 0}
   <a href="{news_category_url name=$node.news_category_name id=$node.news_category_id}">{$node.news_category_name}</a> ({$node.count}){else}<span>{$node.news_category_name} (0)</span>{/if}

Finally add a line like this to your .htaccess file before the CMSMS rewrite rules that add the trailing slash (or extension) and the page rewrite rule:
Code:
RewriteCond %{HTTP_HOST} ^yoursite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com$
RewriteRule ^news/category/([0-9]+)/(.+).htm index.php?mact=News,cntnt01,default,0&cntnt01detailpage=15&cntnt01category_id=$1&cntnt01returnid=15  [NC,L]

In the above code you will need to change the .htm to whatever extension you are using for your site. You will also need to change the detailpage=15 and returnid=15 to the id of the page you want the listings to be displayed on. You may also need to change the news/category... to match the links you are building (see questions and answers below for an example .htaccess file).

_________________
Studio-Owens.com


Last edited by Owens on Sat Aug 06, 2011 11:39 pm, edited 5 times in total.

Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Thu Aug 04, 2011 3:47 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Mon Sep 06, 2010 10:51 am
Posts: 161
Apologies in brining up an old thread.

I followed the instructions given in the response below, and while the categories are prettified, when you click on them, they dont work.


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Fri Aug 05, 2011 1:46 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
swarfega wrote:
I followed the instructions given in the response below, and while the categories are prettified, when you click on them, they dont work.

If you are asking for help. We will need much more information, such as, your code (from both the .htaccess file and the UDT), and a link to your site would be helpful. This will allow someone in the community to try and assist you.

The code I submitted in my previous post works perfectly fine, examples (proof of the pudding is in the eating):


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Fri Aug 05, 2011 8:23 am 
Offline
Forum Members
Forum Members
User avatar

Joined: Mon Sep 06, 2010 10:51 am
Posts: 161
Thanks for your reply and here is the info.

Site: http://thriplow.org.uk

news_category_url
Code:
$name = preg_replace(array("/ /", "/[^A-Za-z0-9-\-]/", "/--/"),array("-", "", "-"),$params['name']);
$id = $params['id'];
echo 'category/'.$id.'/'.$name.'.pc';


News Category Template
Code:
{if $count > 0}
<ul class="list1">
{foreach from=$cats item=node}
{if $node.depth > $node.prevdepth}
{repeat string="<ul>" times=$node.depth-$node.prevdepth}
{elseif $node.depth < $node.prevdepth}
{repeat string="</li></ul>" times=$node.prevdepth-$node.depth}
</li>
{elseif $node.index > 0}</li>
{/if}
<li class="newscategory">
{if $node.count > 0}
   <a href="{news_category_url name=$node.news_category_name id=$node.news_category_id}">{$node.news_category_name}</a> ({$node.count}){else}<span>{$node.news_category_name} (0)</span>{/if}
{/foreach}
{repeat string="</li></ul>" times=$node.depth-1}</li>
</ul>
{/if}


htaccess file
Code:
ErrorDocument 404 /cms/index.php?page=error404
RemoveHandler .php
AddType application/php5-fcgi php
Action application/php5-fcgi /cgi-bin/php5fcgi.fcgi

<IfModule php5_module>
  php_value include_path /ZendGdata
</IfModule>

# ------------------------
# BEGIN Optional settings

Options -Indexes
Options +FollowSymLinks
DirectoryIndex /cms/index.php
RewriteBase /cms
RewriteEngine on

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# except for form POSTS
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
#RewriteCond %{REQUEST_METHOD} !POST$
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
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).pc$ index.php?page=$1 [QSA]

#RewriteRule ^cms/(.+)$ http://thriplow.org.uk/cms/$1 [R=301,L]

#RewriteCond %{HTTP_HOST} ^thriplow.org.uk$ [OR]
#RewriteCond %{HTTP_HOST} ^www.thriplow.org.uk$
# News Pretty URL Fix
#RewriteRule ^news/([^/][0-9]+)/([^/][0-9]+)/(.+)$ #index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01returnid=$2 [NC,L]

#RewriteCond %{HTTP_HOST} ^thriplow.org.uk$ [OR]
#RewriteCond %{HTTP_HOST} ^www.thriplow.org.uk$
#RewriteRule ^news/category/([0-9]+)/(.+).pc #index.php?mact=News,cntnt01,default,0&cntnt01detailpage=59&cntnt01category_id=$1&cntnt01returnid=59  [NC,L]

RewriteCond %{HTTP_HOST} ^thriplow.org.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.thriplow.org.uk$
RewriteRule ^news/category/([0-9]+)/(.+).pc  index.php?mact=News,cntnt01,default,0&cntnt01detailpage=59&cntnt01category_id=$1&cntnt01returnid=59  [NC,L]


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Fri Aug 05, 2011 2:08 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
You need to make some changes in your .htaccess file. (1) Remove the news/ from the rewrite rule and replace it with cms/; as you are not using news in your URL hierarchy. (2) put the news category rewrite rule before the two CMSMS rewrite rules; the trailing character and page rewrite. Try this instead as your .htaccess file...

Code:
ErrorDocument 404 /cms/index.php?page=error404
RemoveHandler .php
AddType application/php5-fcgi php
Action application/php5-fcgi /cgi-bin/php5fcgi.fcgi

<IfModule php5_module>
  php_value include_path /ZendGdata
</IfModule>

# ------------------------
# BEGIN Optional settings

Options -Indexes
Options +FollowSymLinks
DirectoryIndex /cms/index.php
RewriteBase /cms
RewriteEngine on

RewriteCond %{HTTP_HOST} ^thriplow.org.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.thriplow.org.uk$
RewriteRule ^cms/category/([0-9]+)/(.+).pc index.php?mact=News,cntnt01,default,0&cntnt01detailpage=59&cntnt01category_id=$1&cntnt01returnid=59  [NC,L]

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# except for form POSTS
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
#RewriteCond %{REQUEST_METHOD} !POST$
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
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).pc$ index.php?page=$1 [QSA]

Let me know if this doesn't make the magic happen, and I'll setup a test server on my local machine to mirror your directory and URL hierarchy and get it worked out.


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Fri Aug 05, 2011 4:40 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Mon Sep 06, 2010 10:51 am
Posts: 161
Thanks very much owens, categories work nicely now.


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Fri Aug 05, 2011 5:03 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
Thank you for saying thank you. Glad I could help.
:)


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Thu Apr 19, 2012 5:20 pm 
Offline
Forum Members
Forum Members

Joined: Fri Feb 17, 2012 4:25 pm
Posts: 89
Hi - I'm sorry too for jumping on an old thread... I just wondered if there's any way I could write
Code:
RewriteCond %{HTTP_HOST} ^yoursite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com$
RewriteRule ^news/category/([0-9]+)/(.+).htm index.php?mact=News,cntnt01,default,0&cntnt01detailpage=15&cntnt01category_id=$1&cntnt01returnid=15  [NC,L]
to test on my local server?


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Thu Apr 19, 2012 6:29 pm 
Offline
Forum Members
Forum Members
User avatar

Joined: Thu Dec 27, 2007 11:29 pm
Posts: 92
ladyr0gue wrote:
I just wondered if there's any way I could write ... to test on my local server?

Open your CMS Made Simple config.php file on your local server and look for the line that has $config['root_url'] = to figure out what you should replace yoursite.com in the above code with.

This will vary depending upon your what you are using as your local server. I use Server2Go on my Windows machines. So in the .htacess file I would replace yoursite.com with 127\.0\.0\.1:4001


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Thu Apr 19, 2012 6:46 pm 
Offline
Forum Members
Forum Members

Joined: Fri Feb 17, 2012 4:25 pm
Posts: 89
Owens wrote:
ladyr0gue wrote:
I just wondered if there's any way I could write ... to test on my local server?

Open your CMS Made Simple config.php file on your local server and look for the line that has $config['root_url'] = to figure out what you should replace yoursite.com in the above code with.

This will vary depending upon your what you are using as your local server. I use Server2Go on my Windows machines. So in the .htacess file I would replace yoursite.com with 127\.0\.0\.1:4001


thanks for your reply :)
as my root url is http://localhost/cmsms how would I write that? just localhost/cmsms? or do i use a backslash? thanks x


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Thu Apr 19, 2012 6:49 pm 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 11812
Location: Arizona
I've found that using XAMPP I had to use...

RewriteBase /cmsms

_________________
Extensions » Modules/Tags click the name of the module/tag or Help to the right to get its parameters.
Right click and view source is a great way to see what you have to work with.
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Thu Apr 19, 2012 7:51 pm 
Offline
Forum Members
Forum Members

Joined: Fri Feb 17, 2012 4:25 pm
Posts: 89
Dr.CSS wrote:
I've found that using XAMPP I had to use...

RewriteBase /cmsms


Thanks for your reply - I am still doing something wrong boohoo!

here's what I have.

UDT news_category_url
Code:
$name = preg_replace(array("/ /", "/[^A-Za-z0-9-\-]/", "/--/"),array("-", "", "-"),$params['name']);
$id = $params['id'];
echo 'blog/category/'.$id.'/'.$name.'.html';


News category browse default template
Code:
{if $count > 0}
<ul class="list1">
{foreach from=$cats item=node}
{if $node.depth > $node.prevdepth}
{repeat string="<ul>" times=$node.depth-$node.prevdepth}
{elseif $node.depth < $node.prevdepth}
{repeat string="</li></ul>" times=$node.prevdepth-$node.depth}
</li>
{elseif $node.index > 0}</li>
{/if}
<li class="newscategory">
{if $node.count > 0}
   <a href="{news_category_url name=$node.news_category_name id=$node.news_category_id}">{$node.news_category_name}</a> ({$node.count}){else}<span>{$node.news_category_name} (0)</span>{/if}
{/foreach}
{repeat string="</li></ul>" times=$node.depth-1}</li>
</ul>
{/if}


.htaccess file
Code:
Options -Indexes
Options +FollowSymLinks
DirectoryIndex /cmsms/index.php
RewriteBase /cmsms
RewriteEngine on

RewriteCond %{HTTP_HOST} ^localhost$
RewriteRule ^news/category/([0-9]+)/(.+).html

index.php?mact=News,cntnt01,default,0&cntnt01detailpage=3&cntnt01category_id=$1&cntnt01returnid=3  [NC,L]

# 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,NE]
 
# 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
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA,NE]


and no change. I've done something wrong!

*I do wonder if I've set myself up for complications in that I have the installation in a folder named cmsms in xampp/htdocs rather than unpacked straight into the htdocs folder...


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Thu Apr 19, 2012 8:00 pm 
Offline
Administrator
Administrator
User avatar

Joined: Thu Mar 09, 2006 5:32 am
Posts: 11812
Location: Arizona
I wouldn't use the root of htdocs folder, as it has a lot of things in it needed for XAMPP and your CMSMS may get lost amongst them...

I wonder if you need to move the News part of the htaccess below the others...

_________________
Extensions » Modules/Tags click the name of the module/tag or Help to the right to get its parameters.
Right click and view source is a great way to see what you have to work with.
Check ver. CMSMS, PHP, server OS, in System Information page.
Default content http://multiintech.com/defaultcontent/
People are Wonderful
Business is Great
Life is Terrific
Ever wonder what happened to the Album module? Well it is alive and well.
http://album.multiintech.com/
Image


Top
 Profile  
 
 Post subject: Re: Pretty URL's for News Category Browse Links?
PostPosted: Thu Apr 19, 2012 8:18 pm 
Offline
Forum Members
Forum Members

Joined: Fri Feb 17, 2012 4:25 pm
Posts: 89
I tried, no difference unfortunately. Is my code otherwise correct? I don't have a folder named news but all my pretty urls for the other parts of the site seem to work fine including detail view for news articles, I get something like
"http://localhost/cmsms/news/2/66/My-Pretty-Page.html

I have also tried this different solution here http://wiki.cmsmadesimple.org/index.php/User_Handbook/Tips_And_Tricks/Installationbut seemed to come up with more problems - but I notice that the RewriteBase wasn't set for /cmsms when I tried that one.

I also tried using
Code:
RewriteCond %{HTTP_HOST} ^localhost/cmsms$
but no difference, I wonder if I wrote it right?

(btw thanks for the confirmation, glad I am ok to have it in the folder as I don't think my poor lil brain could handle it if it had to be moved! lol)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner