• 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




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: [SOLVED] News & Pretty URL's with MLE & hierarchy Off
PostPosted: Sat Sep 18, 2010 11:45 pm 
Offline
Forum Members
Forum Members

Joined: Sun Dec 21, 2008 11:35 pm
Posts: 98
Many thanks to Owens for providing the solution to having nice URLs with the News Modules for users with multinlingual sites using MLE and with hierarchy set to false in the config file.

See also this post for information on the origins of this post:
http://forum.cmsmadesimple.org/index.php/topic,43037.0.html

I have a site in English and Spanish. You may have to tweak some of the below code to get it to work for you, but this might help someone who finds themselves in my situation. Just to be clear, the below code has been kindly provided by Owens, I am just grouping it together to make it easier for MLE users to implement.

Step 1
Add the below code to your .htaccess file:

\$1:
RewriteCond %{HTTP_HOST} ^yoursite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com$
# News Pretty URL Fix
RewriteRule ^news/([^/][0-9]+)/([^/][a-zA-Z]+_[a-zA-Z]+)/([^/][0-9]+)/([^/][a-zA-Z]+)/(.+)$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01lang=$2&cntnt01returnid=$3&hl=$4 [NC,L]
RewriteRule ^news/([^/][0-9]+)/([^/][0-9]+)/([^/][a-zA-Z]+)/(.+)$ index.php?mact=News,cntnt01,detail,0&cntnt01articleid=$1&cntnt01returnid=$2&hl=$3 [NC,L]


Step 2
Create a User Defined Tag (UDT) and name it news_no_hierarchy_url
(you can create a UDT in admin under the Extensions menu).
Copy and paste the below code and save your UDT.

\$1:
preg_match('/articleid=[0-9]*/i',$params['ugly'], $matches);
$id = preg_replace('/articleid=/i','',$matches[0]);
preg_match('/lang=[a-zA-Z\{2}_[a-zA-Z]{2}/i',$params['ugly'], $matches);
$lang = preg_replace('/lang=/i','',$matches[0]);
preg_match('/returnid=[0-9]*/i',$params['ugly'], $matches);
$rid = preg_replace('/returnid=/i','',$matches[0]);
preg_match('/hl=[a-z]*/i',$params['ugly'], $matches);
$hl = preg_replace('/hl=/i','',$matches[0]);
$title = preg_replace('/ /','-',$params['title']);
if ($lang != '') {
  echo '/news/'.$id.'/'.$rid.'/'.$hl.'/'.$title.'.html';
} else {
  echo '/news/'.$id.'/'.$rid.'/'.$hl.'/'.$title.'.html';
}


Step 3
Add the below code to your news summary template just below the code {foreach from=$items item=entry}

\$1:
{capture assign="cleantitle"}{$entry->title|cms_escape:htmlall}{/capture}
{capture assign="uglyurl"}{$entry->moreurl}{/capture}


Step 4
Replace this code:
\$1:
<a href="{$entry->moreurl}" title="{$entry->title|cms_escape:htmlall}">


With this code:
\$1:
<a href="{news_no_hierarchy_url ugly="$uglyurl" title="$cleantitle"}">


Here is a copy of my news summary template for your information:

\$1:
<!-- Start News Display Template -->
{if $pagecount > 1}
  <p><strong>More articles:</strong>
{if $pagenumber > 1}
{$firstpage} {$prevpage} 
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
 {$nextpage} {$lastpage}
{/if}
</p>
{/if}

{foreach from=$items item=entry}

{capture assign="cleantitle"}{$entry->title|cms_escape:htmlall}{/capture}
{capture assign="uglyurl"}{$entry->moreurl}{/capture}


<div>

<div style="color:#ec008c;padding-top:8px;"><h2>
<a href="{news_no_hierarchy_url ugly="$uglyurl" title="$cleantitle"}">{$entry->title|cms_escape:htmlall}</a></h2></div>

{if $entry->writer}
   <div>
       {$entry->writer}
   </div>
{/if}

{if $entry->postdate}   
      <div style="padding-top:5px;"><strong>{$entry->postdate|cms_date_format}</strong> </div>
{/if}
<div style="padding-top:5px;"><em>{$category_label} {$entry->category}</em><br></div>

{if $entry->article_summary}
   <div style="padding-top:5px;">
      {eval var=$entry->article_summary}
   </div>


<div style="padding-top:10px">

      <img src="images/bullet.gif" alt="bullet"> <a href="{news_no_hierarchy_url ugly="$uglyurl" title="$cleantitle"}">full article</a> <img src="images/bullet.gif" alt="bullet">
   
</div>

{else if $entry->content}

      {eval var=$entry->content}
   
{/if}



<div style="border-bottom: 1px dashed #ec008c; width:100%;padding-top:20px;"></div>
</div>
{/foreach}
{if $pagecount > 1}
  <p><strong>More articles:</strong>
{if $pagenumber > 1}
{$firstpage} {$prevpage} 
{/if}
{$pagetext} {$pagenumber} {$oftext} {$pagecount}
{if $pagenumber < $pagecount}
 {$nextpage} {$lastpage}
{/if}
</p>
{/if}
<!-- End News Display Template -->


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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:  
Hosting Nation - Managed CMSMS Hosting