problem: content type: news fields: - title (textbox) (machine name: title) - body (textarea) (machine name: body) - logo (file) (machine name: logo) - featured (checkbox) (machine name: featured_news)
i need show 1 featured news ordered changed date descending , other requirements.
how implement it? when checked featured field of 1 news checked other featured news should unchecked.
here steps followed:
- made module (newscheckbox)
- made functions
function newscheckbox_form_alter(&$form, $form_state, $form_id) { if($form_id == 'my_form_id_replace_with_underscore') { $form['#submit'][]='featured_news_update'; } } function featured_news_update(){ $nodeid=getfeaturednews(); if($nodeid){ nodesavenews($nodeid); } } function nodesavenews($nodeid){ $node = node_load($nodeid); // 1 node id want load $node->field_featured_news[$node->language][0]['value'] = '0'; node_save($node); }
somehow working, there other way achieve it.
Comments
Post a Comment