<?php
function smarty_function_getshowurl($params, &$smarty){
	extract($params);
	if(isset($cid)) $aid=$cid;
	if(isset($id)) $aid=$id;
	if(!isset($page)) $page=1;
	$types=$orderby=$paged='';
	if($mid=='search'){
		if($page>1 || $page=='{!page!}') $paged="&p={$page}";
		$types="&q={$aid}";
		return WEB_ROOT."/index.php?m={$mid}{$types}{$paged}";
	}
	if(C('web_url_rewrite')){
		$type=$mid;
		if($mid=='channel') $type=C('rewrite_channel');
		if($page>1  || $page=='{!page!}'){
			$paged='-'.$page;
			if(isset($_GET['order'])){
				$order=preg_replace('#[^a-z,0-9]#','',strtolower($_GET['order']));
				if($order!='' && $order!='id' ) $orderby="-order-{$order}";
			}
		}
		$showurl=WEB_ROOT.'/'.$type.'/'.$aid.$orderby.$paged.RE_SUFFIX;
	}else{
		$type='aid';
		if($mid=='channel') $type='m=cate&a=shop&cid';
		if ($mid=='view') $type='m=view&a=gonggao&aid';
		if($page>1 || $page=='{!page!}'){
			$paged="&p={$page}";
			if(isset($_GET['order'])){
				$order=preg_replace('#[^a-z,0-9]#','',strtolower($_GET['order']));
				if($order!='' && $order!='id' ) $orderby="&order={$order}";
			}
		}
		if($aid>0) $types="{$type}={$aid}";
		$showurl=WEB_ROOT."/index.php?{$types}{$orderby}{$paged}";
	}
	return $showurl;
}