mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE Using $Link instead of $ApplicationTitle and $SectionTitle in LeftAndMain.ss. Adding new 'X-Title' HTTP header in order to support title changes for history.pushState
This commit is contained in:
parent
2f2096cd3a
commit
d68ec395a3
@ -208,11 +208,13 @@ class CMSMenu extends Object implements IteratorAggregate, i18nEntityProvider
|
|||||||
// checks on
|
// checks on
|
||||||
if($menuItem->controller) {
|
if($menuItem->controller) {
|
||||||
$controllerObj = singleton($menuItem->controller);
|
$controllerObj = singleton($menuItem->controller);
|
||||||
|
if(Controller::has_curr()) {
|
||||||
// Necessary for canView() to have request data available,
|
// Necessary for canView() to have request data available,
|
||||||
// e.g. to check permissions against LeftAndMain->currentPage()
|
// e.g. to check permissions against LeftAndMain->currentPage()
|
||||||
$controllerObj->setRequest(Controller::curr()->getRequest());
|
$controllerObj->setRequest(Controller::curr()->getRequest());
|
||||||
if(!$controllerObj->canView($member)) continue;
|
if(!$controllerObj->canView($member)) continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$viewableMenuItems[$code] = $menuItem;
|
$viewableMenuItems[$code] = $menuItem;
|
||||||
}
|
}
|
||||||
|
@ -342,8 +342,12 @@ class LeftAndMain extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleRequest($request) {
|
function handleRequest($request) {
|
||||||
|
$title = $this->Title();
|
||||||
|
|
||||||
$response = parent::handleRequest($request);
|
$response = parent::handleRequest($request);
|
||||||
$response->addHeader('X-Controller', $this->class);
|
$response->addHeader('X-Controller', $this->class);
|
||||||
|
$response->addHeader('X-Title', $title);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1176,6 +1180,13 @@ class LeftAndMain extends Controller {
|
|||||||
return self::$application_name;
|
return self::$application_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
function Title() {
|
||||||
|
return sprintf('%s | %s', $this->getApplicationName(), $this->SectionTitle());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the title of the current section, as shown on the main menu
|
* Return the title of the current section, as shown on the main menu
|
||||||
*/
|
*/
|
||||||
|
@ -122,6 +122,10 @@
|
|||||||
var xhr = $.ajax({
|
var xhr = $.ajax({
|
||||||
url: state.url,
|
url: state.url,
|
||||||
success: function(data, status, xhr) {
|
success: function(data, status, xhr) {
|
||||||
|
// Update title
|
||||||
|
var title = xhr.getResponseHeader('X-Title');
|
||||||
|
if(title) document.title = title;
|
||||||
|
|
||||||
// Update panels
|
// Update panels
|
||||||
contentEl.afterLoad(data, status, xhr);
|
contentEl.afterLoad(data, status, xhr);
|
||||||
self.redraw();
|
self.redraw();
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||||
<meta http-equiv="Content-language" content="$i18nLocale" />
|
<meta http-equiv="Content-language" content="$i18nLocale" />
|
||||||
<% base_tag %>
|
<% base_tag %>
|
||||||
<title>$ApplicationName | $SectionTitle</title>
|
<title>$Title</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="loading cms $CSSClasses">
|
<body class="loading cms $CSSClasses">
|
||||||
|
Loading…
Reference in New Issue
Block a user