ThemeShaper Forums » Thematic

[closed]

wp_dropdown_{categories|pages} in Thematic

(4 posts)
  • Started 11 years ago by MarSOnEarth
  • Latest reply from MarSOnEarth
  • This topic is resolved
  1. MarSOnEarth
    Member

    WP provides these two functions and Thematic provides for the *_categories variant as a widget. On the site I'm working on I envisioned the main navigation to be the two dropdowns + breadcrumbs, but I've ran into a problem; while the categories dropdown switches to the selected category automagically, the pages dropdown does not. Here's how I'm using the two:

    $cat_args['show_option_none'] = __('Select Posts in...');
    wp_dropdown_categories($cat_args);
    
    $page_args['show_option_no_change'] = __('Information');
    wp_dropdown_pages($page_args);

    What is the magic that makes the two functions act differently? BTW, the widgetized Categories in Thematic provides its own JS switching routine, but even without it the wp_dropdown_categories() works, and the *_pages() with that (adjusted) JS code still does not. What gives? Help me out of this box I painted myself into, please.

    Posted 11 years ago #
  2. MarSOnEarth
    Member

    An hour later (+dinner time): note to self; Test one thing at a time (there already was the Categories widget on the page. Here's the working code:

    <div id="LM_access">
    	<div id="cat_menu">
    		<ul>
    			<?php
    		$cat_args['show_option_none'] = __( 'Select Posts in...' );
    		wp_dropdown_categories( $cat_args );
    
    		?>
    	</div>
    	<script type="text/javascript">
    	/* <![CDATA[ */
    		var dropdown = document.getElementById("cat");
    	function onCatChange() {
    		if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
    			location.href = "http://localhost/wordpress/?cat="+dropdown.options[dropdown.selectedIndex].value;
    		}
    	}
    	dropdown.onchange = onCatChange;
    	/* ]]> */
    	</script>
    
    	<div id="page_menu">
    		<ul>
    			<?php
    		$page_args['show_option_no_change'] = __( 'Information' );
    		wp_dropdown_pages( $page_args );
    
    		?>
    	</div>
    
    	<script type="text/javascript">
    	/* <![CDATA[ */
    		var ddown = document.getElementById("page_id");
    		function onPageChange() {
    			if ( ddown.options[ddown.selectedIndex].value > 0 ) {
    				location.href = "http://localhost/wordpress/?page_id="+ddown.options[ddown.selectedIndex].value;
    			}
    		}
    		ddown.onchange = onPageChange;
    	/* ]]> */
    	</script>
    </div>

    Thanks to Ian for Thematic. With what's there somehow I'm forging ahead with WP without knowing much of PHP.

    Posted 11 years ago #
  3. It would be interesting to see a screenshot of this 'in-action' MarS :)

    Posted 11 years ago #
  4. MarSOnEarth
    Member

    Hopefully soon. Most of the "mechanisms" of the site are already in place. I still have to solve the per page dynamic updates of the Connections plug-in content, and it looks like I'll have to do it via a custom Loop; not trivial for someone not well versed in PHP, but there are many examples to draw upon. Gosh! What would I do without the community of WP users doing it all before me.

    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.