While creating a content or editing one, newly entered meta tags (keywords, description etc) aren't reflected when Preview of the content is made. This happens because of the following code in function nodewords_form_alter().

if (isset($type)) {
  if (isset($id) && is_numeric($id)) { // tries to tags retrieve from DB; newly entered meta info not reflected
    $tags = _nodewords_load($type, $id); 
  }
  else {
    $tags = array();
  }
  $form['nodewords'] = _nodewords_form($type, $tags);
}

I've done the following changes and it works perfectly for me. I also believe, that this method is more efficient because it doesn't hit the DB unnecessarily.

if(!empty($form_state['values']['nodewords'])) { // Check if $tags can be reused from $form_state
  $tags = $form_state['values']['nodewords'];
}
elseif (isset($type)) { //Not available in $form_state. If type is set
  if (isset($id) && is_numeric($id)) { // and if $id is set, load from DB
    $tags = _nodewords_load($type, $id); 
  }
}
else {
  $tags = array();
}
  
$form['nodewords'] = _nodewords_form($type, $tags);

Comments

lvshankar’s picture

sorry, that would be.

if (isset($type)) {
	if(!empty($form_state['values']['nodewords'])) { // Check if $tags can be reused from $form_state
		$tags = $form_state['values']['nodewords'];
	}
	else {
		if (isset($id) && is_numeric($id)) { //Not available in $form_state. If $id is set, load from DB
			$tags = _nodewords_load($type, $id);
		}
		else {
			$tags = array();
		}
	}
	$form['nodewords'] = _nodewords_form($type, $tags);
}
Robrecht Jacques’s picture

Status: Active » Fixed

Committed to CVS. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.