Knowledge Base

e_url.php [part n.3]

How to create SEF-URL with setting in e_url.php for content plugin

comments: 0
Answer: easy Original url looked like this:
<a href="">
Setting in e_url.php looks like this (we create e_url.php settings with minimalize rewrittiing on mind)
$config['content'] = array(
    'alias'    => '{alias}',
		'regex'    => '^{alias}/(.*)/(.*)',
		'sef'      => '{alias}/{content_sef}/{content_query}',
		'redirect' => 'e107_plugins/content/content.php$2'
	 );
We already added sef-url value to shorcodes by the way. Everything what is needed:
$row['content_sef'] = eHelper::title2sef($row['content_heading'],'dashl');
$row['content_query'] = "?cat.".$row['content_id'];
$url = e107::url("content", "content", $row, "full");
This will be used for any old url, with parameter ?author, ?content etc. So manual work starts. But there is no hurry because thanks using legacy ulrs as canonical, there is not double content. This solution is already prepared for using custom SEF-URL without needind add new fields to database. And to have this topic complet: e_SELF should be replaced by e_REQUEST_SELF e_BASE should be replaced by e_HTTP Example for breadcrumbs: Before:
for($i=0;$i<count($arr[$id]);$i  ){   
	$crumb .= "<a href='".e_PLUGIN."content/content.php?cat.".$arr[$id][$i]."'>".$arr[$id][$i 1]."</a> > ";
	$i  ;
  }
Change to SEF-URL:
for($i=0;$i<count($arr[$id]);$i++){   
      $row['content_sef'] = eHelper::title2sef($arr[$id][$i+1],'dashl');
      $row['content_query'] = "?cat.".$arr[$id][$i];
      $url = e107::url("content", "content", $row, "full"); 
      $crumb .= "<a href='".$url."'>".$arr[$id][$i+1]."</a> > ";
       $i++;
}