Reputation: 103
I tried to create router.php to set SEF url form img src. To display it in src i use as fallowing:
<?php echo JRoute::_(JURI::root().'components/com_mycomponent/myimg/mythumb/'.$thumb->id.'.'.jpg); ?>
To write a router i use instruction from Joomla Wiki but without results :/
I just donk know how to write a router for images src ??
I hope somebody could help me.
My code of router.php
function [componentname]BuildRoute(&$query)
{
$segments = array();
if (isset($query['catid']))
{
$segments[] = $query['catid'];
unset($query['catid']);
};
if (isset($query['id']))
{
$segments[] = $query['id'];
unset($query['id']);
};
unset($query['view']);
return $segments;
}
function [componentname]ParseRoute($segments)
{
$vars = array();
$app = JFactory::getApplication();
$menu = $app->getMenu();
$item = $menu->getActive();
// Count segments
$count = count($segments);
// Handle View and Identifier
switch ($item->query['view'])
{
case 'categories':
if ($count == 1)
{
$vars['view'] = 'category';
}
if ($count == 2)
{
$vars['view'] = 'article';
}
$id = explode(':', $segments[$count-1]);
$vars['id'] = (int) $id[0];
break;
case 'category':
$id = explode(':', $segments[$count-1]);
$vars['id'] = (int) $id[0];
$vars['view'] = 'article';
break;
}
return $vars;
}
I use this code above byt i change component name and i change catid and id on my folders for example muimg and mythumb
Sorry if this question is dumm but i m very new in joomla development
Upvotes: 0
Views: 255
Reputation: 19733
I'm a little unsure what exactly you're trying to achieve but your first code snippet is incorrect and will result in an error. So you need to change this:
(JURI::root().'components/com_mycomponent/myimg/mythumb/'.$thumb->id.'.'.jpg);
to this:
(JUri::root().'components/com_mycomponent/myimg/mythumb/'.$thumb->id.'.jpg');
Upvotes: 0