1

私は drupal が初めてです。drupal 7 のコードを使用してカスタム URL を作成していますが、カスタム URL を設定したいと考えています。次のコードを使用しています。現在、URL http://abc.com/greeting-12が表示されていますhttp://abc.com/ab/cd/md5(string) に設定したいの ですが、どうすればよいか教えてください。

    <?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;              
             }
4

2 に答える 2

1

パス自動モジュール - http://drupal.org/project/pathauto

私の前の答えと同じように、それはすべての汚い仕事をします.path autoは本当に優れており、btwの記事、基本的なページなどを区別することさえできます.作成するコンテンツの種類ごとにカスタマイズできます.

于 2013-05-28T18:57:45.727 に答える