dr:themesettings
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dr:themesettings [2007/12/22 14:44] – external edit 127.0.0.1 | dr:themesettings [2020/11/23 17:23] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Adding settings on Drupal themes ====== | ====== Adding settings on Drupal themes ====== | ||
- | |||
===== WARNING ===== | ===== WARNING ===== | ||
Line 14: | Line 13: | ||
===== Adding settingability to themes ===== | ===== Adding settingability to themes ===== | ||
- | |||
- | |||
==== Creating the settings function for theme " | ==== Creating the settings function for theme " | ||
In the admin.theme file, we'll add the admin_settings function. If the theme is a plain PHP theme, it will already exist. If it is a PHPtemplate theme, as in the case of our " | In the admin.theme file, we'll add the admin_settings function. If the theme is a plain PHP theme, it will already exist. If it is a PHPtemplate theme, as in the case of our " | ||
- | + | <code php> | |
- | <php> | + | |
function admin_settings() | function admin_settings() | ||
{ | { | ||
Line 34: | Line 30: | ||
'# | '# | ||
); | ); | ||
- | |||
return system_settings_form(' | return system_settings_form(' | ||
} | } | ||
- | </php> | + | </code> |
Proof of concept example, no more: we just define a setting for the theme to use later on. In this case, it will be a CSS background color. NOTICE: a true world example should not take input and store it without some sanity checks. | Proof of concept example, no more: we just define a setting for the theme to use later on. In this case, it will be a CSS background color. NOTICE: a true world example should not take input and store it without some sanity checks. | ||
- | |||
- | |||
- | |||
- | |||
- | |||
==== Using the setting: node.tpl.php ==== | ==== Using the setting: node.tpl.php ==== | ||
With the " | With the " | ||
- | + | <code php> | |
- | <php> | + | |
<?php | <?php | ||
echo '< | echo '< | ||
Line 59: | Line 48: | ||
if ($page == 0) ... | if ($page == 0) ... | ||
[...the rest of the file is unchanged...] | [...the rest of the file is unchanged...] | ||
- | </php> | + | </code> |
Ugly inline styling, but this is just a demo, so we don't care. I add the "! important" | Ugly inline styling, but this is just a demo, so we don't care. I add the "! important" | ||
- | |||
===== Hooking it up ===== | ===== Hooking it up ===== | ||
Line 69: | Line 57: | ||
We now need to tell Drupal to stitch this together, and for this we'll need a module. | We now need to tell Drupal to stitch this together, and for this we'll need a module. | ||
- | |||
- | |||
==== The themesettings module ==== | ==== The themesettings module ==== | ||
- | <php> | + | <code php> |
// themesettings.module for Drupal 4.7 | // themesettings.module for Drupal 4.7 | ||
// (C) 2006 FG Marand | // (C) 2006 FG Marand | ||
Line 163: | Line 149: | ||
return $ret; | return $ret; | ||
} | } | ||
- | </php> | + | </code> |
- | + | ||
===== How does it work ? ===== | ===== How does it work ? ===== |
dr/themesettings.1198334698.txt.gz · Last modified: 2020/11/23 17:23 (external edit)