我是drupal的新手。我正在使用drupal 7中的代码创建自定义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;
}
答案 0 :(得分:1)
路径自动模块 - http://drupal.org/project/pathauto
就像我之前的答案一样,它将完成所有肮脏的工作,路径自动非常好,甚至可以区分btw文章,基本页面等,允许您自定义您创建的每种类型的内容。
答案 1 :(得分:0)
如果相同内容类型的所有节点的路径模式相同,则应使用路径自动模块并让它执行脏工作!它快速准确!