In my custom theme I am developing, I have a form API setting in theme-settings.php
that lets a user choose one of two options with a select menu as such:
$form['txtr_settings']['general_settings']['choose_slideshow'] = array(
'#type' => 'select',
'#title' => t('Choose a slideshow'),
'#default_value' => theme_get_setting('choose_slideshow'),
'#options' => array(
'basic' => t('Basic'),
'fancy' => t('Fancy'),
),
);
Then in my theme's page.tpl.php
I want the value the user has selected to be part of an if else statement.
Right now I have this code which does not seem to work:
<?php if (theme_get_setting('choose_slideshow') == 'basic')
include(dirname(__FILE__) . "/slideshow_alpha.inc");
else
include(dirname(__FILE__) . "/slideshow_beta.inc");
?>
I know if I have a simple single checkbox (checked = yes or '1' I can do something like this:
<?php if (theme_get_setting('choose_slideshow') == 1)
... but in this case I really want to show the user both options and have them choose one or the other in the select menu.
If I use either option on it's own without the if / else, each works fine so I think it's a question of my theme_get_setting
value. I am not really sure if this is a Drupal question or a PHP question that I should ask over on Stack Exchange.
drupal_get_path('theme', 'theme_name')
in place ofdirname(__FILE__)
(dirname(__FILE__)
is certainly acceptable and it works in the case of doing a php include...theme_get_setting('choose_slideshow')
at that point, have you printed it out to the screen?choose_slideshow
as a simple body class (added some code to template.php) to see what the value was, after that it all started working but I don't know why...