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."
  • Page:
  • 1
  • 2

TOPIC: [SOLVED] how to add/modify a theme?

how to add/modify a theme? 1 year 11 months ago #1

  • jopla
  • jopla's Avatar
  • Offline
  • Junior
  • Posts: 119
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: 1 year 11 months ago by jopla.
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #2

  • JustCarmen
  • JustCarmen's Avatar
  • Offline
  • Frequent
  • Posts: 914
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 JustBlack theme, the JustLight theme and the Fancy modules

Check it out at www.justcarmen.nl

webtrees 1.7.9 at www.wijzijnfamilie.nl
PHP 5.6.16

wt 1.8.0 (latest dev) on local testsite for theme and module development
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #3

  • Jackie
  • Jackie's Avatar
  • Offline
  • Platinum
  • Posts: 4691
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
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #4

  • jopla
  • jopla's Avatar
  • Offline
  • Junior
  • Posts: 119
Till now I don't have an answer/solution!
Last Edit: 1 year 11 months ago by jopla.
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #5

  • Jackie
  • Jackie's Avatar
  • Offline
  • Platinum
  • Posts: 4691
Hi Jopla,

Carmen posted that she sent you the answer by email.
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #6

  • jopla
  • jopla's Avatar
  • Offline
  • Junior
  • Posts: 119
But if the answer is not the solution .... ?
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #7

  • Jackie
  • Jackie's Avatar
  • Offline
  • Platinum
  • Posts: 4691
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: 1 year 11 months ago by Jackie.
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #8

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Posts: 10262
> 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 - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net
The administrator has disabled public write access.
Do you need a web hosting solution for your webtrees site?
If you prefer a host that specialises in webtrees, the following page lists some suppliers able to provide one for you: 

how to add/modify a theme? 1 year 11 months ago #9

  • jopla
  • jopla's Avatar
  • Offline
  • Junior
  • Posts: 119
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: 1 year 11 months ago by jopla. Reason: extra informatie
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #10

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Posts: 10262
Look in your webserver error logs. These will tell you what is wrong.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #11

  • jopla
  • jopla's Avatar
  • Offline
  • Junior
  • Posts: 119
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?
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #12

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Posts: 10262
> 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 - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #13

  • jopla
  • jopla's Avatar
  • Offline
  • Junior
  • Posts: 119
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?
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #14

  • jopla
  • jopla's Avatar
  • Offline
  • Junior
  • Posts: 119
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: 1 year 11 months ago by jopla.
The administrator has disabled public write access.

[SOLVED] how to add/modify a theme? 1 year 11 months ago #15

  • jopla
  • jopla's Avatar
  • Offline
  • Junior
  • Posts: 119
Problem solved.

You have to change the namespace-name. Maybe somebody can write a short manual how to make your own profile?
Last Edit: 1 year 11 months ago by jopla.
The administrator has disabled public write access.

[SOLVED] how to add/modify a theme? 1 year 11 months ago #16

  • fisharebest
  • fisharebest's Avatar
  • Offline
  • Administrator
  • Posts: 10262
What was the problem?

If you post the answer here, it may help others with the same problem.
Greg Roach - This email address is being protected from spambots. You need JavaScript enabled to view it. - fisharebest.webtrees.net
The administrator has disabled public write access.

[SOLVED] how to add/modify a theme? 1 year 11 months ago #17

  • jopla
  • jopla's Avatar
  • Offline
  • Junior
  • Posts: 119
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: 1 year 11 months ago by jopla.
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #18

  • JustCarmen
  • JustCarmen's Avatar
  • Offline
  • Frequent
  • Posts: 914
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:
<?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 JustBlack theme, the JustLight theme and the Fancy modules

Check it out at www.justcarmen.nl

webtrees 1.7.9 at www.wijzijnfamilie.nl
PHP 5.6.16

wt 1.8.0 (latest dev) on local testsite for theme and module development
Last Edit: 1 year 11 months ago by JustCarmen.
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #19

  • Jackie
  • Jackie's Avatar
  • Offline
  • Platinum
  • Posts: 4691
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.
The administrator has disabled public write access.

how to add/modify a theme? 1 year 11 months ago #20

  • jopla
  • jopla's Avatar
  • Offline
  • Junior
  • Posts: 119
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 & 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: 1 year 11 months ago by jopla.
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Powered by Kunena Forum