hans,
What you wrote works, except that it puts a ?w=weblog in the link (domain.com/?w=weblog&u=[username]). From where I sit, the link still works, but for others including the weblog parameter might be undesirable.
I ended up copying and modifying the function makeCategoryLink to write the function makeUserLink:
- Code: Select all
function makeUserLink($name, $override_weblog="") {
global $PIVOTX;
// Set the weblog, according to passed parameter or current weblog
$weblog = get_default($override_weblog, $PIVOTX['weblogs']->getCurrent());
$site_url = get_default($PIVOTX['weblogs']->get($weblog, 'site_url'), $PIVOTX['paths']['site_url']);
if ($PIVOTX['config']->get('mod_rewrite') < 1) {
$ulink = $site_url . "?u=" . $name;
} else {
$prefix = get_default($PIVOTX['config']->get('localised_user_prefix'), "user");
$ulink = $site_url . makeURI($prefix) . "/" . $name;
}
// If we have more than one weblog, add the w=weblogname parameter
if (para_weblog_needed($weblog)) {
if ($PIVOTX['config']->get('mod_rewrite')>0) {
// we treat it as an extra 'folder'
$ulink .= "/" . $weblog;
} else {
$ulink .= "&w=" . $weblog;
}
}
return $ulink;
The only part(s) I'm unsure about is the mod_rewrite parts and this line:
- Code: Select all
$prefix = get_default($PIVOTX['config']->get('localised_user_prefix'), "user");
I don't use mod_rewrite in conjunction with PivotX, at least, insofar as my PivotX is configured (I do use mod_rewrite otherwise, so I am familiar with it). So, I don't know if a username can be passed through a mod_rewritten link. Therefore, I'm also not sure if that line would work or not. I've only gotten so far as to put that function in the code and test it on my non-mod_rewrite PivotX site; it works there, so far--I'm short on time right now, so I can't go any further for the moment.
What are your thoughts?
I might be able to come back to the snippet some more tonight...certainly for a little bit tomorrow.