如何在我的组件中支持 SEF URL
我是 joomla 组件的新手,请帮助我。
我根据用户要求创建了一个小型 joomla 组件。其运行完美。现在我在这个组件中遇到一个问题,我试图在这个组件中提供 sef 支持,但我不知道该怎么做。
我读了这个链接 - http://docs.joomla.org/Supporting_SEF_URLs_in_your_component#Routing_URL.27s
我在我的组件中创建一个路由器文件。 在 router.php 文件中。
<?php
function joomBuildRoute( &$query )
{
$segments = array();
if(isset($query['view']))
{
$segments[] = $query['view'];
unset( $query['view'] );
}
if(isset($query['id']))
{
$segments[] = $query['id'];
unset( $query['id'] );
};
if(isset($query['layout']))
{
$segments[] = $query['layout'];
unset( $query['layout'] );
};
return $segments;
}
function joomParseRoute($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 'message':
$id = explode( ':', $segments[$count-1] );
$vars['id'] = (int) $id[0];
$vars['view'] = 'message';
break;
}
return $vars;
}
?>
i am newer to joomla component please help me.
i create one small joomla component as per user requirement. and its run perfect. now i have one issue in this component i am trying to provide sef support in this component but i have no idea how to do.
i read this link - http://docs.joomla.org/Supporting_SEF_URLs_in_your_component#Routing_URL.27s
and i create one router file in my component.
in router.php file.
<?php
function joomBuildRoute( &$query )
{
$segments = array();
if(isset($query['view']))
{
$segments[] = $query['view'];
unset( $query['view'] );
}
if(isset($query['id']))
{
$segments[] = $query['id'];
unset( $query['id'] );
};
if(isset($query['layout']))
{
$segments[] = $query['layout'];
unset( $query['layout'] );
};
return $segments;
}
function joomParseRoute($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 'message':
$id = explode( ':', $segments[$count-1] );
$vars['id'] = (int) $id[0];
$vars['view'] = 'message';
break;
}
return $vars;
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谢谢,
它还没有完成。
这里还有一些其他问题。
页面 url 重写但不重定向。
假设我点击消息按钮时的网址是
JOOMLA/joom/index.php/component/joom/message/default
表示重写但不显示消息页面。
谢谢。
thanks,
its not done.
some other problem here.
page url rewite but its not redirect on that.
suppose here url when i click on message button is
JOOMLA/joom/index.php/component/joom/message/default
means its rewrite but not display message page.
thanks.