Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more stable theming by using includes #3450

Closed
frisi opened this issue May 22, 2013 · 17 comments
Closed

more stable theming by using includes #3450

frisi opened this issue May 22, 2013 · 17 comments

Comments

@frisi
Copy link

frisi commented May 22, 2013

currently updating owncloud for themed sites often causes problems.

why?

more or less every minor update adds/(re)moves some javascript variables.
eg 5.0.6 which moved the requesttoken to an attribute in html (see #3445, or #3446)

using php inclues could help a lot.

how?

in my usecase - and i'm pretty sure it's the same for many others - theming owncloud is limited to different logo, css for colors and chaning the page title and the footer.

logo and css can easily be done and usually need not be changed when updating

for a different title and footer however, one needs to customize 4! different templates in the theme:

./core/templates/layout.base.php
./core/templates/layout.guest.php
./core/templates/layout.user.php
./apps/files_sharing/templates/public.php

if we introduce 2 additional templates (for footer and title) that can be customized in the theme too we would profit in 2 ways

  • people just need to customize title.php and footer.php instead of multliple files (also for addons they use)
  • owncloud updates would not break sites that just customized footer and title

of course, we might end up having different templates for guest and user layout because the show different content.

layout.guest.php and layout.base.php could use:

<title><?php include 'title.php'; ?></title>

layout.user.php:

<title><?php include 'title.user.php'; ?></title>
@DeepDiver1975
Copy link
Member

pull requests are welcome

@frisi
Copy link
Author

frisi commented Jun 28, 2013

@DeepDiver1975 i uploaded a proposal of how people could change the title and footer of their owncloud sites without having to update layout.xxx.php files after every owncloud update:

https://github.com/webmeisterei/core/tree/improvedTheming

i'm no php developer at all, so i need some help:

template->incThemed is a hack, and needs to be improved by an owncloud crack. maybe the functionality to use themed tempates (if available) can be safely included into the template->inc function then.

is there a changelog where you record the changes added between releases?

contributor agreement is on the way

@karlitschek
Copy link
Contributor

@frisi We developed a solution in the meantime. You only have to change a new file called defaults.php to do string changes like that. I will be in 5.0.8 scheduled for release in 2 weeks. In the meantime you can check the stable5 branch.

@frisi
Copy link
Author

frisi commented Jun 28, 2013

thanks for your quick response @karlitschek

the OC_Defaults::getName() will most problably work for the html page title
i added the configuration option mainly because i thought the "enterpriseName" or "communityName" might be used elsewhere where i don't want "frisi's cloud" to be used as a title.

for the footer, the approach in improvedTheming gives users a much more powerful way to customize the footer text.
the way it currently is solved in https://github.com/owncloud/core/blob/master/core/templates/layout.guest.php#L46 limits users to footers of the form

some text (some link with some title) Enterprise <linebreak>
slogan

in addition customizing the link or the texts could possibly break other templates using the entityname, baseurl or slogan.

if people really want to customize the footer, they will still need to edit layout.guest.php (et.al) and fix them when updating owncloud (#3445)

please have a look at the changes i made in the improvedTheming Branch and help me fix the include method https://github.com/webmeisterei/core/blob/improvedTheming/lib/template.php#L487

@frisi
Copy link
Author

frisi commented Jul 3, 2013

hi @karlitschek and @DeepDiver1975 - can you please let me know your feedback on this?

@karlitschek
Copy link
Contributor

@frisi The header and footer includes are an option. But we need a pull request as @DeepDiver1975 said.

@frisi
Copy link
Author

frisi commented Jul 3, 2013

@karlitschek i'll happily create the pull request. in order to do that i really need your feedback on the template->improvedTheming method
since this is where the inclusion of a (possible themed) footer template happens.
this magically works but you owncloud experts should have a look at this and tell me "how to do it right"(TM)

@jancborchardt
Copy link
Member

@schiesbn can you comment on this? is this solved with the new theming system?

@schiessle
Copy link
Contributor

This should be solved in current master.

With getLongFooter() you can define an arbitrary footer in your defaults.php (see: https://github.com/owncloud/core/blob/master/core/templates/layout.guest.php#L49)

Sorry for the confusion, but right before the enterprise release of ownCloud5 this changed a few times. But the current implementation can be expected to be stable and should be fairly customizable. Please have a look at the current defaults.php if it suits your needs https://github.com/owncloud/core/blob/master/lib/defaults.php

@jancborchardt
Copy link
Member

If it's fixed then also close this. :)

@frisi
Copy link
Author

frisi commented Aug 13, 2013

thanks to the changes added in #3791 i can confirm this ticket as closed.

as finding out how to apply customizations in a theme took me quite some time i'll share the code here

create a ``defaults.php` file in your theme folder:

<?php


class OC_Theme {

    private $cloudName;

    function __construct() {
        $this->cloudName = "My ownCloud";
    }

    public function getLongFooter() {
        return 'This is some long text containing <a href="#">links</a>';
    }

    public function getName() {
        return $this->cloudName;
    }

}

you can look up the variables and methods that can be customized in https://github.com/owncloud/core/blob/v5.0.10/lib/defaults.php

@chuckingit
Copy link

Hi - i tried using the code above in ownCloud 6.0.1 but could not get the cloudName to take although the footer worked great ... and while i did not truly understand (or know) what the variable $cloudName was doing nor the function __construct(), i did the following and voila - all worked ... not sure if i'm missing something but thought i'd share in case others had similar experience ... cheers - chuck scott

MyDomain.com'; } public function getLongFooter() { return 'MyDomain - some fun stuff about mydomain'; } }

@frisi
Copy link
Author

frisi commented Jan 27, 2014

had to change code when updating to 6.0.0, too @chuckingit:

you'll need to add a getTitle() method that returns the name

/**
 * The Title is used as part of the html <title> element
 */
public function getTitle() {
    return $this->themeName;
}

in general you can check OWNCLOUD_DIR/lib/private/defaults.php for possible settings
and grep (eg in owncloud/core/templates/) for functions (eg getName) to see where they are used.

@lgallard
Copy link

@chuckingit thanks. It worked perfectly in ownCloud 7!

@wastingoctober
Copy link

@chuckingit This also works in OwnCloud 8. Thanks!

@HunorR
Copy link

HunorR commented Apr 28, 2017

in OwnCloud 9 its not working

@lock
Copy link

lock bot commented Aug 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants