我希望在所有菜单url中使用当前会话国家名,这只是为了在url中显示目的。
假设现在的国家是北科雷亚
当前url是http://localhost/project-name/产品/商业垂直版。
我想加入
url为http://localhost/project-name/north-corea__/products/business_verticals
而北科雷亚只用于显示,而不是用于页面。
我在这次会议上有国名$_SESSION“csite”.我希望将此会话值用于所有菜单url。
发布于 2015-05-18 10:00:09
Try:
Add code on routes.php
$currentPath = Router::getPaths(true);
$currentUrl = '';
if (!empty($currentPath->query['url'])) {
$currentUrl = trim($currentPath->query['url']);
} elseif (!empty($currentPath->url)) {
$currentUrl = trim($currentPath->url);
}
if (!empty($currentUrl)) {
$currentUrlArr = explode('/', trim($currentUrl, "/"));
if ($currentUrlArr[0] == 'north-corea') {
Router::connect('/*', array('controller' => $currentUrlArr[1], 'action' => $currentUrlArr[2]));
}
}发布于 2015-05-18 11:34:02
Cakephp本机支持它所称的url前缀。它们被加载到routes.php配置文件中,然后可以在应用程序的其他地方使用。要使用给定前缀构造url,如您的示例中所做的那样
[ 'controller' => 'products', 'action' => 'business-verticals', 'north-corea' => true ]https://stackoverflow.com/questions/30298206
复制相似问题