Recent Topics

1 Oct 27, 2007 15:11    

My b2evolution Version: 1.10.2

Hi

I tried searched this one out but wasn't able to find a satisfactory answer.

I would like the skins list to display as values within a combo/ select/ dropdown box instead of them appearing as list items.

While I did find the code for displaying the skins in a select box from the blue_sky skin _main.php file, I want to get rid of the button that is present along with the select box that is required after selecting the appropriate value to change the skin.

I would like that the skin changes automatically on change of value, rather than changing the value and then clicking the 'Get Skin' button.

Any help is appreciated.

Thanks

2 Oct 27, 2007 18:49

That would require javascript ( google "javascript select onchange" ) but in the interest of accessibilty ( and paranoid buggers like me ;) ) you really should keep the "go" button there ;)

¥

3 Oct 27, 2007 19:34

Hi ¥åßßå

I understand that onchange is required as an event to trigger the function that'll then do its bit and change the skin. Regarding the accessibility bit, I actually consult on accessibility besides other areas at a rather popular interactive /consultancy and it's quite my passion.

In this case, using JavaScript and not having the 'Go' button is all right because its used only to change skins (Visual!). Skins are not going to be of any use to users using screen readers, neither will they be of use to those using shell accounts and/ or/ working with text browsers as all that matters here is text. I hope we're on the same page now :)

I did try and add onchange to the code in the _skinslist.php file part of the blue_sky skin but did so unsuccessfully.

So here's the code below. Hope somebody can help me out with what to change in order to switch the skin on select of the right value rather than selecting a value and then clicking 'Go'. Thanks in advance!


<?php 
/**
 * This is the template that displays the available skins
 *
 * This file is not meant to be called directly.
 * It is meant to be called by an include in the _main.php template.
 *
 * This file is NOT part of the b2evolution distribution!
 * This is a hack by EdB (@link http://wonderwinds.com/} that alphabetizes skins.
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 * @copyright (c)2003-2006 by Francois PLANQUE - {@link http://fplanque.net/}
 *
 * @package evoskins
 * @subpackage blue_sky
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

# $skin_list_style is either 'menu' or 'list'
if(!isset($skin_list_style)) $skin_list_style = 'menu';
# for people who use 'menu' what will the button say?
if(!isset($skin_menu_button)) $skin_menu_button = T_('Get skin');
if(!isset($skin_menu_button_class)) $skin_menu_button_class = 'submit';

# this is what will start and end your skin section - affects both menu-style and list-style
if(!isset($skin_section_start)) $skin_section_start = '<span>'.T_('').'</span>';
if(!isset($skin_section_end)) $skin_section_end = "\n";

# THIS SECTION IS FOR LIST-STYLE ONLY
# this is what will start and end your skin list
if(!isset($skin_list_start)) $skin_list_start = '<ul>';
if(!isset($skin_list_end)) $skin_list_end = '</ul>';
# this is what will separate your skin links
if(!isset($skin_item_start)) $skin_item_start = '<li>';
if(!isset($skin_item_end)) $skin_item_end = '</li>';
# This is additionnal markup before and after the current skin
if(!isset($skin_selected_before)) $skin_selected_before = '<em>';
if(!isset($skin_selected_after)) $skin_selected_after = ' (current)</em>';
# This is additionnal markup before and after the default skin
if(!isset($skin_default_before)) $skin_default_before = '<strong>';
if(!isset($skin_default_after)) $skin_default_after = ' (default)</strong>';
# This is additionnal markup before and after the other skins
if(!isset($skin_other_before)) $skin_other_before = '';
if(!isset($skin_other_after)) $skin_other_after = '';

// ------------------------- //

$skins_array = array();
for( skin_list_start(); skin_list_next(); ) {
	$skins_array[] = skin_list_iteminfo( 'name', false );
	if( skin_list_iteminfo( 'name', false ) == $skin ) $this_skin = skin_list_iteminfo( 'name', false );
	if( skin_list_iteminfo( 'name', false ) == $Blog->get( 'default_skin' ) ) $def_skin = skin_list_iteminfo( 'name', false );
	}

sort($skins_array);
reset($skins_array);
$skins_count = count($skins_array);

echo $skin_section_start;

switch( $skin_list_style ) { 
	case 'menu':
	form_formstart( $Blog->dget( 'blogurl', 'raw' ), '', '', 'get', 'switcher' ) ?>
	<fieldset><label for="set"></label> 
	<select id="set" name="skin" onchange="<?php echo $skin_menu_button ?>;">
	<?php 
	for( $ii = 0; $ii < $skins_count; $ii++ ) { 
		switch( $skins_array[$ii] ) {
			case 'The_Skin_You_Want_To_Hide': // this hides a skin from the public list and still be available to you via the back office
			break;
			default:
			echo '<option value="'.$skins_array[$ii];
			echo '"';
			if( $skins_array[$ii] == $this_skin ) echo ' selected="selected" ';
			echo '>'.$skins_array[$ii];
			echo "</option>\n";
			}
		}
	?>
	</select>
	<br />
	<input type="submit" class="<?php echo $skin_menu_button_class ?>" value="<?php echo $skin_menu_button ?>" />
	</fieldset>
	</form>
	<?php 
	break;

	case 'list':
	echo $skin_list_start;
	for($ii = 0; $ii < $skins_count; $ii++) {
		switch( $skins_array[$ii] ) {
			case 'The_Skin_You_Want_To_Hide': // this hides a skin from the public list and still be available to you via the back office
			$close_line = false;
			break;
			case $this_skin: // this is for the skin you are on
			echo $skin_item_start;
			echo $skin_selected_before;
			echo $skins_array[$ii];
			echo $skin_selected_after;
			$close_line = true;
			break;
			case $def_skin: // this is for the default skin when you are not on it
			$skin_alt_text = 'switch to the '.$skins_array[$ii].' skin';
			$disp_this = url_add_param( get_bloginfo('blogurl'), 'skin='.$skins_array[$ii] );
			$disp_this .= '" title="'.$skin_alt_text;
			$disp_this .= '">'.$skins_array[$ii];
			echo $skin_item_start;
			echo $skin_default_before.'<a href="';
			echo $disp_this.'</a>';
			echo $skin_default_after;
			$close_line = true;
			break;
			default: // this is where most skins end up
			$skin_alt_text = 'switch to the '.$skins_array[$ii].' skin';
			$disp_this = url_add_param( get_bloginfo('blogurl'), 'skin='.$skins_array[$ii] );
			$disp_this .= '" title="'.$skin_alt_text;
			$disp_this .= '">'.$skins_array[$ii];
			echo $skin_item_start;
			echo $skin_other_before.'<a href="';
			echo $disp_this.'</a>';
			echo $skin_other_after;
			$close_line = true;
			break;
			}
		if( $close_line ) echo $skin_item_end."\n";
		}
	echo $skin_list_end."\n";
	unset($skins_array);
	break;
	}

echo $skin_section_end;

?>

4 Oct 28, 2007 17:22

Chi Loop wrote:

Skins are not going to be of any use to users using screen readers, neither will they be of use to those using shell accounts and/ or/ working with text browsers as all that matters here is text.

The paranoid amongst us have js disabled and yet may want to change your skin ( an obvious solution would be to use js to hide the go button ;) )

From a brief glance at your code this should work :

   <select id="set" name="skin" onchange="document.location.href='<?php echo regenerate_url( 'skin', 'skin=' )?>' + this.selectedIndex.value;">

¥

5 Oct 28, 2007 19:39

Hi ¥åßßå

The paranoid amongst us have js disabled and yet may want to change your skin ( an obvious solution would be to use js to hide the go button Wink )

I agree with you . Also included in the list would be institutions such as banks where JavaScript is disabled company wide by the IT folks.

And thank! The code works! :D

I would however like the skin switcher to be accessible by those with JavaScript turned off as well, so I was wondering if it would be possible to detect JS on the user's machine through PHP.

Like:
IF javascript=true, render code for the select box that changes skin onchange of value
ELSE render code for the select box accompanied by the go button

Would this be possible? If yes, I'd really appreciate if you can tell me how to code it as well. Thanks!

6 Oct 28, 2007 19:48

Why bother php, when the client has an answer built in? ( yeah yeah, call me blonde for suggesting hiding by js :p )

<noscript>
<input type="submit" value="sheeeesh, stop being paranoid ¥ ;)" />
</noscript>

;)

¥

7 Oct 29, 2007 20:05

Hey ¥åßßå

Thanks. That takes care of that :)

You rock!


Form is loading...