Hi Together,
I’m using my nextcloud instance with multiple domains.
I have a theme desinged via standard admin-options.
Now, I’m trying to change the Theme only for one domain.
I tried some different approaches, the one described in [Howto] Individual themes per domain was the nearly working one for me.
But I’m not able to overwrite the name of the nextcloud instance given by the admin setting under Theming.
I’ll show you the code of my theme below which should change the name to ZZZ
, but it’s not used if I open the cloud in the browser.
Any idea how I can change it?
The Basics
- Nextcloud Server version:
31.0.6.2
- Operating system and version:
Ubuntu 22.04.5 LTS
- Web server and version: Apache
- PHP version:
8.1
- Is this the first time you’ve seen this error? (Yes / No):
Yes
- When did this problem seem to first start?
Trying domain Theming
- Installation method:
archive, migrated from oc
- Are you using CloudfIare, mod_security, or similar? (Yes / No):
no
Summary of the issue you are facing:
Trying to overwrite default theme by custom domain theme, colours and logo can be changed, but not the name of the instance.
Steps to replicate it (hint: details matter!):
- starting with a nextcloud with working trusted domains and default theming via admin settings
- adding
domains.config.php
with correct domain and theme - adding a theme folder (copied from example folder) with
defaults.php
, modifying there theme data. - colour changes and logo changes are working, but name is still the same from admin settings.
domains.config.php
:
<?php
// from https://help.nextcloud.com/t/howto-individual-themes-per-domain/27585/6
if (isset($_SERVER['HTTP_HOST'])) {
switch ($_SERVER['HTTP_HOST']) {
case 'ZZZ':
$CONFIG['theme']='XXX';
$CONFIG['mail_from_address'] = 'no-reply';
$CONFIG['mail_domain'] = 'YYY';
break;
# and so on for other domains
}
}
?>
defaults.php
:
code
<?php
/**
* @author Björn Schießle <schiessle@owncloud.com>
* @author Jan-Christoph Borchardt, http://jancborchardt.net
* @copyright Copyright (c) 2016, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
class OC_Theme {
/**
* Returns the base URL
* @return string URL
*/
public function getBaseUrl(): string {
return 'DOMAIN';
}
/**
* Returns the documentation URL
* @return string URL
*/
public function getDocBaseUrl(): string {
return 'https://docs.nextcloud.com';
}
/**
* Returns the title
* @return string title
*/
public function getTitle(): string {
return "ZZZ";
}
/**
* Returns the short name of the software
* @return string title
*/
public function getName(): string {
return 'ZZZ';
}
/**
* Returns the short name of the software containing HTML strings
* @return string title
*/
public function getHTMLName(): string {
return 'ZZZ';
}
/**
* Returns entity (e.g. company name) - used for footer, copyright
* @return string entity name
*/
public function getEntity(): string {
return 'YYY';
}
/**
* Returns slogan
* @return string slogan
*/
public function getSlogan(): string {
return 'XXX';
}
/**
* Returns short version of the footer
* @return string short footer
*/
public function getShortFooter(): string {
$entity = $this->getEntity();
$footer = '© ' . date('Y');
// Add link if entity name is not empty
if ($entity !== '') {
$footer .= ' <a href="' . $this->getBaseUrl() . '" target="_blank">' . $entity . '</a>' . '<br/>';
}
$footer .= $this->getSlogan();
return $footer;
}
/**
* Returns long version of the footer
* @return string long footer
*/
public function getLongFooter(): string {
$footer = '© ' . date('Y') . ' <a href="' . $this->getBaseUrl() . '" target="_blank">' . $this->getEntity() . '</a>' .
'<br/>' . $this->getSlogan();
return $footer;
}
/**
* Generate a documentation link for a given key
* @return string documentation link
*/
public function buildDocLinkToKey($key): string {
return $this->getDocBaseUrl() . '/server/15/go.php?to=' . $key;
}
/**
* Returns mail header color
* @return string
*/
public function getColorPrimary(): string {
return '#FFFFAA';
}
/**
* Returns variables to overload defaults from core/css/variables.scss
* @return array
*/
public function getScssVariables(): array {
return [
'color-primary' => '#FFFFAA',
'--image-background' => 'none',
];
}
}
Apps
Enabled:
[...]
- serverinfo: 3.0.0
- settings: 1.14.0
[...]
- theming: 2.6.1
[...]
Disabled:
- app_api: 5.0.2 (installed 5.0.2)
[...]
- theming_customcss: 1.18.0 (installed 1.18.0)
- theming_domain: 31.0.1 (installed 31.0.1)
[...]
Thanks for any hint/help!