wizzud
Forum Replies Created
-
Forum: Plugins
In reply to: [Custom Menu Wizard Widget] Dropdown Outputadd_filter( 'wp_nav_menu', 'my_cmw_nav_menu_as_dropdown', 10, 2 ); function my_cmw_nav_menu_as_dropdown( $nav_menu, $args ){ if( !empty( $args->_custom_menu_wizard ) && $args->_custom_menu_wizard['flat_output'] ){ $nav_menu = preg_replace_callback( array( '/<li[^>]*>(.*?)<\/li>/', '/<ul([^>]*)>/', '/<\/ul>/' ), 'my_cmw_nav_menu_as_dropdown_callback', str_replace( '</ul>', '</select>', $nav_menu ) ); $title = ''; //determine which title to use... foreach( array('current', 'current_root', 'branch', 'branch_root') as $v){ if( $args->_custom_menu_wizard[ 'title_from_' . $v ] && !empty( $args->_custom_menu_wizard['_walker'][ $v . '_title' ] ) ){ $title = $args->_custom_menu_wizard['_walker'][ $v . '_title' ]; break; } } //put title into first option... $nav_menu = sprintf( $nav_menu, $title ); } return $nav_menu; } function my_cmw_nav_menu_as_dropdown_callback( $matches ){ $firstChars = substr( $matches[0], 0, 2 ); $rtn = $matches[0]; if( $firstChars == '<l' ){ if( preg_match( '/href="([^"]+)"[^>]*>([^<]+)</', $matches[1], $m ) > 0 ){ $rtn = '<option data-href="' . $m[1] . '">' . $m[2] . '</option>'; }else{ $rtn = '<option>' . $matches[1] . '</option>'; } }elseif( $firstChars == '<u' ){ if( preg_match( '/id="(.*?)"/', $matches[1], $m ) > 0 ){ $rtn = '<select name="' . $m[1] . '"' . $matches[1]; }else{ $rtn = '<select' . $matches[1]; } $rtn .= ' onchange="window.location.href=jQuery(this).find(\'option:selected\').data().href;"><option value="" selected="selected">%$1s</option>'; } return $rtn; }This version replaces the previous “Select a Category” text with the widget title (as determined by the CMW widget settings). I am still unclear as to whether this is actually what you want, but it is based on :
…don’t want “Select a Category” text in box…
Since “Select a Category” was the text in the first OPTION of the SELECT, then “box” must mean the SELECT element…
Dropdown output will be..
I can only assume that “dropdown” means the SELECT element again.
Shop Business & Finance (to be title in the box)
Since “box” previously referred to the SELECT element, then this must mean that – in this particular instance – “Shop & Business Finance” replaces “Select a Category”, ie. put the widget title (as determined by CMW) into the first OPTION of the SELECT.
However, this now refers to “title” … but there is no concept of a visible title as such in a SELECT element, so …. hmmm…need the Level 1 to be title in the dropdown box…
Ok, the “Level 1” bit is determined by the CMW settings, but now we have “title in the dropdown box”, which (again) brings in the “title” – that I don’t quite get – and a double reference to the SELECT element.
So, unless I’ve totally misunderstood (which is a distinct possibility!) you want a SELECT element with the widget title (as determined by CMW) as the first OPTION … that’s what I’ve provided.
On the other hand, “box” might be the SELECT’s container … in some cases?
And “dropdown” might not be the SELECT … in some cases?
And “title” might mean … ?Forum: Plugins
In reply to: [Custom Menu Wizard Widget] Dropdown OutputIf you don’t want “Select a Category”, just replace it with whatever you do want (or a non-breaking space).
[“Select a Category” should really be
<?php __("Select a Category"); ?>]If you don’t want to restrict it to Flat output instances, then remove
&& $args->_custom_menu_wizard['flat_output']However, unless you plan on adding some very fancy indents into your OPTIONs – to indicate levels – then I see no advantage in setting the instance to Hierarchical output.
EDIT: Also, making it Hierarchical would actually break the code because there would be multiple, nested UL elements!As for styling, that’s down to your theme. You can add whatever id or classes you like to the container, and then use them to style how you see fit. CMW does not provide any styling.
Forum: Plugins
In reply to: [Custom Menu Wizard Widget] Dropdown Outputadd_filter( 'wp_nav_menu', 'my_cmw_nav_menu_as_dropdown', 10, 2 ); function my_cmw_nav_menu_as_dropdown( $nav_menu, $args ){ if( !empty( $args->_custom_menu_wizard ) && $args->_custom_menu_wizard['flat_output'] ){ $nav_menu = preg_replace_callback( array( '/<li[^>]*>(.*?)<\/li>/', '/<ul([^>]*)>/', '/<\/ul>/' ), 'my_cmw_nav_menu_as_dropdown_callback', str_replace( '</ul>', '</select>', $nav_menu ) ); } return $nav_menu; } function my_cmw_nav_menu_as_dropdown_callback( $matches ){ $firstChars = substr( $matches[0], 0, 2 ); $rtn = $matches[0]; if( $firstChars == '<l' ){ if( preg_match( '/href="([^"]+)"[^>]*>([^<]+)</', $matches[1], $m ) > 0 ){ $rtn = '<option data-href="' . $m[1] . '">' . $m[2] . '</option>'; }else{ $rtn = '<option>' . $matches[1] . '</option>'; } }elseif( $firstChars == '<u' ){ if( preg_match( '/id="(.*?)"/', $matches[1], $m ) > 0 ){ $rtn = '<select name="' . $m[1] . '"' . $matches[1]; }else{ $rtn = '<select' . $matches[1]; } $rtn .= ' onchange="window.location.href=jQuery(this).find(\'option:selected\').data().href;"><option value="">Select a Category...</option>'; } return $rtn; }Forum: Plugins
In reply to: [Custom Menu Wizard Widget] Dropdown OutputI suspect not. CMW handles Custom Menus … not Categories.
Sorry.Forum: Plugins
In reply to: [Custom Menu Wizard Widget] Dropdown OutputThe code sample only runs if CMW has produced the output (the first if statement within the filter function). It is also conditional upon CMW having been asked to produce flat output, but you can change that, or add other conditions as you wish.
If you need to restrict it to running against certain instance(s) of CMW then one way would be to give those instances a unique class (or maybe give a single instance a unique id?) and, as part of that first if statement, also run a strpos() check for the string you have chosen.
Of course, if none of your “other” CMW instances produce flat output then you don’t need any other checks, but that is something only you can make a judgment on.Forum: Reviews
In reply to: [Custom Menu Wizard Widget] The Best Menu CustomizerThank you for the Review.
If you still require a collapsible/expandable menu you might like to read this thread on the Support Forum (assuming you haven’t already, in which case I apoligise for being obvious). It explains why I don’t provide the capability as part of the plugin, and it also gives some sample (note the emphasis!) script should you want to try adding it for yourself.
Good.
Right, now to try and explain why your original settings didn’t do what you expected.
This is going to seem long-winded, for which I apologise, but you went to a lot of trouble to explain your problem to me, so it seemed only fair to try and reciprocate.
Bearing in mind that:
1. the settings are (roughly) progressive
2. current branch is defined as the current item, its ancestors and its descendants.Branch = Current Item : definitely
Starting at = 2 : you don’t want the root level items; ok (ish)At this point, for any current item, you get output that consists of everything that is at or below the level-2 (ref the
Start atsetting) item(s) within the current branch, eg- for a level-1 current item you get all that item’s descendants (but not that item itself)
- for a level-2 item you get that item plus its descendants
- for any other level you get the level-2 item that is the current item’s ancestor, plus all descendants of that level-2 ancestor
Depth = 2 : limits the number of levels output to a maximum of 2 (excluding any later Inclusions)
Since we’re starting at level-2 this effectively says “don’t output anything at level-4 or below”. Alternatively, “only output anything we currently have that’s at level 2 or level 3 (ie. a depth of 2 levels).
However, with a menu that only has 3 levels (as you have), this has no effect whenStart atis set to 2.
It’s important to note here that depth includes whatever level it is starting at, so if you start with level-X and ask for a depth of 1, you get level-X; if you ask for a depth of 3 then you (might) get levels X, X+1 and X+2. (If this seems illogical then consider what you should expect if you were allowed to ask for a depth of zero, starting with level-X? To me, a depth of zero means no output.)(Depth) Relative to Current Item = On : this is the problematic one!
Ordinarily,
Depthstarts at theStart atlevel. Adepth=1setting would output just items at theStart atlevel; fordepth=2you would get any items at theStart atlevel, plus any items at theStart atlevel + 1. MakingDepthrelative to current item merely alters the level at whichDepthstarts, from theStart atlevel to the level at which the current item can be found. However…The expectation here was that CMW will recalculate
Depthrelative to the current item regardless of where that current item is … and this is not the case. If the current item has already been excluded from the output because of some other setting – in this case, theStart atvalue – then it does not get used to help determineDepth.This is because
Depth– with or withoutRelative to Current Itembeing set – still has to abide by theStart atfilter. Since theRelative to Current Itemsetting is actually part (a modifier if you like) of theDepthsetting, the “Current Item” part also has to abide by theStart atfilter, so if current item is outside theStart atvalue (ie. higher up the structure) it cannot be used to determine depth.If I were to allow depth to be calculated relative to the current item regardless of where current item was in the structure, it would allow the
Start atsetting to be invalidated (or become unenforceable), eg.Using
[cmwizard ... start_at="4" depth=1 depth_rel_current=1]when current item is a level-1 item would output just the level-1 item, which breaks thestart_at="4"setting. Since this is part of the Filter process, not the Inclusions, it’s not acceptable … so I don’t allow it!That’s it, and hope it made some sort of sense. The rest of the settings are inconsequential to your problem.
I’m glad you could use CMW to get what you needed. I think that the only place you got slightly stuck was that you didn’t consider the possibility of treating the need to not show the level-1 items as an exception, rather than part of the norm.
First things first…
Before investigating why your settings aren’t doing what you expect, let’s see if we can get CMW to produce what (I think!) you need. Does this produce the menu you’re after?…[cmwizard menu=3 branch=current depth=2 ancestors=2 ancestor_siblings=2 exclude_level="1" siblings=1 container_id="nav_menu-3"]No problem.
Oops, sorry, crossover of postings.
Check your CSS and see what is keeping the sub-menus that aren’t on the current path, invisible.The “problem footer” html you sent me has 5 top level items, of which only Home and About Us do not have sub-menu items. Of the sub-items, the second (of 3) sub-item – “Treatments” – below “Patient Information” is shown as being “current”.
In other words, your menu structure (in the HTML!) is:
Home About Us Patient Information - Eye Conditions - Treatments (marked current) - FAQs GP's & Optometrists Information - Information brochures - Request a seminar for your practice Contact Us - Hamilton - Thames - Matamata - Te Awamutu - Morrinsville - Huntly - CambridgeIf that is the full extent of your “Footer Menu” custom menu then I don’t see the problem : all options are there even though the current page is Treatments.
Also, the menu is not being filtered by CMW. If CMW was filtering, it would do exactly that : filter. Ie. there would not be a full menu. And there would be extra classes set by CMW. I’nm afraid this is all down to your Custom Menu widget and CSS, not CMW.
One quick test : if you deactivate CMW, does the footer menu still show the same information as it does with CMW active?
And a question : besides CMW, what other plugins do you have installed that are to do with custom menus?
Can you email me (rb[at]wizzud.com) a couple of screenshots? : the footer sidebar widgets (in the backend Widgets admin), and a Firebug(?) HTML – or a View Source dump? – of the both the offending front end footer widget code (at least the start of it) and the ok front end CMW widget.
And what WP version are you using? Latest (3.9.1)?
Do you have a web-accessible site I can look at?
Forum: Plugins
In reply to: [Custom Menu Wizard Widget] Part of our site now not workingWhile I can’t say that I’ve checked every single page, I have looked at a number of them and I can’t find any instance of the Custom Menu Wizard plugin … which naturally leads me to wonder whether it is actually being used. If it’s not, then I would suggest you remove it … just a matter of good housekeeping (aka de-cluttering). If you don’t know whether or not it is being used, take a look at all the widgets in any sidebars you may have set up – in Appearance > Widgets – and see if there is a Custom Menu Wizard instance there. You can also check posts/pages for use of the CMW shortcode by using CMW’s “assist” (you can create a temporary instance in the Inactive Widgets area, if you don’t have an instance already in a sidebar) – open the “assist” and click the button at the bottom right.
No, CMW does not manage price fields, prices, product attributes, etc … and I would be interested to know which part of the plugin’s description gives the impression that it might?
From a cursory glance through page source, your “shop” appears to be a custom built job, implemented directly in the theme rather than via a plugin. If your theme doesn’t supply the tools to manage it via the backend then you might have to look at the theme’s files.
Basically, I don’t envy you trying to work out what’s going on; but I think I can say, with some confidence, that whatever problems you have with your shop products, CMW has nothing to do it. Sorry.