sitemap  |  contact

Sakic.Net Forum
13 May 2008, 02:10 *
Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length
News: SEF Advance 2008 for Joomla! 1.5 available now!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: sef_ext.php for components  (Read 72 times)
MikeGH
Newbie
*
Posts: 1


View Profile
« on: 08 May 2008, 00:01 »

If you have a joomla 1.5 component that comes with a functioning router.php and want to use it with SEF advanced, you can create a sef_ext.php with the following content:

[replace XXXXXX with the name of the component (after com_)]
<?php
/**
* SEF Advance component extension
*
* This extension will give the SEF Advance style URLs to the example component
* Place this file (sef_ext.php) in the main component directory
* Note that the class must be named: sef_componentname
*
* Copyright (C) 2003-2007 Emir Sakic, http://www.sakic.net, All rights reserved.
*
* Comments: for SEF Advance > v3.6
**/
require_once("router.php");

class sef_XXXXXX {
   
   /**
   * Creates the SEF Advance URL out of the request
   * Input: $string, string, The request URL (index.php?option=com_example&Itemid=$Itemid)
   * Output: $sefstring, string, SEF Advance URL ($var1/$var2/)
   **/
   function create ($string)
   {
      $string = str_replace("&amp;","&",$string);
      $o = split("&",substr($string,strpos($string,"index.php?")+10));   
      foreach($o as $value)
      {
         $i = split("=",$value);
         $ns[$i[0]] = $i[1];   
      }
      $result = XXXXXXBuildRoute($ns);
      foreach($result as $val)
      {
         $retval .= $val;
         $retval .= "/";   
      }
      return $retval;
   }
   
   /**
   * Reverts to the query string out of the SEF Advance URL
   * Input:
   *    $url_array, array, The SEF Advance URL split in arrays
   *    $pos, int, The position offset for virtual directories (first virtual directory, which is the component name, begins at $pos+1)
   * Output: $QUERY_STRING, string, query string (var1=$var1&var2=$var2)
   *    Note that this will be added to already defined first part (option=com_example&Itemid=$Itemid)
   **/
   function revert ($url_array, $pos)
   {
   
      $na = array();
      for ($a=$pos+2;$a<count($url_array);$a++)
      {
         if (strlen($url_array[$a]) > 0)
         {
            $na[] = $url_array[$a];
         }
      }
      $res = XXXXXXParseRoute($na);
      $QUERY_STRING = '';
      foreach($res as $key=>$value)
      {
         $QUERY_STRING .="&";
         $QUERY_STRING .=$key;
         $QUERY_STRING .="=";
         $QUERY_STRING .=$value;   
         $GLOBALS[$key] = $_GET[$key] = $_REQUEST[$key] = $value;                  
      }
      return $QUERY_STRING;
   }   
}
?>
Logged
Pages: [1]
  Print  
 
Jump to: