Coroner
12-09-2009, 03:36 AM
I've tried to create my own friendly URL's but something goes wrong.
Created 2 plugins
<plugin active="1" executionorder="1">
<title>SEOUrl</title>
<hookname>friendlyurl_fetch_main_fragment_fallback</hookname>
<phpcode><![CDATA[
if ($this->link == 'gallery')
{
$titlekey = 'title';
$idkey = 'catid';
$handled = true;
}
]]></phpcode>
</plugin>
and the 2nd:
<plugin active="1" executionorder="1">
<title>SEOUrl</title>
<hookname>global_bootstrap_init_complete</hookname>
<phpcode><![CDATA[
class vB_Friendly_Url_Gallery extends vB_Friendly_Url_Abstract
{
public function __construct(&$registry, $linkinfo, $pageinfo, $primaryid, $primarytitle, $urloptions)
{
$this->link = 'gallery';
parent::__construct($registry, $linkinfo, $pageinfo, $primaryid, $primarytitle, $urloptions);
}
public function output()
{
$customfragment = $this->get_main_fragment();
$pagefragment = $this->get_page_fragment();
$arguments = $this->get_qs_arguments();
$handled = false;
if (!$handled)
{
switch ($this->registry->options['friendlyurl'])
{
case 1:
return 'gallery.php?' . $customfragment . $pagefragment . (!empty($arguments) ? $this->amp . implode($this->amp, $arguments) : '');
case 2:
return 'gallery.php/' . $customfragment . $pagefragment . (!empty($arguments) ? '?' . implode($this->amp, $arguments) : '');
case 3:
return 'gallery/' . $customfragment . $pagefragment . (!empty($arguments) ? '?' . implode($this->amp, $arguments) : '');
case 0:
default:
return 'gallery.php?' . $this->registry->session->vars['sessionurl'] . 'c=' . $this->id . (!empty($arguments) ? $this->amp . implode($this->amp, $arguments) : '');
}
}
}
}
]]></phpcode>
</plugin>
Next is the part I can't ..... believe.
In class_friendly_url I've found the part:
public static $friendlies = array(
'showthread' => array(
'primaryvar' => 't',
...
Now, when I add this code (hardcoded):
'mygallery' => array(
'script' => 'gallery.php',
'primaryvar' => 'c',
'ignorelist' => array ('c', 'catid'),
'rewritevar' => 'gallery',
),
to the class I works correctly. But when I'm adding this CODE by a plugin like:
<plugin active="1" executionorder="1">
<title>SEOUrl</title>
<hookname>global_bootstrap_init_complete</hookname>
<phpcode><![CDATA[
vB_Friendly_Url::$friendlies['mygallery'] = array (
'script' => 'gallery.php',
'primaryvar' => 'c',
'ignorelist' => array ('c', 'catid'),
'rewritevar' => 'gallery'
);
]]></phpcode>
</plugin>
it doesn't work.
To test if it works I'm using this:
$myurl = fetch_seo_url('gallery', array('catid' => 2, 'title' => 'Title 1'));
Does anyone know, what I'm doing wrong ?
Cheers
Coroner
Created 2 plugins
<plugin active="1" executionorder="1">
<title>SEOUrl</title>
<hookname>friendlyurl_fetch_main_fragment_fallback</hookname>
<phpcode><![CDATA[
if ($this->link == 'gallery')
{
$titlekey = 'title';
$idkey = 'catid';
$handled = true;
}
]]></phpcode>
</plugin>
and the 2nd:
<plugin active="1" executionorder="1">
<title>SEOUrl</title>
<hookname>global_bootstrap_init_complete</hookname>
<phpcode><![CDATA[
class vB_Friendly_Url_Gallery extends vB_Friendly_Url_Abstract
{
public function __construct(&$registry, $linkinfo, $pageinfo, $primaryid, $primarytitle, $urloptions)
{
$this->link = 'gallery';
parent::__construct($registry, $linkinfo, $pageinfo, $primaryid, $primarytitle, $urloptions);
}
public function output()
{
$customfragment = $this->get_main_fragment();
$pagefragment = $this->get_page_fragment();
$arguments = $this->get_qs_arguments();
$handled = false;
if (!$handled)
{
switch ($this->registry->options['friendlyurl'])
{
case 1:
return 'gallery.php?' . $customfragment . $pagefragment . (!empty($arguments) ? $this->amp . implode($this->amp, $arguments) : '');
case 2:
return 'gallery.php/' . $customfragment . $pagefragment . (!empty($arguments) ? '?' . implode($this->amp, $arguments) : '');
case 3:
return 'gallery/' . $customfragment . $pagefragment . (!empty($arguments) ? '?' . implode($this->amp, $arguments) : '');
case 0:
default:
return 'gallery.php?' . $this->registry->session->vars['sessionurl'] . 'c=' . $this->id . (!empty($arguments) ? $this->amp . implode($this->amp, $arguments) : '');
}
}
}
}
]]></phpcode>
</plugin>
Next is the part I can't ..... believe.
In class_friendly_url I've found the part:
public static $friendlies = array(
'showthread' => array(
'primaryvar' => 't',
...
Now, when I add this code (hardcoded):
'mygallery' => array(
'script' => 'gallery.php',
'primaryvar' => 'c',
'ignorelist' => array ('c', 'catid'),
'rewritevar' => 'gallery',
),
to the class I works correctly. But when I'm adding this CODE by a plugin like:
<plugin active="1" executionorder="1">
<title>SEOUrl</title>
<hookname>global_bootstrap_init_complete</hookname>
<phpcode><![CDATA[
vB_Friendly_Url::$friendlies['mygallery'] = array (
'script' => 'gallery.php',
'primaryvar' => 'c',
'ignorelist' => array ('c', 'catid'),
'rewritevar' => 'gallery'
);
]]></phpcode>
</plugin>
it doesn't work.
To test if it works I'm using this:
$myurl = fetch_seo_url('gallery', array('catid' => 2, 'title' => 'Title 1'));
Does anyone know, what I'm doing wrong ?
Cheers
Coroner