Extra option for the plugin?

Forums Forums Menus Extra option for the plugin?

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #551
    vcsvu
    Member

    We use the multi-level menu for our site http://www.vcsvu.nl

    When installing the plugin we encountered a problem, for which we have made a solution. The problem was that we had a lot of pages, which where a children of a certain parent, and should not be shown in the menu.

    We used the following code in the index.php for excluding the children out of the menu:

    [code:3b6bnx8y]
    //CUSTOM EDITING BY MARTIN HELLENDOORN FOR THE VCSVU SITE
    function pages() {
    $args = array(
    ‘post_type’ => ‘page’,

    ‘post_parent’ => get_option(‘suckerfish_excludepages’), // any parent
    );

    $exclude .= get_option(‘suckerfish_excludepages’).’,’;

    if(get_option(‘suckerfish_excludepages’) != ”){
    $attachments = get_children($args);
    }

    if ($attachments) {
    foreach ($attachments as $post) {
    $exclude .= $post->ID.’,’;

    }
    }

    wp_list_pages(‘title_li=&exclude=’. $exclude);}
    //////////////////////////////////////////////////
    [/code:3b6bnx8y]

    Can this (excluding children pages) option also be build in the next version of the plugin? Because we now have to adjust the plugin after each update.

    #4765

    Hi,
    If I can figure out what it does then sure, that is probably addable to the next release.

    I’m a little confused, what exactly does it do?

    #4766
    vcsvu
    Member

    Sorry, the coding was a bit mmessy. I cleaned it up and made some comment.

    [code:ar7wthcn]
    //CUSTOM EDITING BY MARTIN HELLENDOORN FOR THE VCSVU SITE
    function pages()
    {
    //Get the exclude pages from the advances options of the multi-level plugin
    $args = array(
    ‘post_type’ => ‘page’,
    ‘post_parent’ => get_option(‘suckerfish_excludepages’), );
    $exclude .= get_option(‘suckerfish_excludepages’).’,’;

    //Get children of excluded pages
    if(get_option(‘suckerfish_excludepages’) != ”)
    {
    $attachments = get_children($args);
    }

    //Add all the children pages to the exclude variable
    if ($attachments)
    {
    foreach ($attachments as $post)
    {
    $exclude .= $post->ID.’,’;
    }
    }

    //exclude the pages
    wp_list_pages(‘title_li=&exclude=’. $exclude);
    }
    //////////////////////////////////////////////////
    [/code:ar7wthcn]

    This function is now always on. Maybe when you put it in the plugin, a checkbox can be used to exclude the children pages or not.

    #4767

    I had no idea what it was you were trying to achieve here because I thought the plugin already did that. I never realised the child pages were shown even when their parent was excluded.

    Thanks for the code improvement <img decoding=” title=”Smiley” /> I’ll get to work on this ASAP and have it implemented into a new version shortly.

    I’ll be adding a credit link in the WP plugins repository for you, should I add the following URL http://www.vcsvu.nl/? And should I add the credit to the name vcsvu? Or perhaps your real name or company name?

    #4768

    It works! I have it running in a test install now.

    Do you know how to make it exclude the grand children as well? It seems to be only excluding the children at the moment and I think it will confuse some users who have heavily nested menus if it doesn’t exclude everything for them.

    #4769

    And getting it to work with categories would be good too <img decoding=” title=”Smiley” />

    #4770

    Attached is a preliminary plugin which incorporates this feature. I haven’t included anything in the admin panel yet. But if you just want a ‘pages only’ menu, then you can use the following to display them and have them ignore the children pages:

    Regular ‘pages only’ menu:
    [code:1q6puneo]<ul id="suckerfishnav">
    <?php pages_excludechildren(); ?>
    </ul>[/code:1q6puneo]

    All pages in a single dropdown menu:
    [code:1q6puneo]<ul id="suckerfishnav">
    <?php pagesdropdown_excludechildren(); ?>
    </ul>[/code:1q6puneo]

    #4771
    vcsvu
    Member

    I do not really understand what you mean with the code examples. Are pages_excludechildren() and pagesdropdown_excludechildren() new functions you made in the future plugin update?

    The grandchildren are gotten by making a foreach loop with all the children, to get there children ect. ect. But maybe there is also a function in wordpress it self to get this. In our case however, we only want to exclude the children of a certain page and not all parent pages. I will try to come with a solution today.

    Credits may go to Martin Hellendoorn (myself <img decoding=” title=”Smiley” />) and my company website is http://www.meubelproducten.nl.

    #4772

    Yes, those are new functions I made within the plugin.

    #4773
    vcsvu
    Member

    Mmm, I see that I forgot to update to the recent version of the multi-level menu plugin. So now I have no idea how to implement your solution. Can you explain where the function exactly has to go?

    #4774
    vcsvu
    Member

    Ok, I had some time yesterday and made the code for the extra option in the admin menu en implemented the function in the core.php file.

    The following function must be placed in the core.php file:
    [code:256tda5v]
    /* NEW FUNCTION FOR EXLCUDING PAGES AND CHILDREN  —>MARTIN HELLENDOORN */
    function excludepages()
    {
    //Get the exclude pages from the advances options of the multi-level plugin
    $args = array(
    ‘post_type’ => ‘page’,
    ‘post_parent’ => get_option(‘suckerfish_excludepages’), );
    $exclude .= get_option(‘suckerfish_excludepages’).’,’;

    //Get children of excluded pages
    if($args != ” && get_option(‘suckerfish_2_excludechildren’) == ‘on’)
    {
    $attachments = get_children($args);
    }

    //Add all the children pages to the exclude variable
    if ($attachments)
    {
    foreach ($attachments as $post)
    {
    $exclude .= $post->ID.’,’;
    }
    }

    return $exclude;
    }
    [/code:256tda5v]

    And adjust the following line of core.php
    [code:256tda5v]
    function pages() {echo ”, ereg_replace(""><a [/?a-zA-Z0-9-.:"=_ >]+</a>([tn]+)<ul"," haschildren\0",wp_list_pages(‘title_li=&exclude=’. get_option(‘suckerfish_excludepages’) .’&echo=0′)) , ”;}
    [/code:256tda5v]
    into
    [code:256tda5v]
    function pages() {echo ”, ereg_replace(""><a [/?a-zA-Z0-9-.:"=_ >]+</a>([tn]+)<ul"," haschildren\0",wp_list_pages(‘title_li=&exclude=’. excludepages() .’&echo=0’)) , ”;}
    [/code:256tda5v]

    In admin_page.php add the following code:
    [code:256tda5v]
    <!– EXTRA OPTION FOR EXCLUDING CHILDREN —- MARTIN HELLENDOORN–>

    <div class="includeexclude">
    <label>Exlude children of excluded pages</label>
    <input type="checkbox" name="suckerfish_2_excludechildren" <?php if(get_option(‘suckerfish_2_excludechildren’) == ‘on’){echo ‘CHECKED’;} ?> />
    </div>

    <!– END EXTRA OPTION –>
    [/code:256tda5v]

    after the following part:

    [code:256tda5v]
    <div class="includeexclude">
    <p>
    <label>Categories to include or exclude</label>
    <input type="text" name="suckerfish_excludecategories" value="<?php echo get_option(‘suckerfish_excludecategories’); ?>" />
    </p>
    <select name="suckerfish_includeexcludecategories">
    <?php
    $suckerfish_includeexcludecategories = get_option(‘suckerfish_includeexcludecategories’);
    switch ($suckerfish_includeexcludecategories){
    case "include":echo ‘<option>include</option><option>Exclude</option>’;break;
    case "Exclude":echo ‘<option>Exclude</option><option>include</option>’;break;
    case "":echo ‘<option>include</option><option>Exclude</option>’;break;
    }
    ?>
    </select>
    </div>
    [/code:256tda5v]

    And the last adjustment is replacing
    [code:256tda5v]
    <input type="hidden" name="page_options" value="suckerfish_css, suckerfish_superfish, suckerfish_superfish_speed, suckerfish_superfish_time, suckerfish_superfish_timeout, suckerfish_menuitem1, suckerfish_menuitem2, suckerfish_menuitem3, suckerfish_menuitem4, suckerfish_menuitem5, suckerfish_menuitem6, suckerfish_menuitem7, suckerfish_menuitem8, suckerfish_menuitem9, suckerfish_menuitem10, suckerfish_pagestitle, suckerfish_keyboard, suckerfish_excludepages, suckerfish_excludecategories, suckerfish_hometitle, suckerfish_pagestitle, suckerfish_categoriestitle, suckerfish_archivestitle, suckerfish_blogrolltitle, suckerfish_recentcommentstitle, suckerfish_disablecss, suckerfish_custommenu, suckerfish_custommenu2, suckerfish_inlinecss, suckerfish_includeexcludepages, suckerfish_2_css, suckerfish_2_menuitem1, suckerfish_2_menuitem2, suckerfish_2_menuitem3, suckerfish_2_menuitem4, suckerfish_2_menuitem5, suckerfish_2_menuitem6, suckerfish_2_menuitem7, suckerfish_2_menuitem8, suckerfish_2_menuitem9, suckerfish_2_menuitem10, suckerfish_2_pagestitle, suckerfish_2_excludepages,  suckerfish_2_excludecategories, suckerfish_2_hometitle, suckerfish_2_pagestitle, suckerfish_2_categoriestitle, suckerfish_2_archivestitle, suckerfish_2_blogrolltitle, suckerfish_2_recentcommentstitle, suckerfish_2_disablecss, suckerfish_2_custommenu, suckerfish_2_custommenu2, suckerfish_2_inlinecss, suckerfish_2_includeexcludepages, suckerfish_generator, suckerfish_delay, suckerfish_superfish_shadows, suckerfish_superfish_arrows, suckerfish_showdelay, suckerfish_displaycss, suckerfish_secondmenu, osort_order, suckerfish_superfish_delaymouseover, suckerfish_superfish_hoverintent, suckerfish_superfish_sensitivity, suckerfish_maintenance" />
    [/code:256tda5v]

    by the following line:

    [code:256tda5v]
    <input type="hidden" name="page_options" value="suckerfish_css, suckerfish_superfish, suckerfish_superfish_speed, suckerfish_superfish_time, suckerfish_superfish_timeout, suckerfish_menuitem1, suckerfish_menuitem2, suckerfish_menuitem3, suckerfish_menuitem4, suckerfish_menuitem5, suckerfish_menuitem6, suckerfish_menuitem7, suckerfish_menuitem8, suckerfish_menuitem9, suckerfish_menuitem10, suckerfish_pagestitle, suckerfish_keyboard, suckerfish_excludepages, suckerfish_excludecategories, suckerfish_hometitle, suckerfish_pagestitle, suckerfish_categoriestitle, suckerfish_archivestitle, suckerfish_blogrolltitle, suckerfish_recentcommentstitle, suckerfish_disablecss, suckerfish_custommenu, suckerfish_custommenu2, suckerfish_inlinecss, suckerfish_includeexcludepages, suckerfish_2_css, suckerfish_2_menuitem1, suckerfish_2_menuitem2, suckerfish_2_menuitem3, suckerfish_2_menuitem4, suckerfish_2_menuitem5, suckerfish_2_menuitem6, suckerfish_2_menuitem7, suckerfish_2_menuitem8, suckerfish_2_menuitem9, suckerfish_2_menuitem10, suckerfish_2_pagestitle, suckerfish_2_excludepages, suckerfish_2_excludechildren, suckerfish_2_excludecategories, suckerfish_2_hometitle, suckerfish_2_pagestitle, suckerfish_2_categoriestitle, suckerfish_2_archivestitle, suckerfish_2_blogrolltitle, suckerfish_2_recentcommentstitle, suckerfish_2_disablecss, suckerfish_2_custommenu, suckerfish_2_custommenu2, suckerfish_2_inlinecss, suckerfish_2_includeexcludepages, suckerfish_generator, suckerfish_delay, suckerfish_superfish_shadows, suckerfish_superfish_arrows, suckerfish_showdelay, suckerfish_displaycss, suckerfish_secondmenu, osort_order, suckerfish_superfish_delaymouseover, suckerfish_superfish_hoverintent, suckerfish_superfish_sensitivity, suckerfish_maintenance" />
    [/code:256tda5v]

    I hope you can add this in the following update of the plugin.

    The adjusted plugin (with adjusted core.php and admin_page.php) can be downloaded at http://www.vcsvu.nl/changed-plugin.rar

    #4775
    nv1962
    Member

    Maybe I’m too dense (probably that’s why I attended RUU and not the VU – hehe) but why don’t you use a plugin like pageMash and "hide" your unwanted menu items there? By "hiding" any page within that plugin you’re not really messing with their real appearance or visibility – you’re just keeping them from appearing in the menus. So, it doesn’t make pages "private" or anything like that.

    Bonus: you can move pages from anywhere in the hierarchy to anywhere else (even totally different branches, so not just moving to a different level within the same branch) with a single drag-and-drop action.

    Then again, I may have misunderstood the intent here.

    #4776
    vcsvu
    Member

    @nv1962: Thanks for the suggestion. I will also try the pageMash plugin. But if the extra option will be edited into this plugin, I will also be very happy.

    @edit: I tried pageMash, but it doesn’t work. Still all the children are shown in the menu.

    #4777
    nv1962
    Member

    That’s odd… Even after selecting "hide" within pageMash, which dims those pages? We’re talking about menu items consisting of pages, right? Well that’s strange – it really <i>should</i> hide pages (actually, just hide their corresponding menu item) no matter where in the tree structure they reside… Sorry: out of suggestions here, in that case!

    Edit: well almost… There’s a plugin which does nothing else but hiding pages (selectively, page by page) from navigation lists (i.e. menus) called, mysteriously, <a href="http://www.simonwheatley.co.uk/wordpress-plugins/exclude-pages/">Exclude Pages from Navigation</a> – if <i>that</i> doesn’t work either, there’s probably something magical/mystical going on with your menus (perhaps you should just worship it as it is…)

    #4778
    &quot;vcsvu&quot; wrote:
    … I have no idea how to implement your solution. Can you explain where the function exactly has to go?

    Unless I’ve inadvertently missed it out of the latest release, the function should already be in there. As before, you just need to use the excludechildren() function to get the pages, like this:

    [code:35j9gk2l]<ul id="suckerfishnav">
    <?php pages_excludechildren(); ?>
    </ul>[/code:35j9gk2l]

    I won’t be adding it in as a standard feature along side other options until I have it working with categories and getting rid of the grandchildren and great-grandchildren too.

    Any help with this would be greatly appreciated <img decoding=” title=”Smiley” /> Programming is not my area of expertise, so any help would be greatly appreciated.

Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.