September 08th
A simple solution how to add a description field to your node/add forms.
We are building a website that has landing pages. Structure could be like:
The site structure is based on a menu, thus each page has its menu and most importantly parent menu item if it is not landing page. When visitor is viewing a landing page, the page consists of a text from landing page node and a list of first level sub-menu items with its description (views can't do this afaik).
Here is the landing page layout:

The only problem is, that in node/add form menu fieldset doesn't have description field. So user adding or editing a new content has to after content creation visit menu administration, select the menu item and edit description. Not a good workflow eh? :)
So first we need to use form_alter to add a description field to a menu fieldset:
<?php
/**
* Implementation of hook_form_alter(). Adds menu item fields to the node form.
*/
function mymodule_form_alter(&$form, $form_state, $form_id) {
if (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id) {
$form['menu']['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#default_value' => isset($form['menu']['options']['#value']['attributes']['title']) ? $form['menu']['options']['#value']['attributes']['title'] : '',
'#rows' => 1,
'#description' => t('The description displayed when hovering over a menu item.'),
);
$form['#submit'][] = 'mymodule_node_form_submit';
}
}
?>then, as you can see in the code above, we have our own form submit callback. Let's add that too:
<?php
function mymodule_node_form_submit($form, &$form_state) {
$form_state['values']['menu']['customized'] = TRUE;
$form_state['values']['menu']['options']['attributes']['title'] = $form_state['values']['menu']['description'];
}
?>And that's it. Now in node/add form we have in menu fieldset a description field too. :)
Delicious
TechnoratiI can't quite understand how those aren't just teasers.
as written in the post, the site structure is defined by menu system. so what we want to get below each landing page is a sub-level items based on parent menu.
in case of teasers, we will need to:
(custom code)
get the menu structure
get the nodes and output teasers
with just menus and using description field:
(custom code)
get the menu structure
most importantly we wanted to keep that menu item description there, in case ppl hover over it in the menu
and one more thing, teasers and menu description unfortunately arent same in our case, teaser is being used somewhere else
forgot the main issue, the sub pages doesn't have to be nodes! so it could be views for example.
Yep, this is confusing me :/
Had this exact need on a site using UTF-8 multilingual strings for menu titles, but English translation for the tooltip (menu description field). By default, Drupal was nulling the descriptions set in the menu admin when a node was saved. Not nice.
Thanks again for allowing me to copy-paste instead of trying to find all the form keys!
help with drupal is gr6...thanks..eep postign and helping others...
I think you should definitely have landing pages on your websites. This really explains what you are all about.
palm beach cosmetic dentist
Hello, possibly you could assist me? I see u are using drupal on your web site. I recently decided to create a blog for myself and i am presently using one of the free blog website services that are in my country, but i would really like to make my own blog using my private site name. I did recently read about blog engine and i was thinking maybe you might know where i may be able to find good training or videos on how to make use of drupal properly? Thanks!
The problem of comment quality — and you have increased blog traffic and interaction as well. You also draw more attention to your reviews, because people would naturally want to read about what they can win. Good stuff. This will for sure increase your visitors to your blog!
meilleur site de roulette
Custom imprinted promotional computer bags, Promotional Tote Bags, promotional backpacks; messenger bags also make great promotional giveaways. Hand them out promotional bags to select prospective clients or raffle them off at your next computer expo or career fair. Visitors can use handy promotional tote bags containing your imprinted company logo embroidered to carry their Promotional Products,Promotional knives
Very funny article writing about who we are and for what we are about.
golf tee times
discount tee times
online tee times
UK Essays right here and there.