2013-05-27 4 views
1

내가 드루팔에 새로운 오전에 사용자 정의 노드의 URL을 설정하는 방법에 대해 설명합니다. 드루팔 (Drupal 7)의 코드를 사용하여 맞춤 URL을 만들고 있는데 맞춤 URL을 설정하고 싶습니다. 다음 코드를 사용하고 있습니다. 현재는 http://abc.com/greeting-12 내가 설정 싶어 URL을 보여주는 것이 http://abc.com/ab/cd/md5(string) 하십시오 제가 그것을 할 수있는 방법을 알려주세요?드루팔 7

<?php 
drupal_add_css(drupal_get_path('theme', 'custom') . '/css/my_flip1.css', array('group' => CSS_THEME, 'type' => 'file')); 
$path = base_path() . path_to_theme(); 
?> 
<?php 
    global $url; 
    $link_id=$_REQUEST['link_id']; 
    global $myimg; 
     global $de; 
    if(isset($_REQUEST['id'])) 
    { 
       global $myimg; 
       global $de; 
       global $url; 
      $myimg=$_REQUEST['img']; 
       $path = base_path() . path_to_theme(); 
       $account = $GLOBALS['user']->uid; 
       $de=$_REQUEST['txt']; 
       $node=new stdClass(); 
       $node->type = "page"; // Or any other content type you want 
       $title=$node->title="Greeting"; 
       $node->language = LANGUAGE_NONE; 
       node_object_prepare($node); // Set some default values. 
       $node = node_submit($node); // Prepare node for a submit 
       node_save($node); // After this call we'll get a nid 
       $node->status = 1; 

       $options = array('absolute' => TRUE); 
       $nid =$node->nid; 

       $url = url('node/' . $nid, $options); 
       $node->path=$url; 

       db_insert('user_shared_image') 
    ->fields(array(
         'uid' => $account, 
      'link' => $node->path, 
          'description'=>$_REQUEST['txt'], 
          'link_id'=>$link_id, 
        )) 
      ->execute(); 

      $format =   ' 
       <head> 
     <style> 
      .imgright{ 
       background: url("../images/trans.png") repeat scroll 0 0 transparent; 
       } 
      </style> 
      <script type="text/javascript"> 
      jQuery(document).ready(function(){ 

      jQuery(".flip-container").click(function() { 
      jQuery(".flip-container").addClass("hover"); 
      jQuery(".transparent1").hide(); 
      jQuery("#back").css("visibility","visible"); 
      }); 
      jQuery("#back").click(function() { 
      jQuery(".flip-container").removeClass("hover"); 
       jQuery(".transparent1").show(); 
       jQuery("#back").css("visibility","hidden"); 
       }); 

       }); 
       </script></head> 

       <div align="center"> 
      <button id="back" type="button" style="visibility:hidden;"> 
      Show Image</button> </div> 
       <div class="right-element1" align="center"> 
       <div class="flip-container flip" style="float:none !important;"> 
         <div class="flipper"> 
           <div class="front"> 
            '.$myimg.' 
           </div> 

           <div class="back face center"> 
          <div id="back-content"> 
    <p>  '.$_REQUEST["txt"].' </p> 


                </div> 
           </div> 

          </div> 

        </div> 

        <div class="transparent1"> 
            <p> '.$_REQUEST["txt"].' </p> 


           </div> 
        </div>'; 


      db_insert('field_data_body') 
       ->fields(array(
            'entity_type'=>'node', 
            'bundle'=>'page', 
            'entity_id'=>$nid, 
            'revision_id'=>$nid, 
            'language'=>'und', 
            'delta'=>0, 
        'body_value' => $format, 
            'body_format'=>'php_code', 
       )) 

        ->execute(); 

         echo $url; 
        exit;    
      } 

답변

0

경로 패턴, 당신은 경로 자동 모듈을 사용하고 더러운 일을하도록해야 동일한 콘텐츠 유형의 모든 노드에 대해 동일 할 경우 ! 그것의 빠르고 정확한!

1

경로 자동 모듈 - 경로 자동 정말 좋은 그냥 내 이전의 대답과 같은

http://drupal.org/project/pathauto, 그것은 모든 더러운 일을 할 것입니다 심지어 당신이 사용자 정의 할 수 BTW 기사, 기본 페이지 등을 구별 할 수있다 귀하가 만드는 각 유형의 콘텐츠.