after creating a custom Router for a joomla component, the POT method not working in my component

28 views
Skip to first unread message

shahryar tavakkoli

unread,
May 11, 2016, 6:38:17 PM5/11/16
to Joomla! General Development
after creating a custom Router for a joomla component, the POT method not working in my component.

in previous version of Router of my component the "views" shown in links but after getting new parameters from menu name this issue solved! but new issue is that the POST method not working now :( here is an example:

<cod>
<form action="<?php echo JRoute::_('index.php?option=com_miniuniversity&view=search');?>" method="post" class="form-horizontal">

</cod>


it return the users to previous page:


<cod>
<?php echo JRoute::_('index.php?option=com_miniuniversity&view=search');
</cod>

output:

/menu_name


this is my Router code:


<cod>
<?php

defined('_JEXEC') or die;

class MiniuniversityRouter
{
public function build(&$query) {
$segments = array();

if (isset($query['id']))
{
$segments[] = $query['id'];
unset($query['id']);
};
unset($query['view']);
return $segments;
}
//--------------------------------------------------------------------------------------
public function parse(&$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 'search':
{
$vars['view'] = 'search';
break;
}

case 'cards':
{
$vars['view'] = 'cards';
break;
}

case 'teachers':
{
if ($count == 1)
{
$vars['view'] = 'teacher';
$id = explode(':', $segments[$count-1]);
$vars['id'] = (int) $id[0];
}

break;
}
case 'libs':
{
if ($count == 1)
{
$vars['view'] = 'lib';
$id = explode(':', $segments[$count-1]);
$vars['id'] = (int) $id[0];
}

break;
}
}
return $vars;
}
}
//=========================================================================================
function miniuniversityBuildRoute(&$query) {
$router = new MiniuniversityRouter;

return $router->build($query);
}
//-------------------------------------------------------------
function miniuniversityParseRoute($segments) {
$router = new MiniuniversityRouter;

return $router->parse($segments);
}
</cod>

joomla version: 3.5

full project :

https://github.com/shahryarjb/MiniUniversity
Reply all
Reply to author
Forward
0 new messages