WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] dynamic sidebar Q (8 posts)

  1. Cathy Tibbles
    Member
    Posted 7 years ago #

    I have been reading/ learning codex php instructions for layout and design. Starting from my current theme Multitalentedmommy I'm trying to make some layout changes to the sidebars, I believe that this codex doc is deprecated?
    http://codex.wordpress.org/Customizing_Your_Sidebar#Plugin_Resources There are instructions to change the sidebar.php file. But the only thing my sidebar.php file has is some code instructions to get the dynamic sidebar file if one exists. So, where would i find the dynamic sidebar files? I looked in wp-admin-widgetsidebars, and it is just the style and instructions for the admin menu, to select options for your widgetized sidebar. I also looked in the css file for my theme - NOT THERE!! Where do I find the guts of the "dynamic sidebar"?

    thanks,
    Cathy

  2. shadow
    Member
    Posted 7 years ago #

    In your theme files, look for dynamic_sidebar.php or something similar.

    It depends on how your theme author named it, but it should be something like that.

    Failing that, look for left or right sidebar.php as well.

  3. Cathy Tibbles
    Member
    Posted 7 years ago #

    Thanks again for getting back to me.

    Unfortunately, that exactly, is my problem. There are sidebar php files. but NO dynamic_sidebar files. Would they be somehow in the db?

    This is the entire contents of the theme (from my cpanel):

    Create New File
    404.php 0 k 0644
    Readme.txt 0 k 0644
    archive.php 2 k 0644
    archives.php 0 k 0644
    comments-popup.php 4 k 0644
    comments.php 3 k 0644
    footer.php 0 k 0644
    from style sheet.txt 0 k 0644
    functions.php 0 k 0644
    header.php 1 k 0644
    index.php 1 k 0644
    links.php 0 k 0644
    page.php 0 k 0644
    screenshot.png 35 k 0644
    search.php 1 k 0644
    searchform.php 0 k 0644
    sidebar.php 0 k 0644
    sidebar2.php 1 k 0644
    single.php 1 k 0644
    style.css

  4. Cathy Tibbles
    Member
    Posted 7 years ago #

    here's the code that I found:
    In the wp-includes/widgets.php file:
    in the *default widgets* section:

    • function wp_widget_pages( $args ) {
      extract( $args );
      $options = get_option( 'widget_pages' );

      $title = empty( $options['title'] ) ? __( 'Pages' ) : $options['title'];
      $sortby = empty( $options['sortby'] ) ? 'menu_order' : $options['sortby'];
      $exclude = empty( $options['exclude'] ) ? '' : '&exclude=' . $options['exclude'];

      if ( $sortby == 'menu_order' ) {
      $sortby = 'menu_order, post_title';
      }

      $out = wp_list_pages( 'title_li=&echo=0&sort_column=&depth=1' . $sortby . $exclude );

      if ( !empty( $out ) ) {
      ?>
      <?php echo $before_widget; ?>
      <?php echo $before_title . $title . $after_title; ?>

        <?php echo $out; ?>

      <?php echo $after_widget; ?>
      <?php
      }
      }

      This is DEEP CODE for me!!! Is it a BAD idea to change the WP code itself??? I simply want to change that bolded code to include "depth=1".

  5. Cathy Tibbles
    Member
    Posted 7 years ago #

    OKay - tried that. For anyone interested, this is what it did:

    - to add parameters to the code, means that it is restricted in the information that it gathers from the db. Thus, it is restricted when I click on the parent page from showing sub-pages. I am sure that if I have all the data retrieved into the dynamic sidebar, that there is some sort of code once there, that will help me to change how it is displayed - formatted.

    Anyone know how to hide the sub-pages in the pages-navigation (other than "exclude")? and then show the subpages when the parent page is clicked on? there has to be a snippet with the argument - if, then, else type of thinking - but how does that translate into PHP?

    AND, if the sidebar function in the theme, only asks for "get registered sidebars", and then the dynamic sidebars have all this WP code getting stuff from the db - where does one present arguments for the layout?

    THANKS for sharing your knowledge. :)

  6. Root
    Member
    Posted 7 years ago #

    You are into some very high end php based layout stuff with this. Might be a bit beyond the scope of the forum. Most people who need to do this can do it themselves :)

  7. Alex Cragg
    Member
    Posted 7 years ago #

    If i understand you, i think you've gotten lost somewhere, so excuse this if i've miss understood:

    the 'dynamic sidebar' bit in your sidebar is telling that sidebar to use widgets, which are defined on your presentation tab in the admin screen, once you have a widget added and saved, this then appears in your sidebar on your site.

    If you look at the source of your page now, this widget you added will have some XHTML mark up, such as <ul>s and <li>s for an unordered list. You can now style your sidebar using these tags in your CSS, they will probably be prefixed by something with 'widget' in the XHTML class.

    In terms of hiding sub pages until their parents have been clicked on, look at using a plugin, this makes things much easier, and you dont need to remember your changes that you made to the core code when you upgrade.

    check out these two pages
    http://www.webspaceworks.com/resources/wordpress/30/ - for the plugin itself
    http://www.webspaceworks.com/resources/wordpress/67/ - and for info on using it with widgets

    hope this helps

  8. Cathy Tibbles
    Member
    Posted 7 years ago #

    Root - I AM starting to feel very over-my-head in this stuff.
    Epicalex - that is the folding plugin that i was trying to use. It does exactly what I need. However, to use it - it has to be installed in place of the wp-get-pages command in the sidebar. Thus the trouble! My sidebar's only command is get-dynamic-sidebar!

    All is running smoothly now. instead of trying to input arguments in the above code (from widget.php), I replaced the code itself with the plugin code - voila! I'm happy, happy, happy!

    THanks for gettin' back to me.

Topic Closed

This topic has been closed to new replies.

About this Topic