Page 1 of 1
Custom body class or id
Posted: Sun 28. Mar 2021, 09:21
by rbrickyboy
Hello,
I was wondering how to set body class or id,
I could not find it from the Admin->Templates, can someone please help..
Kind regards,
Re: Custom body class or id
Posted: Tue 30. Mar 2021, 16:32
by Uwe367
Please open the following file:
include/config/
conf.template_default.inc.php
Around line 287 and 288 you can add a body class or a body id or both. The classes you define there will be rendered in source code.
Code: Select all
$template_default['body']['id'] = '';
$template_default['body']['class'] = '';
Code: Select all
$template_default['body']['id'] = 'my_id';
$template_default['body']['class'] = 'my_class';
Kind Regards.
Re: Custom body class or id
Posted: Thu 1. Apr 2021, 13:37
by rbrickyboy
Re: Custom body class or id
Posted: Thu 1. Apr 2021, 20:36
by Uwe367
You're welcome.
Re: Custom body class or id
Posted: Fri 2. Apr 2021, 13:36
by dani
Uwe367 wrote: Tue 30. Mar 2021, 16:32
Please open the following file:
include/config/
conf.template_default.inc.php
Around line 287 and 288 you can add a body class or a body id or both. The classes you define there will be rendered in source code.
Code: Select all
$template_default['body']['id'] = '';
$template_default['body']['class'] = '';
Code: Select all
$template_default['body']['id'] = 'my_id';
$template_default['body']['class'] = 'my_class';
Kind Regards.
Instead of editing the "master" template config file, which will be over written if you copy&paste an phpwcms update, you can use your own custom config files at the template level.
Admin -> templates -> edit template: -> (Will overwrite default settings of config file
include/config/conf.template_default.inc.php) settings: -> dropdown "custom_settings.php"
Example template file:
https://github.com/slackero/phpwcms/blo ... ttings.php
Other case that describes how it works:
https://wiki.phpwcms.org/doku.php/engli ... m_settings
viewtopic.php?p=112333#p112333
My use case:
Code: Select all
// Have a look at the <body> Tag in the source view of your website
$template_default['body']['class'] = 'blog_custom_master';
// article default
$template_default['article']['image_default_width'] = '860';
$template_default['article']['image_default_height'] = '645';
Re: Custom body class or id
Posted: Fri 2. Apr 2021, 14:39
by Uwe367
dani wrote: Fri 2. Apr 2021, 13:36
Instead of editing the "master" template config file, which will be over written if you copy&paste an phpwcms update, you can use your own custom config files at the template level.
Yes you are right. I forgot to explain this. Sure it´s better to to create your own config file and this file (your own file) only can have the settings included which you need because the files, so far as i know, will be merged by rendering. I believe i have read this a long time ago in an other thread.
And this file is also usable in Structure Levels.