Custom body class or id

post everything related to phpwcms templates here
Post Reply
rbrickyboy
Posts: 14
Joined: Wed 22. Aug 2012, 17:35

Custom body class or id

Post 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,
User avatar
Uwe367
Posts: 1209
Joined: Sat 15. Sep 2007, 07:19
Location: Koblenz

Re: Custom body class or id

Post 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.
rbrickyboy
Posts: 14
Joined: Wed 22. Aug 2012, 17:35

Re: Custom body class or id

Post by rbrickyboy »

:D :D :D Thanks for your help!
User avatar
Uwe367
Posts: 1209
Joined: Sat 15. Sep 2007, 07:19
Location: Koblenz

Re: Custom body class or id

Post by Uwe367 »

You're welcome.
dani
Posts: 79
Joined: Sat 21. Jan 2006, 19:39
Location: Germany
Contact:

Re: Custom body class or id

Post 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"
template01.png
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';
User avatar
Uwe367
Posts: 1209
Joined: Sat 15. Sep 2007, 07:19
Location: Koblenz

Re: Custom body class or id

Post 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.
Image
Post Reply