mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00: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
|
||||
if($menuItem->controller) {
|
||||
$controllerObj = singleton($menuItem->controller);
|
||||
if(Controller::has_curr()) {
|
||||
// Necessary for canView() to have request data available,
|
||||
// e.g. to check permissions against LeftAndMain->currentPage()
|
||||
$controllerObj->setRequest(Controller::curr()->getRequest());
|
||||
if(!$controllerObj->canView($member)) continue;
|
||||
}
|
||||
}
|
||||
|
||||
$viewableMenuItems[$code] = $menuItem;
|
||||
}
|
||||
|
@ -342,8 +342,12 @@ class LeftAndMain extends Controller {
|
||||
}
|
||||
|
||||
function handleRequest($request) {
|
||||
$title = $this->Title();
|
||||
|
||||
$response = parent::handleRequest($request);
|
||||
$response->addHeader('X-Controller', $this->class);
|
||||
$response->addHeader('X-Title', $title);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@ -1176,6 +1180,13 @@ class LeftAndMain extends Controller {
|
||||
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
|
||||
*/
|
||||
|
@ -122,6 +122,10 @@
|
||||
var xhr = $.ajax({
|
||||
url: state.url,
|
||||
success: function(data, status, xhr) {
|
||||
// Update title
|
||||
var title = xhr.getResponseHeader('X-Title');
|
||||
if(title) document.title = title;
|
||||
|
||||
// Update panels
|
||||
contentEl.afterLoad(data, status, xhr);
|
||||
self.redraw();
|
||||
|
@ -4,7 +4,7 @@
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="Content-language" content="$i18nLocale" />
|
||||
<% base_tag %>
|
||||
<title>$ApplicationName | $SectionTitle</title>
|
||||
<title>$Title</title>
|
||||
</head>
|
||||
|
||||
<body class="loading cms $CSSClasses">
|
||||
|
Loading…
x
Reference in New Issue
Block a user