Community

Redirect Multiple Duplicates of mutiple nodes to the respective Original URL

There are duplicate nodes for random nodes ranging from 2-20 duplicates and instead of deleting all of them, I would like to redirect them to the original or the FIRST node that was created and this needs to happen for all the nodes.

I installed path redirect and global redirect but they don't seem to help much.

Any suggestions are appreciated.

Comments

How are you determining a

How are you determining a node is a duplicate of another? Is there a field that specifies that it is a duplicate of another node, or is there a field that would have a value unique to it and it's duplicates? The way duplicates are identified will inform the best approach.

It has the same content and

It has the same content and the title but the wierd thing is that the duplicates show the "admin" as the author where as the original post would be posted by an actual author.

In some cases if the original post has an image or a video, the duplicates don't have the media but have the same content.

There is a definite possibility of user error but some articles have 20-25 duplicates.

The only way to identify duplicates would be through the title.

Again, The plan is to unpublish all duplicates and redirect them to the original article

I think that redirecting to

I think that redirecting to the original node is a band-aid solution. It seems that something in your system is causing these nodes to be duplicated - it would probably be better to track this down (the source of the problem), rather than apply a redirect (which only masks the problem).

Do you know how these duplicate nodes are being created?

Jaypan We build websites

You are absolutely

You are absolutely right.

After reading the forums I realized that the only would be to disable each module and see if check for duplicates but that would be such a pain.

Also, more weird is that the author on the duplicate is always the same "admin"

Also the reason to redirect

Also the reason to redirect all duplicates is that these duplicate articles have been posted in networking websites and we don't want to just delete them

The following is an outline

The following is an outline how to address the issue. I haven't worked much in Drupal 6 so I hope the code is fully applicable, but this maps out what you need. The example below assumes that matching titles within this content type = duplicates. If there are instances of non-duplicate nodes with matching titles, you'll need to check for matching content as well.

Use hook_view to act on the nodes as they're loaded in the browser.

yourmodule_view($node, $view_mode){
      //filter by the type of node with the duplicate issue
      if($node->type == "TypeWithDuplicateProblem"){
            //get node id
            $nid = $node->nid;
           //get the lowest nid value for matching titles of this type
            $result = db_query("SELECT MIN(nid) FROM {node} where type = :type AND title = :title", array(':type' =>$node->type, ':title' => $node->title) );
           $lowest_nid = db_fetch_array($result));
         
           //see if the lowest nid is lower than the page being loaded
           // if it's lower, redirect to the parent node
           if($lowest_nid < $nid){
               drupal_goto('node/' . $lowest_nid);
           }
     }

}

Hope this helps!

I followed your path. Thanks

I followed your path. Thanks for that!!

I created a custom module that would redirect all duplicates to the original but I get the following error(the function is working) -

warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'views_access' not found or invalid function name in includes/menu.inc on line 452.

nobody click here