[solved] Are SEF/ pretty news category browse urls possible?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
ladyr0gue
Forum Members
Forum Members
Posts: 91
Joined: Fri Feb 17, 2012 4:25 pm

[solved] Are SEF/ pretty news category browse urls possible?

Post by ladyr0gue »

I have followed and asked a few questions on other people's threads here http://forum.cmsmadesimple.org/viewtopi ... =7&t=30347 and here http://forum.cmsmadesimple.org/viewtopi ... =8&t=51417 about this but am still even not entirely sure if it's possible!

in answer to a question here http://forum.cmsmadesimple.org/viewtopi ... 20&t=37978 about whether it was possible to make pretty urls for browsing between summary pages (like Page 1 of N etc.) Calguy1000 said
calguy1000 wrote:answer: no.

Once you add parameters like sort order, sorting field, page number, page limit, summary template, detail template (and other parameters that the news and other various modules support for customizing the output) to the url, no matter what you do, it won't be pretty. and besides, usually it's the detail view that's most important anyways... users don't generally care about how ugly the url is to access "the 4th page of all news articles (even expired ones) sorted by author in decending order with 5 items per page", using a different detail template.

News allows you numerous ways to organize the data, just by adding more calls to the module. Making the pagination urls 'pretty' would require removing that flexibility.


So Firstly and foremost - is it actually possible to make pretty the news category pages without creating an actual page for each new category, adding the news tag and setting it to only view that category, each time? As that would be inconvenient and complicated for the user....

If it is possible, I don't know what I'm doing wrong!

I'm running 1.10.3 on xampp

I tried to follow the instructions on the first post, reading very carefully. Here's what I've been trying...

I have the following in my config.php file

Code: Select all

<?php
# CMS Made Simple Configuration File
# Documentation: /doc/CMSMS_config_reference.pdf
#
$config['dbms'] = 'mysql';
$config['db_hostname'] = 'localhost';
$config['db_username'] = 'root';
$config['db_password'] = '';
$config['db_name'] = 'cms';
$config['db_prefix'] = 'cms_';
$config['db_port'] = 0;
$config['root_url'] = 'http://localhost/cmsms';
$config['timezone'] = 'Europe/Berlin';
$config['default_encoding'] = 'utf-8';
  #------------
  #URL Settings
  #------------
$config['url_rewriting'] = 'mod_rewrite';
$config['use_hierarchy'] = true;
$config['query_var'] = 'page';

#Show mod_rewrite URLs in the menu?
$config['assume_mod_rewrite'] = true;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '.html';
$config['process_whole_template'] = false;
?>
then I created a UDT news_category_url

Code: Select all

$name = preg_replace(array("/ /", "/[^A-Za-z0-9-\-]/", "/--/"),array("-", "", "-"),$params['name']);
$id = $params['id'];
echo 'blog/category/'.$id.'/'.$name.'.html';
Then my news category browse template is this

Code: Select all

{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}
and this is my .htaccess file

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /cmsms

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


Oh please oh please can anyone tell me where I am going wrong? I may just scrap categories altogether but I really would prefer to have them there as some of them will include keywords we hope to optimise!
Last edited by ladyr0gue on Sun Apr 22, 2012 2:20 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Are SEF/ pretty news category browse urls actually possi

Post by calguy1000 »

There is no code in the News module to handle any category urls in this way.

So even if you can (using this UDT that was designed for the CGBlog module btw) manage to get the links to appear properly, news will not handle them.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
ladyr0gue
Forum Members
Forum Members
Posts: 91
Joined: Fri Feb 17, 2012 4:25 pm

Re: Are SEF/ pretty news category browse urls actually possi

Post by ladyr0gue »

ah thank you for your reply Mr. CG - :) yes I had noticed the
echo 'blog/category/'.$id.'/'.$name.'.html';
bit in that UDT which I copied (and I had tried saying 'news' too just to see) - oh well not to worry guess there's other more important things in life to worry about than how good looking all the links are ;)
Post Reply

Return to “CMSMS Core”