Making the Settings screen logo clickable
1
So I wanted to link the uploaded backend logo (the one that appears on /backend/system/settings) to my website.
You can do this in 2 ways. First being by overloading the controller middleware:
Event::listen('backend.page.beforeDisplay', function ($backendController, $action, $params) {
if ($backendController instanceof \System\Controllers\Settings && $action === 'index') {
$backendController->middleware(function ($request, $response) {
$basePath = url('//www.yoururl.com');
$injectedJs = <<< THEINJECTEDJS
<script>
$(function() {
$('.layout-cell .oc-logo-transparent').on('click', function(){
document.location.href = '$basePath';
return false;
});
});
</script>
THEINJECTEDJS;
$response->setContent($response->getContent() . $injectedJs);
});
}
});
The second, you could also do this by listening to the extendHead view event:
Event::listen('backend.layout.extendHead', function ($controller, $layout) {
$basePath = url('//www.yoururl.com');
return <<< THEINJECTEDJS
<script>
$(function() {
$('.layout-cell .oc-logo-transparent').on('click', function(){
document.location.href = '$basePath';
return false;
});
});
</script>
THEINJECTEDJS;
}
Which is similar but does the same without overloading the middleware function.
There are no comments yet
Be the first one to comment