Any suggestions on how to handle nodes that have cck_redirection fields that are set to automatically redirect? It doesn't make sense to index these but I'm not entirely sure what the best way would be? Are there hooks that could be used to check the node being indexed to see if it had a redirection field?

Comments

Anonymous’s picture

You should be able to set the node to not be indexed in the node edit form.

damienmckenna’s picture

From an editorial workflow perspective I'd prefer not to have to rely on someone else to change a setting every time, plus there's the existing nodes that have that field.

I guess I'm looking for some thoughts on what the general rule should be and whether existing hooks could cope to implement any suggested improvements/fixes? I'm very happy to work on the fix but I wanted some input from others on how they would like it handled.

dave reid’s picture

Assigned: Unassigned » dave reid

Hmm.... I thought I had written down the custom code required to do this. Sorry Damien. :(

Let me re-come up with it.

dave reid’s picture

Status: Active » Fixed

Here's what I successfully tested locally. It could probably be done better, but it gets the job done.

function mymodule_xmlsitemap_link_alter(array &$link) {
  if ($link['type'] == 'node') {
    $query = db_query("SELECT field_name FROM {content_node_field_instance} WHERE widget_type = 'cck_redirection' AND type_name = '%s'", $link['subtype']);
    while ($field = db_result($query)) {
      $table = db_escape_table('content_type_' . $link['subtype']);
      $field = db_escape_string($field . '_value');
      if (db_result(db_query_range("SELECT 1 FROM {$table} WHERE nid = %d AND $field IS NOT NULL", $link['id'], 0, 1))) {
        $link['status'] = 0;
        $link['status_override'] = 1;
        return;
      }
    }
  }
}

Status: Fixed » Closed (fixed)

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