I'm working on an sef_ext.php file for CB custom member urls. Got the general idea down but I can't seem to get it to work. Anyone want to take a look at it?
NOTE: this requires OpenSEF if you haven't figured it out
[code:1]<?php
/*
*sef_ext for comprofiler (Community Builder)
* SEF advance component extension
*
* This extension will give the SEF advance style URLs to the userlist component
* Place this file (sef_ext.php) in the main component directory
* Note that class must be named: sef_componentname
*
* Copyright (C) 2003-2004 Emir Sakic,
www.sakic.net
, All rights reserved.
*
*/
class sef_comprofiler {
/**
* Creates the SEF advance URL out of the Mambo 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 == "
mysite.com/index.php?option=com_comprofiler&task=userProfile&user=$user
"
// $string == "index.php?option=com_example&Itemid=$Itemid&var1=$var1&var2=$var2"
$sefstring = "";
if (eregi("&user=",$string)) {
$temp = split("&user=", $string);
$temp = split("&", $temp[1]);
$sefstring .= $temp[0]."/";
}
/* if (eregi("&var2=",$string)) {
$temp = split("&var2=", $string);
$temp = split("&", $temp[1]);
$sefstring .= $temp[0]."/";
}*/
// $sefstring == "$var1/$var2/"
return $sefstring;
}
/**
* Reverts to the Mambo query string out of the SEF advance URL
* Input:
* $url_array, array, The SEF advance URL split in arrays (first custom virtual directory beginning at $pos+1)
* $pos, int, The position of the first virtual directory (component)
* Output: $QUERY_STRING, string, Mambo 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) {
// define all variables you pass as globals
global $user;
// Examine the SEF advance URL and extract the variables building the query string
$QUERY_STRING = "";
if (isset($url_array[$pos+2]) && $url_array[$pos+2]!=""«») {
// component/example/$var1/
$user = $url_array[$pos+2];
$_GET = $user;
$_REQUEST = $user;
//do some sql queries here to convert $user to a userid
global $database, $my;
$query = "SELECT id"
. "\n FROM #__users"
. "\n WHERE username = $user";
$database->setQuery( $query );
$id = $database->loadResult();
//end are need to fix
$QUERY_STRING = "&user=$id";
}
/*if (isset($url_array[$pos+3]) && $url_array[$pos+3]!=""«») {
// component/example/$var1/$var2/
$var2 = $url_array[$pos+3];
$_GET = $var2;
$_REQUEST = $var2;
$QUERY_STRING .= "&var2=$var2";
}*/
// $QUERY_STRING == "var1=$var1&var2=$var2";
return $QUERY_STRING;
}
}
?>[/code:1]
I had to use an sql query to get the member id from the membername because going of the membername wasn't giving me the right URLS when openSEF is on.
Post edited by: igeoffi, at: 2007/03/15 07:40