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

这里的技术是共享的

You are here

drupal

shiping1 的头像

主题函数 主题钩子函数

<?php if (!empty($secondary_links)): ?>
          <div id="secondary" class="clear-block">
            <?php print theme('links', $secondary_links, array('class' => 'links secondary-links')); ?>
          </div>
     <?php endif; ?>

这里好像是 只能在page.tpl.php文件中才会起作用


1)在 sites/all/modules/中
  建一文件夹 hellodrupal
2)在其内建 hellodrupal.info,hellodrupal.module
名称要一样
 <?php
; $Id$
name = Hellodrupal
description = List the latest content links
core = 6.x

普通分类: 
shiping1 的头像

jQuery Msg Alert 的使用

jQuery Msg Alert

This module displays Drupal's messages and the most recent Watchdog's messages as a little alert at the bottom corner. Every message sent by drupal_set_message() will be converted to a dialog alert, using jQuery Msg Alert plugin.
You can configure the time interval between then and they will reorganize themselves to be always near each other.
These alerts are actually jQuery UI dialogs, so you have a huge option of themes to customize the look and feel.

REQUIREMENTS:
普通分类: 
shiping1 的头像

TypeError: $(...).on is not a function drupal的jquery版本有时低出问题

你可能要添加您的安装的更多细节进入正题。
普通分类: 
shiping1 的头像

error "An error occurred at /admin/build/views/ajax/display/home/default/analyze-theme"

不知道什么原因 反正 把misc下的jquery.js 文件换掉 就可以了
反正jquery核心文件有时一动 就会出点问题
普通分类: 
shiping1 的头像

views 用sql来查询

普通分类: 
shiping1 的头像

根据node得到路径

见 https://drupal.org/node/164585 有大用
变量 $node_url 只有在node.tpl.php中起作用


<?php
$nodeurl
= url('node/'. $node->nid);
普通分类: 
shiping1 的头像

drupal 路径 别名路径

我的方法 根据$term得到 别名路径
<?php   $pathArr=taxonomy_term_uri($continent);$alias= drupal_get_path_alias($pathArr['path']); ?>
这里 alias 就是别名路径


Get the URL of a Node or Term in Drupal 7

Primary tabs
ListView(active tab)
Submitted by geoff on Sat, 2012-04-28 11:33
Given a Node or Taxonomy Term - or any "entity" based object

$uri = entity_uri($entity_type, $entity);
$url = $uri['path'];
When you create a link with the l() function, it will link to the Clean URL for that entity (if one exists).

for a Node
普通分类: 
shiping1 的头像

开发时 每次都要清空缓存的办法


admin/build/themes/settings/lanyulu
(好像是只有zen或zen子主题下才可以看到下面)
下面这个页面的设置



Theme development settings


普通分类: 
shiping1 的头像

drupal 错误弹出js alert

  这个模块 可以实现 错误弹出js alert
可以让错误信息更友好

好像没有配置,装上去就起作用

可是对所有页面都起作用

普通分类: 
shiping1 的头像

Drupal 7与Drupal 6比较之主题变化

shiping1 的头像

自己通过模块创造主题里的预处理函数

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 的头像

添加和操作模板变量

在一个预处理函数是 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 的头像

发布评论用到的文件

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 得到子分类

页面

Subscribe to RSS - drupal