Add extra fields for each menu item - wordpress

I am making a theme. There I want to add extra fields for each menu items ( Appearance > Menus and i.e). In the picture below I want to add some extra form fields ( like radio button, textarea and etc. ) under the field "Description":
Is there any way or tutorial about how can I do this?

I was looking for the same thing.
I found these, all of which work differently.
https://gist.github.com/kucrut/3804376
simple to use and straightforward if you plan to build an elaborate class
(note: with mods this could be used for checkboxes, radio, color pickers, ect)
https://wordpress.org/plugins/sweet-custom-menu/
This worked well, very simple, adds a txt field.
(note: it overrides the whole wordpress_walker class)
http://www.johnmorrisonline.com/how-to-add-a-fully-functional-custom-meta-box-to-wordpress-navigation-menus/
This is very different, it adds an entire mettabox type to the admin menu panel on the LEFT. I elected to use this as I was building my own version of a "mega menu" and wanted to add widgets. With enough work on this item and the one above anything is possible.
Good luck!

It all depends on what you want an extra field for, but sometimes this kind of problem can be resolved by looking at an alternative approach: Add in a shortcode in your menu, giving you the programmatic flexibility to customise your menu item output beyond what is offered by WP.

Related

Relationship based Taxonomies Dropdown

Please help.
I am very new to web development & don't have any computers background. I have created a pincodes database Website pincodes.forinfo.in using WordPress. I want a relationship based dropdown Taxonomies like www.pincode.city.
I have tried many ways from last 6 months but failed. Please help me.
I have custom Taxonomies State, District, City, pincode. I need a taxonomy dropdown, when user clicked on state the second dropdown should show the Districts of that particular state. Like wise when a user clicked on District the third dropdown should show the cities of the particular.
How can it is possible. Please help me.
I want show this dropdown on a WordPress page.
If you are using the latest version of Wordpress then I do not see the reason to be baffled by this, since you will be able to manage this from Appearance->Menu.
Check out my screenshots.
Click on the Screen Options button on the top right corner of the
Menu page. Screen Options
For me, Types is a custom Taxonomy, so I select it. The taxonomies appear on the left now Custom Tax Appears
You can now add the links to your menu and then arrange it so that it becomes a sub-menu of your primary menu.
This is how your menu should look if you want your custom taxonomy to be a sub-item of another menu item.
Sub menu items
You can do this by holding and dragging the item slightly to the right.
You can stack such items one below the other and create endless sub-menus.
I must mention that there are some themes that do not support sub-menus. If you theme doesn't, change it and check again.
Things that you need to do to implement your idea:
Get a good autocomplete plugin - Easyautocomplete (Much better than jQuery UI autocomplete)
Create three input boxes on a custom template page
Use enqueue_script to get your JS files to load with your Wordpress installation
Bind autocomplete to the three input text boxes
Learn how to query your Wordpress installation for your taxonomies
Use a php file to transfer a json file of your taxonomies to the autocomplete function - I would recommend this AJAX plugin
Have conditions in your php file according to which the 2nd field's values are fetched after getting the value of the first field and similarly for the third field
As I said, it's a lot of coding, and if you are really starting out to code this yourself, without much knowledge of PHP or jQuery, it's going to be very difficult. I would suggest you take the help of a developer.
You can even send me the details of logging into your Wordpress installation, if you want me to take a look.
Mail me at arunadaybasu#gmail.com

Select view filter using checkboxes on Drupal

I have created 3 content types, and I want to show them in a single view. In that view, I tried to add 3 checkboxes. When the first checkbox is checked, the view will show the first content type. If the second is checked, it will show the second content type, etc.
I'm searching in google and forums but i don't find anything.
Could someone help me?
Thank you so much.
ps: sorry for my bad English.
Practically, taxonomies work well with exposed filters. In your case it seems a bit overkill but I'm pretty sure that you would get the intended results.
Check the better_exposed_filters which should give you better display options, actually, you may want radio buttons, instead of checkboxes :)
As Vadim Eremeev recommends, enable Ajax so that simply selecting a button would display the relevant content.
Now, if you use taxonomies, you may not need three different Content types, but that's another issue!

Show remaining wordpress categories in drop down menu

I have limited space for horizontal category navigation bar on top of my theme and I need to limit number of categories shown on this bar and tell WordPress put "More.." as a drop down menu link at the end of the list to let users hover their mouse cursors on that to see other categories as shown in screenshot.
How can I do that?
Depends on what function you're using to format the navigation menu. It's probably wp_list_categories() which might not be the best choice in your case. As #Andre mentioned in his answer, you might want to go with navigation menus available since WordPress 3, but if you need to stick to categories, try get_categories() which will return the categories in a non-formatted way. This will enable you to loop through them in any way that you want, include a counter to limit the general output, and then loop through the rest under the More submenu.
Reference: get_categories
I guess you are using wordpress version 3+.
This is probably not the cleanest way but should work:
Register a custom menu to your template. Watch the 'depth' parameter (because you want the second level)
Go to 'Appearance - Menus'
Create a Custom Menu
Create a 'Custom Link' called 'More...'
add the 'More...' Link with the other categories as sub-categories to the menu.
write your CSS code to only display the second level on hover.
However, I'm not sure if you want the 'More..' menu item to be a linkpage/category. All of that is possible, just add the category/page instead of the 'Custom Link'.
Hope this workaround can solve your problem.

Fb like share box in drupal website

I am making a drupal website and have a content type "quotation". The standard way of taking input in drupal is going to the create content in the menu which is not very user friendly considering your normal user.
I want to have an option to create content (i.e quotation) like in facebook, twitter or any other social networking site. A share box where someone can type in his status and can directly create content.
Also, I have two vocabularies associated with my content type and I want to accommodate them as well while using minimum space. So, how should I go about the problem.
Is there any module in Drupal which can help me in doing so or I have to write Jquery code myself.
two vocabularies associated with my
content type and I want to accommodate
them as well while using minimum
space.
Lol, sounds tough. If you want to use minimal space you'll need to simplify the workflow, ie, remove a vocabulary or 2.
You can also do something like this:
$('#node-edit').focus(function (){
// set your node form vocab to display:none and then show them when user actually uses the form
$('.vocab-wrappers').show();
// set your node form buttons to display:none and then show them when user actually uses the form
$('#node-form buttons').show();
});
To hide the vocabularies/buttons until the user is editing the content.
To get a facebook like effect, I suggest you use: http://drupal.org/project/formblock
This should get you the form and the ability to place it anywhere.
You can use form alter to hide certain parts of the form, or a form alter module, there's various options if you look in drupal modules.
http://drupal.org/project/nodeformcols
You also want http://drupal.org/project/auto_nodetitle to make the title optional, and hidden from the form.
Lastly, theme the node form in CSS/JS, making the texarea smaller and whatever other stuff you would like, recommend setting display:none on the field labels.
This should give you the correct idea for making a decent facebook-like form setup.
This should be possible:
http://drupal.org/node/464906
I've never tried it myself though.

Drupal: Content in blocks from node_reference fields?

After only a few weeks of working with Drupal I've come up with a recurring problem, which I don't really have an optimal solution to, so I'm hoping that someone here might be able to give some best practice pointers.
What I have is a region inside my node.tpl.php, which is populated with blocks that display content from two different CCK fields of the type node_reference. This works fine when displaying a single node. The problem appears when I need to use a view.
For example, lets say I have a news listing, and a single news item view. When I display the single news item I can use the news node node_reference field to reference whatever material I would like to have in my sidebar, but when on the news listing view I would like to reference nodes separately. What would be the best practice to solve this?
I'm having a few ideas, but none seem like the logical choice, how would you do?
My understanding of your problem is that you don't want the blocks to display on the view page and you want the block information displayed inline with the node.
The first part is easy, you can modify the block visibility settings to not show up on the path where you have the view.
The second part will depend on how you set up your view. If you are using fields you can simply add fields for the node_reference and they should display. If you are using a node view, you will have to override the template and create a template which displays the node reference field.
If you want further explanation please comment and I can clarify
After reading my question I realize that it was explained pretty badly, so I'll try again, and also tell how I solved it.
The Problem
On normal "pages" (when displaying only a single node), I have a sidebar that shows something similar to banners, which are either random, or I can select one or many that should always be displayed on the sidebar. This is solved easily when displaying a single node, using a CCK node_reference field. The problem is when using a View that displays multiple nodes, for example a news listing-
The Solution
In my case I could solve this by creating additional fields on my default Page content-type. These fields were called view, display and arguments. In my tpl.php I then embedded the news listing view inside a page, lets call it News. This way I gained great flexibility, and also helps the News page to know where it is located in menu structure.
Final comments
I have yet to discover if there are any drawbacks or dangers in doing this way, but if there are, feel free to share them with me :)
I tend to want to create my own modules, which create blocks and reference the database directly. Then I put the blocks inside of panels, this seems to be more flexible for me than using views and cck fields etc ...

Resources