• Resolved foodin65

    (@foodin65)


    Hello All,

    I’m in the process of developing a simple plugin for a network of sites that I host using WordPress 3.0RC1.

    The plugin is quite simple at the moment. All it does is have the name of the parent site in the network and a Jump menu of other important sites in the network.

    My Jump Menu is kinda dumb though as I’ve just written it in HTML. I need it to be dynamic. Currently it doesn’t know which site it’s on and so it always thinks it’s on the first site listed in the menu… which pretty much makes the jump menu useless.

    I’ve pasted my whole plugin code here:
    http://wordpress.pastebin.ca/1874637

    I didn’t post the CSS, but you can see the CSS with firebug here:
    http://myfrn.org – NSFW (no pictures, just uses the word Foreskin in the title – information only site).

    Can someone help he give my jump menu a brain?

    I have more questions and things I’d like to do with this plugin… but that’s a different topic for a different time.

Viewing 1 replies (of 1 total)
  • I think i can help you with this, you need to reposition your code, it’s currently printing out the menu into the head of the document(which is invalid).

    I assume the reason you hooked onto wp_head, is because you couldn’t find another way to hook the menu into a header position across all pages, you could hook onto the get_header action instead.

    I’ve re-written part of the function for you and updated the action, you’ll need to test to let me know if it works ok.

    function MyFrnHeaderBar (){
    
    	$site_links = array(
    		'Select a site' => '',
    		'MyFRN.org' => 'http://myfrn.org',
    		'MFCommunity' => 'http://community.myfrn.org',
    		'Powdered Pull Balls' => 'http://powderedpullballs.myfrn.org'
    	);
    	$current_site = get_bloginfo('wpurl');
    	?>
    	<div id="myfrnheader">
    		<div id="myfrnheader_title"><a href="http://myfrn.org" title="MyFRN.org">MyFRN.org Sites</a>:</div>
    		<form name="Jump" action="" id="myfrnheader_jumpmenu_form">
    			<div id="myfrnheader_jumpmenu_container">
    				<select name="Menu" onchange="location=document.Jump.Menu.options[document.Jump.Menu.selectedIndex].value;" id="myfrnheader_jumpmenu">
    
    					<?php foreach( $site_links as $name => $link ) : ?>
    
    					<?php $selected = ( $current_site == $link ) ? 'selected="selected" ' : ''; // Shorthand if/else for setting var ?>
    
    					<option <?php echo $selected; ?>value="<?php echo $link ?>">
    						<?php echo $name ?>
    					</option>
    
    					<?php endforeach; ?>
    
    				</select>
    			</div>
    		</form>
    		<div id="fancynav">
    			Login
    		</div>
    	</div>
    <?php
    }
    add_action( 'get_header', 'MyFrnHeaderBar' );

    Havn’t touched the other function or action, so just leave those as is..

Viewing 1 replies (of 1 total)
  • The topic ‘My Jump Menu Needs A Brain’ is closed to new replies.