Web based family history software

This Help forum is for issues relates to the latest release (1.7.5). For issues related to beta or github version please use their own Help forum.
Before asking for help please read "How to request help" by clicking on that tab above here."

Question [SOLVED] how to add/modify a theme?

  • jopla
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago - 7 years 8 months ago #1 by jopla
how to add/modify a theme? was created by jopla
Hi,

I like to modify a theme. Earlier I modified the theme itself but with the new release my changes are gone.

Somebody told me that I have to make a copy of the "_custom" directory to f.e. "mytheme" and put there the changes.

But as soon I made a copy of that directory the whole webtreessite doesn't work anymore. Have I to webtrees anywhere else also that there will be a new theme?

Thanks for reaction.

Jop
Last edit: 7 years 8 months ago by jopla.

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #2 by JustCarmen
Replied by JustCarmen on topic how to add/modify a theme?
Hi Jop, I have just answered your email you sent me earlier today. Let me know if it works or if you have still any issues.


Carmen
Designer of the JustLight theme (comes with a light and dark color palette), Fancy Imagebar, Fancy Research Links and Fancy Treeview for webtrees 2


Check my website at www.justcarmen.nl

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #3 by Jackie
Replied by Jackie on topic how to add/modify a theme?
Hi,

The answer posted here would help others..

Do we need « How to customise a theme? » in the Wiki - category Customising ?
wiki.webtrees.net/en/Category:Customising_webtrees

Please Log in or Create an account to join the conversation.

  • jopla
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago - 7 years 8 months ago #4 by jopla
Replied by jopla on topic how to add/modify a theme?
Till now I don't have an answer/solution!
Last edit: 7 years 8 months ago by jopla.

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #5 by Jackie
Replied by Jackie on topic how to add/modify a theme?
Hi Jopla,

Carmen posted that she sent you the answer by email.

Please Log in or Create an account to join the conversation.

  • jopla
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago #6 by jopla
Replied by jopla on topic how to add/modify a theme?
But if the answer is not the solution .... ?

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago - 7 years 8 months ago #7 by Jackie
Replied by Jackie on topic how to add/modify a theme?
Hi Jopla,

Did you rename the folder _custom when you copied it?

e.g. _custom = joplatheme

Did you change the first line of the file theme.php with your theme's name?

namespace MyNamespace\MyProject;
should become:
namespace Joplatheme\webtrees;


EDIT: In the file theme.php, you should change the name _custom with your theme's name e.g. joplatheme, everywhere you see it.
Last edit: 7 years 8 months ago by Jackie.

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #8 by fisharebest
Replied by fisharebest on topic how to add/modify a theme?
> Somebody told me that I have to make a copy of the "_custom" directory to f.e. "mytheme" and put there the changes.

That is correct.

What changes did you make?

> But as soon I made a copy of that directory the whole webtreessite doesn't work anymore.

I guess there was an error in your changes.

"doesn't work anymore". What does this mean? Do you get an error message?

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

  • jopla
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago - 7 years 8 months ago #9 by jopla
Replied by jopla on topic how to add/modify a theme?
Hello,

There is a problem with the copying of the _custom dir. Or more with the theme.php. If there are 2 theme.php (1 in _custom and 1 in theme_jop) the site crashs.

If I rename the theme.php in _custom to theme.php.org than there is placed a new theme.php at the update and the site will crash again ...
Last edit: 7 years 8 months ago by jopla. Reason: extra informatie

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #10 by fisharebest
Replied by fisharebest on topic how to add/modify a theme?
Look in your webserver error logs. These will tell you what is wrong.

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

  • jopla
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago #11 by jopla
Replied by jopla on topic how to add/modify a theme?
The problem is:
1. if you make a copy of the _custom directory there will be 2 theme.php files and that will give any php error.
2. if you rename the _custom directory there will be installed at update a new _custom directory with again a 2nd theme.php file -> error

so, if you keep the _custom directory and change the theme.php, can I be sure that the theme.php will be not overwrite at update by the original?

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #12 by fisharebest
Replied by fisharebest on topic how to add/modify a theme?
> if you make a copy of the _custom directory there will be 2 theme.php files and that will give any php error.

It is OK to have many "theme.php" files.

There exists:
clouds/theme.php
colors/theme.php
fab/theme.php
minimal/theme.php
webtrees/theme.php
xenea/theme.php

This is not your error.

Look in your webserver error logs. You will see the exact error.

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

  • jopla
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago #13 by jopla
Replied by jopla on topic how to add/modify a theme?

fisharebest wrote: > if you make a copy of the _custom directory there will be 2 theme.php files and that will give any php error.
Look in your webserver error logs. You will see the exact error.


How?

Please Log in or Create an account to join the conversation.

  • jopla
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago - 7 years 8 months ago #14 by jopla
Replied by jopla on topic how to add/modify a theme?

fisharebest wrote: > if you make a copy of the _custom directory there will be 2 theme.php files and that will give any php error.
It is OK to have many "theme.php" files.


Maybe, but probably there will be used in _custom/theme.php and theme_jop/theme.php the same varianles or objects or something like that.

Or two times "return new MyTheme".

Maybe you cannot create a new object if the object allready excist?

Or have I to modyfy this line also:
namespace MyNamespace\MyProject;
in f.e.
namespace MyNamespace\Theme_Jop_Project;
?
Last edit: 7 years 8 months ago by jopla.

Please Log in or Create an account to join the conversation.

  • jopla
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago - 7 years 8 months ago #15 by jopla
Replied by jopla on topic [SOLVED] how to add/modify a theme?
Problem solved.

You have to change the namespace-name. Maybe somebody can write a short manual how to make your own profile?
Last edit: 7 years 8 months ago by jopla.

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #16 by fisharebest
Replied by fisharebest on topic [SOLVED] how to add/modify a theme?
What was the problem?

If you post the answer here, it may help others with the same problem.

Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net

Please Log in or Create an account to join the conversation.

  • jopla
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago - 7 years 8 months ago #17 by jopla
Replied by jopla on topic [SOLVED] how to add/modify a theme?
The problem was that there is a lack of a good (Dutch) manual :-)

PS. You was to fast with your reply, see above. :-)
Last edit: 7 years 8 months ago by jopla.

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago - 7 years 8 months ago #18 by JustCarmen
Replied by JustCarmen on topic how to add/modify a theme?

The answer posted here would help others..


Yes, Jackie I know. But I'd just answered his questions in Dutch (because he wrote to me in Dutch) when I saw his message here. If I had the time I would have translated it here but I was in a hurry, sorry.

But if the answer is not the solution .... ?

You just asked me some questions which I've answered but I can't help if it wasn't the whole solution when I only get parts of the story.

But tonight you sent me your theme file to look at it. And as I said earlier you are on the right track. Only one little change needed to get it working:
Code:
<?php namespace MyNamespace\MyProject; /** * webtrees: online genealogy * Copyright (C) 2016 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * 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 General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ use Fisharebest\webtrees\Menu; use Fisharebest\webtrees\Theme\ColorsTheme; /** * Class CustomTheme - This is a template showing how to create a custom theme. * * Since theme folders beginning with an underscore are reserved for special * use, you should copy this entire folder ("themes/_custom") to a new name. * For example, "themes/custom". You should also rename the class. * * In this example, we are extending the webtrees theme, but you could * also extend any of the core themes, or even the base theme. * * Only the first two functions are required: themeId() and themeName(). * The rest are just examples, and should be removed in actual themes. */ class ThemeJop extends ColorsTheme { /** * Give your theme a unique identifier. Themes beginning with an underscore * are reserved for internal use. * * {@inheritdoc} */ public function themeId() { return 'theme_jop'; } /** * Give your theme a name. This is shown to the users. * Use HTML entities where appropriate. e.g. “Black &amp; white”. * * You could use switch($this->locale) {} to provide a translated versions * of the theme name. * * {@inheritdoc} */ public function themeName() { return 'Jop-s theme'; } /** * This is an example function which shows how to add an additional CSS file to the theme. * * {@inheritdoc} */ public function stylesheets() { $css_files = parent::stylesheets(); // Put a version number in the URL, to prevent browsers from caching old versions. $css_files[] = WT_BASE_URL . 'themes/theme_jop/custom-v1.0.css'; return $css_files; } /** * This is an example function which shows one way to remove an entry from a menu. * * @param string $surname The significant surname for the page. * * {@inheritdoc} */ public function menuLists($surname) { // Start with the default "Lists" menu. $menu = parent::menuLists($surname); // Remove the "notes" sub-menu. $submenus = array_filter($menu->getSubmenus(), function (Menu $menu) { return $menu->getClass() !== 'menu-list-note'; }); // Replace the sub-menus $menu->setSubmenus($submenus); return $menu; } } return new ThemeJop // This script must return a theme object.

Sorry I can't show the changes inside the code block but I have changed your code in two places. Class MyTheme is changed in Class ThemeJop and at the bottom I have changed 'return new MyTheme' in 'return new ThemeJop'.

Your script wasn't working because the class 'MyTheme' already existed.


Carmen
Designer of the JustLight theme (comes with a light and dark color palette), Fancy Imagebar, Fancy Research Links and Fancy Treeview for webtrees 2


Check my website at www.justcarmen.nl
Last edit: 7 years 8 months ago by JustCarmen.

Please Log in or Create an account to join the conversation.

More
7 years 8 months ago #19 by Jackie
Replied by Jackie on topic how to add/modify a theme?

JustCarmen wrote: Yes, Jackie I know. But I'd just answered his questions in Dutch (because he wrote to me in Dutch) when I saw his message here. If I had the time I would have translated it here but I was in a hurry, sorry.


No problem, Carmen. I know how devoted you are to webtrees. Thank you.

Please Log in or Create an account to join the conversation.

  • jopla
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
7 years 8 months ago - 7 years 8 months ago #20 by jopla
Replied by jopla on topic how to add/modify a theme?
The code Carmen send in is not complete correct. I think, I m allmost sure, the problem is in line 2.
Herewith is the original _custom/theme.php. In red are the items you have to rename in my opinion if you make a copy of the _custom dir,

Please, can somebody check my comments?

<?php
namespace MyNamespace\MyProject; //change to f.e. MyThemeProject

/**
comments
*/
use Fisharebest\webtrees\Menu;
use Fisharebest\webtrees\Theme\webtreesTheme; // choose here the theme which you want to use as base for your theme.
You can find the name in the theme.php from the choosen theme. (f.e. webtreesTheme or ColorsTheme)
but I m not complete sure if I m right here.


/**
comments
*/
class MyTheme extends webtreesTheme {
//// choose here the theme which you want to use as base for your theme. You can find the name in the theme.php from the choosen theme.
//(f.e. webtreesTheme or ColorsTheme).

/**
* Give your theme a unique identifier. Themes beginning with an underscore
* are reserved for internal use.
*
* {@inheritdoc}
*/
public function themeId() {
return '_custom'; // choose here a name without "_" at start, f.f. my_theme
}

/**
* Give your theme a name. This is shown to the users.
* Use HTML entities where appropriate. e.g. “Black &amp; white”.
*
* You could use switch($this->locale) {} to provide a translated versions
* of the theme name.
*
* {@inheritdoc}
*/
public function themeName() {
return 'Custom theme'; // f.e. Own Theme. This will be shown in the menu.
}

/**
* This is an example function which shows how to add an additional CSS file to the theme.
*
* {@inheritdoc}
*/
public function stylesheets() {
$css_files = parent::stylesheets();
// Put a version number in the URL, to prevent browsers from caching old versions.
$css_files[] = WT_BASE_URL . 'themes/_custom/custom-v1.0.css'; // choose the path of the css file for the theme

return $css_files;
}

/**
* This is an example function which shows one way to remove an entry from a menu.
*
* @param string $surname The significant surname for the page.
*
* {@inheritdoc}
*/
public function menuLists($surname) {
// Start with the default "Lists" menu.
$menu = parent::menuLists($surname);
// Remove the "notes" sub-menu.
$submenus = array_filter($menu->getSubmenus(), function (Menu $menu) {
return $menu->getClass() !== 'menu-list-note';
});
// Replace the sub-menus
$menu->setSubmenus($submenus);

return $menu;
}
}

return new MyTheme; // This script must return a theme object.

Last edit: 7 years 8 months ago by jopla.

Please Log in or Create an account to join the conversation.

Powered by Kunena Forum
}