Support » Plugin: WP-dTree » [Plugin: WP-dTree] Open only node being browsed?

  • The plugin works great, but it’s missing one key feature that should be there. Most of the time we don’t need to see all of the nodes, and being able to restrict to a specific parent node in config isn’t feasible for all pages because we’d have to make a new sidebar for each page to have specific settings for the tree on that page. This could easily be fixed if we had a checkbox to show just the node and children of the current page. This is probably a 10m fix for the dev that knows the code.

    I’ll happily code the mods myself, but I’d like to know where in the code to look I could go hunting for it, but a hint would save a lot of time.

    So instead of showing this while on the C++ page:

    Projects
     - ASP
     - C++
       - defs.h
       - program.c
     - .NET
     - Python

    It shows this:

    C++
     - defs.h
     - program.c

    http://wordpress.org/extend/plugins/wp-dtree-30/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Here’s a quick fix to allow this functionality. I’ll update this when I get around to adding a new checkbox option to the widget config.

    In wp-dtree-pge.php on line 6. Change

    'child_of' => $child_of,

    to

    child_of' => get_the_ID(),

    Here’s the code that adds a check-box to the widget config and allows the current page to be shown as the parent node. I double-checked this against a new install so there shouldn’t be any errors. If you have questions feel free to contact me at drodgersmobile -at- gmail dot com.

    // wp-dtree-widget.php (INSERT BEFORE LINE 42)

    $settings['activepage_parent'] = isset($new_settings['activepage_parent'])? 1 : 0; // drodgersmobile@gmail.com (active page as parent)

    // wp-dtree-widget.php (INSERT BEFORE LINE 94)
    // Add checkbox below highlight/opento checkboxes

    // wp-dtree-pge-widget.php (INSERT BEFORE LINE 54)
    // Add checkbox near child/direct parent dropdown menus

    <!--
    // Checkbox that makes active page the parent node of the tree
    -->
    <input class="checkbox" type="checkbox" <?php checked($settings['activepage_parent'], true); ?> id="<?php echo $this->get_field_id('activepage_parent'); ?>" name="<?php echo $this->get_field_name('activepage_parent'); ?>" />
    <label for="<?php echo $this->get_field_id('activepage_parent'); ?>" title="Active page becomes the parent node of the tree."><?php _e('Active Page As Parent', 'wpdtree'); ?></label>
    </p><p>
    <!-- -->

    // wp-dtree.php (INSERT BEFORE LINE 259)

    if($args['activepage_parent'] != 0)
    {
    	$args['child_of'] = get_the_ID();
    	$nodelist = wpdt_get_pages_nodelist($args);
    	$tree = wpdt_build_tree($nodelist, $args);
    }

    Plugin Author ulfben

    (@ulfben)

    Thanks. I’ll have a look at it for next release.

    Sure. Glad to help out.

    I’m sure the code can be improved. I improvised it, but it works well so far. I haven’t found any issues regarding tree function being adversely affected. It might be nice to also have a field where specific ids can be entered for this functionality in case you don’t need it on every page.

    Plugin Author ulfben

    (@ulfben)

    I took a stab at it and added something to trunk. Please download the development version here and try it out.

    I added “child of current view” to category-, pages- and taxonomy trees.

    One question on the use case though; the tree will be empty if there’s no child pages / categories. Don’t you find it super annoying to have the navigation dissapear when users visit leaf nodes?

    I’ll take a look at it and get back to you.

    I see what you’re talking about. I would add a dropdown selection for the default parent to show when there are no child nodes for a given page/cat/tax. That should take care of the blank nav menu. Beyond that there are other wordpress plugins users could employ to remove the widget entirely from pages they did not want it on.

    I would also redesign options that limited the plugin such as the “only direct children” and “show no children” options. Instead, I’d make those fields where IDs could be entered. This would make the plugin more dynamic by being able to control it on multiple pages rather than a site-wide static option.

    This is a great plugin, and you’ve done some wonderful work to it. I see no reason for it not to continue to evolve and become more awesome. It has so many uses!

    Plugin Author ulfben

    (@ulfben)

    I would also redesign options that limited the plugin such as the “only direct children” and “show no children” options. Instead, I’d make those fields where IDs could be entered.

    Yeah. Since I don’t use most of these trees or settings myself, I just expose all parameters the default WordPress functions do without any idea of what is really useful and what is just enabling end users to shoot their feet off. 🙂

    Ergo. I’m grateful for any reasoned suggestions on how to improve and clarify the settings panel of these widgets.

    I’ve noted your suggestions.

    Another idea I had for this project would be to have the ability to designate a top-level parent for a given set of nodes.

    So for instance if you had the tree below

    - Gaming
      - Doom
        - Levels
          - 1
      - Quake
        - Levels
          - 1
      - Unreal

    Once you selected “Doom” you’d get the following:

    - Levels
         - 1

    Instead, by being able to designate a top level parent, or having the tree keep the top level parent you’d end up with.

    - Doom
       - Levels
         - 1

    This would also address the issue of having no nav bar on pages with no children. It would just show the page you were on with no nodes below.

    - Gaming
      - Unreal

    Did you ever clean up the plugin? The development version has a few bugs. It doesn’t correctly limit the “active node” of the tree on any of the widgets except for pages. I’ve tested it with both categories and taxonomy. I did not test links, but I know the other two do not work.

    Plugin Author ulfben

    (@ulfben)

    The development log is available from the plugin description page.

    http://plugins.trac.wordpress.org/log/wp-dtree-30/

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: WP-dTree] Open only node being browsed?’ is closed to new replies.