Hi thyon!
Your post about how actually looks url for news is really useful for me.
I already made new “hardcode” for news in my typolight site.
Now I have this logic
1) if you click to [site_url]/news.html you would be redirect to latest news. And url will be like this:
[site_url]/news/latest-news-alias.html
2) All news have url like this: [site_url]/news/news-alias.html and it shown perfectly.
For make this work you should make some things.
!!! in my site “news” named “nyheter”!!!!
1. Change line# 310 in \system\modules\news\ModuleNews.php
From:
Code:
$strUrl = ampersand($this->generateFrontendUrl($objPage->fetchAssoc(), '/items/' . ((!$GLOBALS['TL_CONFIG']['disableAlias'] && strlen($objArticle->alias)) ? $objArticle->alias : $objArticle->id)));
To:
Code:
$strUrl = ampersand($this->generateFrontendUrl($objPage->fetchAssoc(), '/' . ((!$GLOBALS['TL_CONFIG']['disableAlias'] && strlen($objArticle->alias)) ? $objArticle->alias : $objArticle->id)));
I mean change ‘/items/’ to ‘/’
2. Go to .htaccess and write this:
Code:
RewriteCond %{REQUEST_URI} nyheter/(.*)\.html$
RewriteRule ^nyheter/(.*)\.html$ nyheter.html?items=$1 [NC]
BEFORE
RewriteCond %{REQUEST_FILENAME} !-f
So it should looks like:
Code:
##
# Rewrite base
##
RewriteEngine On
#Options +FollowSymlinks
RewriteBase /
##
# Block malicious requests
##
RewriteCond %{REQUEST_URI} (ftp|https?):|/etc/ [NC,OR]
RewriteCond %{QUERY_STRING} (ftp|https?):|/etc/ [NC]
RewriteRule .* - [F,L]
##
# Compress .js and .css files
##
AddEncoding gzip .gz
AddType "text/javascript" .gz
AddType "text/css" .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME} \.(js|css)$
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [L]
##
# Rewrite TYPOlight URLs
##
RewriteCond %{REQUEST_URI} nyheter/(.*)\.html$
RewriteRule ^nyheter/(.*)\.html$ nyheter.html?items=$1 [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*\.html$ index.php [L]
3) Go to admin panel and create page named “nyheter” in site root. Make it visible for navigation and publish.
4) Go to template and create a duplicate news_full.tpl to news_full_latest.tpl
5) Delete all content from news_full_latest.tpl and place there:
Code:
<?php
if ($_SERVER['REQUEST_URI'] == '/nyheter.html')
{
header('Location: nyheter/'.$this->alias.'.html');
}
?>
6) Create a module (Newslist) named news_latest and select news_full_latest.tpl template for it.
7) Create module (Newsreader) news_reader and assign template for it (!!! Except news_full_latest.tpl)
8) Create article for nyheter page and place there 2 modules
1 - news_latest
2 – news_reader
And publish this article
That’s all.
P.s.
Sorry for my English.
Bookmarks