{News} + mod_rewrite
Posted: Sat Apr 09, 2011 2:50 am
Cobbled my first {News} setup together.
In the summary template, each title links to a detail page where the individual single news article is displayed.
I got this to work.
To finalize the module, I was of going to use the article title as my page title.
When NOT using "mod_rewrite" the link from summary page to detail page works ( and all others ).
When using "mod_rewrite" it does not (404).
Now, I think I have to use mod_rewrite for SEO friendly URL rewrites, because I am using Xampp/Vista home dev, and from what I read "Pretty Urls" does not work properly/well on windows servers.
"News-summary-tpl" Template ( contains title link to detail page)
<a href="{$entry->moreurl}" title="{$entry->title| cms_escape:htmlall}">
{$entry->title|cms_escape}</a>
"News-detail-tpl" Template (contains logic for url rewrite)
{if isset($entry->canonical)}
{assign var='canonical' value=$entry->canonical}
{/if}
{assign var="pagetitle" value=$entry->title|escape}
"home" page ( contains news summary with the links)
{news detailpage="news-detail" detailtemplate="News-detail-tpl"}
("news-detail" is the Page Alias as well as the Url. It is an empty file with one )
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
{stylesheet name="op2-css"}
{metadata}
{if isset($pagetitle) && !empty($pagetitle)}
<title>{sitename} {$pagetitle} </title>
{else}
<title>{sitename} - {title}</title>
{/if}
</head>
config.php
$config['url_rewriting'] = 'mod_rewrite';
$config['page_extension'] = '.htm';
#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';
$config['use_hierarchy'] = true;
$config['internal_pretty_urls'] = false;
In mod_rewrite, while hovering over the news title link the addressbar reads: ../news/date/article-title/d,News-detail-tpl.htm
With Pretty Urls, while hovering over the news title link the addressbar reads: "http://localhost/op2/index.php?mact=New ... eturnid=21"
CMSms v1.9.4.1 Xampp/Vista home dev
thanks
In the summary template, each title links to a detail page where the individual single news article is displayed.
I got this to work.
To finalize the module, I was of going to use the article title as my page title.
When NOT using "mod_rewrite" the link from summary page to detail page works ( and all others ).
When using "mod_rewrite" it does not (404).
Now, I think I have to use mod_rewrite for SEO friendly URL rewrites, because I am using Xampp/Vista home dev, and from what I read "Pretty Urls" does not work properly/well on windows servers.
"News-summary-tpl" Template ( contains title link to detail page)
<a href="{$entry->moreurl}" title="{$entry->title| cms_escape:htmlall}">
{$entry->title|cms_escape}</a>
"News-detail-tpl" Template (contains logic for url rewrite)
{if isset($entry->canonical)}
{assign var='canonical' value=$entry->canonical}
{/if}
{assign var="pagetitle" value=$entry->title|escape}
"home" page ( contains news summary with the links)
{news detailpage="news-detail" detailtemplate="News-detail-tpl"}
("news-detail" is the Page Alias as well as the Url. It is an empty file with one )
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
{stylesheet name="op2-css"}
{metadata}
{if isset($pagetitle) && !empty($pagetitle)}
<title>{sitename} {$pagetitle} </title>
{else}
<title>{sitename} - {title}</title>
{/if}
</head>
config.php
$config['url_rewriting'] = 'mod_rewrite';
$config['page_extension'] = '.htm';
#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';
$config['use_hierarchy'] = true;
$config['internal_pretty_urls'] = false;
In mod_rewrite, while hovering over the news title link the addressbar reads: ../news/date/article-title/d,News-detail-tpl.htm
With Pretty Urls, while hovering over the news title link the addressbar reads: "http://localhost/op2/index.php?mact=New ... eturnid=21"
CMSms v1.9.4.1 Xampp/Vista home dev
thanks