📜 ⬆️ ⬇️

Substitution node alias

image

The task is to replace all the links of a particular node type with others.





My actions:

Because In Drupal “for good,” all links are generated via url () , that is, the ability to use the custom_url_rewrite_outbound () function to reload links.
')
Copy Source | Copy HTML function custom_url_rewrite_outbound(& $path , & $options , $original_path ) { if (preg_match( "/^node\/[0-9]*$/" , $original_path )){ // "node/13123" $array = explode( "/" , $original_path ); // $node = node_load( $array [ 1 ]); // // , if ( $node ->type == 'node_type' ) $path = 'my_super_new_node/' . $node ->nid; } }
  1. Copy Source | Copy HTML function custom_url_rewrite_outbound(& $path , & $options , $original_path ) { if (preg_match( "/^node\/[0-9]*$/" , $original_path )){ // "node/13123" $array = explode( "/" , $original_path ); // $node = node_load( $array [ 1 ]); // // , if ( $node ->type == 'node_type' ) $path = 'my_super_new_node/' . $node ->nid; } }
  2. Copy Source | Copy HTML function custom_url_rewrite_outbound(& $path , & $options , $original_path ) { if (preg_match( "/^node\/[0-9]*$/" , $original_path )){ // "node/13123" $array = explode( "/" , $original_path ); // $node = node_load( $array [ 1 ]); // // , if ( $node ->type == 'node_type' ) $path = 'my_super_new_node/' . $node ->nid; } }
  3. Copy Source | Copy HTML function custom_url_rewrite_outbound(& $path , & $options , $original_path ) { if (preg_match( "/^node\/[0-9]*$/" , $original_path )){ // "node/13123" $array = explode( "/" , $original_path ); // $node = node_load( $array [ 1 ]); // // , if ( $node ->type == 'node_type' ) $path = 'my_super_new_node/' . $node ->nid; } }
  4. Copy Source | Copy HTML function custom_url_rewrite_outbound(& $path , & $options , $original_path ) { if (preg_match( "/^node\/[0-9]*$/" , $original_path )){ // "node/13123" $array = explode( "/" , $original_path ); // $node = node_load( $array [ 1 ]); // // , if ( $node ->type == 'node_type' ) $path = 'my_super_new_node/' . $node ->nid; } }
  5. Copy Source | Copy HTML function custom_url_rewrite_outbound(& $path , & $options , $original_path ) { if (preg_match( "/^node\/[0-9]*$/" , $original_path )){ // "node/13123" $array = explode( "/" , $original_path ); // $node = node_load( $array [ 1 ]); // // , if ( $node ->type == 'node_type' ) $path = 'my_super_new_node/' . $node ->nid; } }
  6. Copy Source | Copy HTML function custom_url_rewrite_outbound(& $path , & $options , $original_path ) { if (preg_match( "/^node\/[0-9]*$/" , $original_path )){ // "node/13123" $array = explode( "/" , $original_path ); // $node = node_load( $array [ 1 ]); // // , if ( $node ->type == 'node_type' ) $path = 'my_super_new_node/' . $node ->nid; } }
  7. Copy Source | Copy HTML function custom_url_rewrite_outbound(& $path , & $options , $original_path ) { if (preg_match( "/^node\/[0-9]*$/" , $original_path )){ // "node/13123" $array = explode( "/" , $original_path ); // $node = node_load( $array [ 1 ]); // // , if ( $node ->type == 'node_type' ) $path = 'my_super_new_node/' . $node ->nid; } }
  8. Copy Source | Copy HTML function custom_url_rewrite_outbound(& $path , & $options , $original_path ) { if (preg_match( "/^node\/[0-9]*$/" , $original_path )){ // "node/13123" $array = explode( "/" , $original_path ); // $node = node_load( $array [ 1 ]); // // , if ( $node ->type == 'node_type' ) $path = 'my_super_new_node/' . $node ->nid; } }


Attention question:

How much is my method correct, and is there a more correct solution to my problem? Thank.

Source: https://habr.com/ru/post/112586/


All Articles