欢迎各位兄弟 发布技术文章

这里的技术是共享的

shiping1 的头像

drupal 不能对评论进行回复 不能回复评论 去掉评论回复

删除Drupal评论中的Reply链接

作者:老梁 日期:2013年5月12日

删除Drupal评论的reply链接

在有些Drupal网站建设项目中,客户希望禁用评论项的回复功能。实现这个需求非常简单,通过实现THEME_preprocess_comment()主题预处理函数即可。

在Drupal主题的template.php文件中,放入下列代码:

普通分类: 
shiping1 的头像

drupal节点或评论中显示用户头像

Enabling user pictures (avatars)

Last updated April 8, 2012. Created by emmajane on May 7, 2005.

普通分类: 
shiping1 的头像

有人用过ubercart吗 请问原价 现价 的方法

有人用过ubercart吗 请问原价 现价 的方法
如何实现
原价的字段 怎么办
是在内容类型里添加字段吗
[福建]Lenny(112331868)  21:54:05
原价就是list price
打折就是sale price
[苏州]泪痕_元怜(958186957)  21:54:29

cost是什么意思吗
[福建]Lenny(112331868)  21:54:46
安装完über cart 自然会有个product content type
 
[苏州]泪痕_元怜(958186957)  21:55:24
product content type
 可以在内容类型中设吗
设字段吗
因为感觉字段不够用
@[福建]Lenny   兄弟可以吗
我是说增加字段 怎么加
[中山]猫之良品<catcat811@gmail.com>  22:11:02
cost就是成本的意思
普通分类: 
shiping1 的头像

drupal 翻译字符串几种方法 有大用

1)
http://my.wangruo.com/admin/build/translate/
admin/build/translate/search

2)装上stringoverride ( string override )模块后  可以自定义增加字符串 并进行翻译,,,还可以导入导出字符串设置
admin/settings/stringoverrides

3)直接在 .po文件中修改 和增加
themes/chameleon/translations/themes-chameleon.zh-hans.po

普通分类: 
shiping1 的头像

drupal 格式化日期 设置变量的方法 修改变量的方法 这里不用在模板里直接写函数 时间 time 有大用

node.tpl.php 中 <span class="submitted"><?php print $submitted; ?></span>

sites/all/themes/mygarland/myminnelli/template.php 中
function myminnelli_node_submitted($node) {
  return t('Submitted by !username on @datetime',
    array(
      '!username' => theme('username', $node),
      '@datetime' => format_date($node->created,'custom','Y-m-d H:i:s'),
    ));
}

见模块 node.module中注册了这个主题函数
普通分类: 
shiping1 的头像

使用format_date()函数格式化Drupal节点创建日期

使用format_date()函数格式化Drupal节点创建日期

作者:老梁 日期:2013年10月18日

日期

普通分类: 
shiping1 的头像

date Y-m-d 年月日时分秒表示法 格式 format 日期字符 符号 表示法 有大用 有大大用

 

来自  http://php.net/manual/zh/function.date.php

Y-m-d H:i:s    年月日时分秒

date

(PHP 4, PHP 5)

普通分类: 
shiping1 的头像

添加和操作模板变量

在一个预处理函数是 global 一个变量 在后续的预处理函数中 可以通过global取到
例如在
function lanyulu_preprocess_node(&$vars)
{
    global $aaa;
    $aaa ="AAAAAAAA"; 
}

function lanyulu_preprocess_comment_wrapper(&$vars) {
     global $aaa;
     此时就可以取到 $aaa的值
}


普通分类: 
shiping1 的头像

所有模板都可以使用的变量

所有模板都可以使用的变量

Drupal已经定义了下面一些常用变量:

$zebra:这个变量的值是odd 或even,每当调用theme('node')时,它可以很容易在节点列表主题化时作为切换变量。

普通分类: 
shiping1 的头像

php 数组操作 array操作 相加 合并 相减 压入 差集等等 有大用 有大大用 有大大大用

//array_diff 两个数组相减两个数组的差集  是值的差集 ,不是键的差集
//元素  属于前一个数组 ,且不属于后一个数组,的元素组成的新数组
$userIds=array(1,3,5,7,9);
$userId = array(3,5,9);
$userIds = array_diff($userIds,$userId);
var_dump($userIds);
//结果 array(2) { [0]=> int(1) [3]=> int(7) }


<?php
//array_push() 函数向第一个参数的数组尾部添加一个或多个元素(入栈),然后返回新数组的长度。
?>

//array_unshift() 函数在数组开头插入一个或多个元素。
//array_unshift(array,value1,value2,value3...)
//$a=array("a"=>"Cat","b"=>"Dog");

普通分类: 
shiping1 的头像

发布评论用到的文件

comment-wrapper.tpl.php,comment.tpl.php


//以下是先执行1 再执行2
//下面是评论的预处理函数1
function garland_preprocess_comment_wrapper(&$vars) {
  if ($vars['content'] && $vars['node']->type != 'forum') {
    $vars['content'] = '<h2 class="comments">'. t('Comments') .'</h2>'.  $vars['content'];
  }
}
//下面是评论的预处理函数2
function lanyulu_preprocess_comment(&$vars, $hook) {
    $vars['classes_array'][]='mycomment';
}


发布评论的容器tpl box.tpl.php
普通分类: 
shiping1 的头像

删除Drupal评论中的Reply链接 评论预处理

删除Drupal评论中的Reply链接

作者:老梁 日期:2013年5月12日

删除Drupal评论的reply链接

在有些Drupal网站建设项目中,客户希望禁用评论项的回复功能。实现这个需求非常简单,通过实现THEME_preprocess_comment()主题预处理函数即可。

普通分类: 
shiping1 的头像

Drupal 7 模板改写建议 顺序

Drupal 7 模板改写建议

普通分类: 
shiping1 的头像

node.tpl.php 判断是否一个独立页面

直接在node.tpl.php中用$page就可以判断是否为一个独立页面.页这里的$node对象也很强大!.

<?php if (!$page): ?>
  <h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
普通分类: 
shiping1 的头像

主题 默认的模板建议文件 模板建议 顺序

主题包含哪些文件
    1)主题名.info文件
    2)page.tpl.php(可能还有各种分支)
    3)node.tpl.php(可能还有各种分支)
    4)block.tpl.php(也许可能没有)
    4)box.tpl.php 评论的容器设置,其实一般不用改,一般用不到(也许可能没有)
    5)comment.tpl.php(也许可能没有)
    6)template.php文件(也许可能没有)
    7)phptemplate.engine一般用不到(也许可能没有)里面的函数可以重写的

themes->engines-> 模板引擎目录
去drupal网站上找smarty,因为drupal已为它封装
 不要在smarty网站上找smarty
sites/all/themes 的目录下
1)http://drupal.org/project/smarty
  放到 engine的目录中就可以了
2)主题的目录在 sites/all/themes 下面
普通分类: 
shiping1 的头像

drupal d6 d7 drupal6 drupal7 根据 节点 或者分类得到词汇表 有大用 有大大用

shiping1 的头像

drupal teaser的获得

在/wangruoban/modules/node/node.module\
大约 307行 可以看到 node_teaser函数

function node_teaser($body, $format = NULL, $size = NULL) {

  if (!isset($size)) {
    $size = variable_get('teaser_length', 600);
  }

  // Find where the delimiter is in the body
  $delimiter = strpos($body, '<!--break-->');

  // If the size is zero, and there is no delimiter, the entire body is the teaser.
  if ($size == 0 && $delimiter === FALSE) {
    return $body;
  }
普通分类: 
shiping1 的头像

drupal 主题一些覆写

<?php

/**
 * Sets the body-tag class attribute.
 *
 * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
 */
function phptemplate_body_class($left, $right) {
    if ($left != '' && $right != '') {
        $class = 'sidebars';
    }
    else {
        if ($left != '') {
            $class = 'sidebar-left';
        }
        if ($right != '') {
            $class = 'sidebar-right';
        }
    }

    if (isset($class)) {
普通分类: 
shiping1 的头像

好多地方用到的分页大小 包括分类页面用到的分页大小 条目数 分页数量

admin/content/node-settings
普通分类: 
shiping1 的头像

configure page size for taxonomy using services

configure page size for taxonomy using services

Last updated June 13, 2013. Created by ellishettinga on June 13, 2013.
Log in to edit this page.

普通分类: 
shiping1 的头像

taxonomy_get_children 得到子分类

shiping1 的头像

function taxonomy_select_nodes

function taxonomy_select_nodes

7 taxonomy.moduletaxonomy_select_nodes($tid, $pager = TRUE, $lim
普通分类: 
shiping1 的头像

父分类显示子栏目下 父分类 子分类 父栏目 子栏目 的文章 有大用 有大大用

下面这个是完全正确的
http://my.wangruoban.com/taxonomy/term/24/
不能取子栏目的内容
http://my.wangruoban.com/taxonomy/term/24/1
1.表示深度为1.就可以取到子栏目的同空
wangruoban\modules\taxonomy\taxonomy.pages.inc
的大约 function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
从第二个参数 就可以看出来了 第一个参数$str_tids 对应的栏目的id为24 ,第二个参数对应的是深度,我这里为1












下面好像不怎么起作用

普通分类: 
shiping1 的头像

drupal node 中 使用裁切图像 imagecache

普通分类: 
shiping1 的头像

Drupal中template.php的作用

你可能知道在drupal的模板中(比如node.tpl.php)隐藏了很多信息,比如:

     <div><?php print $links; ?></div>

如果你是个设计人员或者drupal的使用者,你可能不知道$links中都包含了哪些信息,deve模块提供一个函数dsm()可以很轻松的查看$links的详细信息,用法如下:

    <?php dsm('$links'); ?>

这是一个不错的办法,可是虽然知道了$links的信息,如果要修改$links又要怎么做呢?

普通分类: 
shiping1 的头像

node 节点 及其它各种变量 字段

定制drupal 7节点(node)

普通分类: 
shiping1 的头像

覆写字段方法

google   drupal override node field





覆写字段的顺序
leyouji_field__field__feedom_tags()
Candidate function names:
leyouji_field__field__feedom_tags___spot
< leyouji_field___spot <
leyouji_field__field__feedom_tags
< leyouji_field__taxonomy_term_reference
< leyouji_field
Preprocess functions:
template_preprocess_field + rdf_preprocess_field
Process functions:
template_process_field


假使你的这个文章所在的内容类型叫 article
article 的 field_image 是放图片,title 是标题, body 是内容。
 
普通分类: 
shiping1 的头像

去掉默认的css.txt

shiping1 的头像

drual import link css

shiping1 的头像

如果在一个模板中,你不知道这个模板都有什么变量的话,使用以下调试脚本输出

如果在一个模板中,你不知道这个模板都有什么变量的话,使用以下调试脚本输出
<?php
$vars = get_defined_vars();
print_r($vars);
?>
普通分类: 

页面

Subscribe to 个人技术网_前端_后台_php_div_css_linux_javascript_seo RSS