Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of module_invoke_all(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in /home/.megatoes/geniusy/geniusy/drupal/modules/fuzzysearch/fuzzysearch.module on line 324
drupal | Geniusy's Blog

drupal

Tabular menu items in Drupal

tabluar-menu-items/teaser.

In today’s excercise, we are going to adapt some nice styles to the Drupal menu items. There is a widely known CSS technique called sliding doors which became very popular since it became published. We are going to spice this a little more with extra hover states and implement sprites to improve the performance a little. This will involve a little PHP code – overriding a themeable function, and some CSS markup.

Let’s start with a piece of generated html code:

<ul class="links-menu">
<li><a href="/free">Download templates</a></li>
<li><a href="/about">About</a></li>
<li class="active"><a href="/blog" class="active">Blog</a></li>
<li><a href="/contact">Contact</a></li>
</ul>

This is how Drupal renders primary links. Notice the active menu item which is set by a CSS class active on both the <li> and <a> tags. Since the anchor element’s parent is set to a class, it makes extremely easy to theme nice menu items.

Let’s create a background image for the tabs. Our tab will have four states: one for a regular item, one for hover, and both of them once they’re .active. I prefer using sprites as this will improve performance a little: loading several little images takes more time than loading one bigger image which holds all the necessary background elements.

So I decided to come up with this tab image.

Tags: drupal, menu, Tabular

Drupal常用API函数列表

comment_num_all($nid):调用评论数,$nid为node的ID,当前node可用$node->nid。

taxonomy_get_tree($vid):显示分类(item),vid为category的ID,必须是category,不能是item,也就是说只能显示父层下面的item。

taxonomy_get_children($tid):显示Item下面的item,$tid为父item的id。

menu_get_menu():Return the menu data structure.不带参数,显示系统所有的menu。

menu_primary_links($start_level = 1, $pid = 0):pid可以指定起始层数,start_level貌似意思也差不多,还没实验过,有时间试试再说,下面是英文说明:
$start_level This optional parameter can be used to retrieve a context-sensitive array of links at $start_level levels deep into the Primary links menu. The default is to return the top-level links.

$pid The parent menu ID from which to search for children. Defaults to the menu_primary_menu setting.

menu_overview_tree:Present the menu tree, rendered along with links to edit menu items.

menu_get_item($mid, $path = NULL):Retrieves the menu item specified by $mid, or by $path if $mid is not given.

node_last_viewed:Retrieves the timestamp at which the current user last viewed the specified node.放在首页可以返回用户上次访问网站的时间。

referer_uri:Return the URI of the referring page.可以用来统计来源页面。

request_uri:Since $_SERVER['REQUEST_URI'] is only available on Apache, we generate an equivalent using other environment variables.任何服务器系统下面都可以使用。

sess_count($timestamp = 0, $anonymous = true):Counts how many users have sessions. Can count either anonymous sessions, authenticated sessions, or both.貌似可以分别统计在线会员与游客数了。可以通过指定$timestam来实现15分钟内在线人数效果。

statistics_title_list($dbfield, $dbrows):
Description

Returns all time or today top or last viewed node(s).

Parameters

$dbfield one of

Tags: api, drupal, function, 函数, 功能

Drupal如何调用文章阅读次数和评论次数

初次接触Drupal的新手可能会和我一样手足无措,本来很简单的功能都没办法实现。调用阅读数和评论数真是很简单的功能,如果使用其它CMS或者Blog CMS,这些一般都能从官方默认的模板或者使用帮助中找到,但是Drupal就不同了,什么都得靠自己摸索。

为了调用这两个变量我首先想到的是在数据库里面找,但是非常令我失望,drupal的node表里面根本没记录阅读次数,评论到是可以通过count一下comments表里面每个nid出现的次数得到,但是每次那样也未必烦琐了一点。

在DrupalChina里面提出了这个问题,第一个问题得到了解答:先要在后台,“管理”-“日志”-“访问记录设置”里面启用“页面访问计数”功能,然后就可以通过<?php
print $node->links['statistics_counter']['title']
?>语句调用node阅读次数了。

显示评论数是我自己摸索出来的,在api.drupal.org上面找到了三个函数,comment_num_all,comment_num_new和comment_num_replies,我只用了第一个,后面两个具体什么功能没用过,官方上也没说明。但我要的功能达到了,在需要显示评论数的地方加上<?php print comment_num_all($node->nid) ?>语句就OK了。

上次在api.drupal.org上还找到了一个显示分类的函数,我现在右边的分类就是用taxonomy_get_tree($vid)和taxonomy_get_children($vid)来获取分类(category或者taxonemy),这样就可以不需要自己写SQL语句了,其实这些函数就是由一些SQL语句组成的。有空的时候可以多到api网站上转转,上面可以找到很多好用的函数的。

Tags: api, comment_num_all, drupal, node, statistics_counter, taxonomy_get_tree, 文章, 次数, 评论数, 调用, 阅读

用Drupal做门户站的可行性

  最近听到很多谣言,据说百度今后将不再收录用dedecms和ecms等cms做的站,因为多数都是采集的垃圾站。虽然52acca在暑假时都已经被百度封了,而且这消息是毫无根据的胡乱猜测,但听到这消息也让我大吃一惊。如果真是这样的话,我就有了充分的理由对52acca大动手笔了。本来acca全球统考前都做了phpcms版的新版52acca的,但就在准备用新版替换就班的时候,听说dedecms2007要出来了,于是就对它再次燃起了希望。用dedecms做了个新版首页,也就是现在的首页,就等2007出来正式进行全站转换。一个月过去了,dedecms2007也出来20多天了,但没人说2007好,听到的只是埋怨声一片。最近一直在研究Drupal,不能说是没有进展,但是Drupal的确太复杂了,所以要用它单独建站真的还有很大的难度,现在处理起这个博客来都还有诸多问题。但听到这个消息后,我再也按耐不住了,转换已经迫在眉睫,现在想听听大家的看法,共同研究出一个转换的方案,下面是我的初步想法,以52ACCA现在的首页方案,也就是CH的风格为例:

  可以用page-front.tpl.php来做首页的模板,可以就分成header,sidebar-left,content,siderbar- right,footer五块,也可以多分几块,block-modulename-delta.tpl.php,block- modulename.tpl.php和block-region.tpl.php来写各个block的模板;

  列表页和内容页可以去掉sidebar-left区块,然后根据页面来控制block的显示。

  哎,说起来容易,做起来难啊,有几十种不同的block,都得单独写模板;而且列表这么多,如果用view的话,服务器肯定承受不起;即使用SQL查询,每打开一个页面都得进行几十次查询,那个负载也不小啊。

  大家如果有好的想法,说出来参考一下啊。

Tags: 52acca, dedecms, drupal, phpcms, 可行性, 网站, 门户

The Drupal Song Music Video——Drupal之歌(视频)

Drupal之歌(视频)

Loading...

Tags: drupal, Drupal之歌, Music, Song, Video

Drupal学习视频(一)——Drupal的优势

Loading...

This is a step by step video tutorial for creating your website using an opensource content management system called Drupal CMS. There are about 35 videos that take you step by step from registering your domain all the way through configuring it with advanced features like - shopping cart, document workflow, image galleries, surveys, forums, polls, wikis and much more.

This tutorial series has four objectives:

Tags: benifits, cms, drupal, 优势, 学习, 视频

Drupal的计划任务设定(Drupal CRON TASKS)

Drupal的很多功能都是依赖CRON TASKS来完成的,比如搜索的索引,还有Cache的清理,所以CRON对于Drupal来说是很重要的。今天终于把我的Cron tasks搞定了,下面说说我的经历。我是自己的服务器,虚拟主机一半是不能自己设定Cron tasks的,但有一些网站免费提供这个功能。对于drupal来说,只要定时访问根目录下面的cron.php文件,然后就会自动执行一连串的任务,所以我们要做就是定时访问一下这个文件。

Tags: CRON, crond, crontab, drupal, TASKS, 计划任务

drupal中文建站指南-成果篇(2)

 in 

刚才打了一篇,居然发布的时候出了问题,只好提笔重写了,这倒是以前没注意的drupal的一个问题。另外,现在对这个题目的感觉也是怪怪的,应用指南?好在已经这个系列发到现在,就这么一直将就下去吧。

Tags: drupal, zen, 布局, 建站, 成果篇

3大获奖开源CMS评析-Joomla Drupal Plone

 in 

目前全世界的开源CMS(内容管理系统)有上百种,但真正能够被广泛接受和使用的应该不超过10种。最近packt在全球范围内评选最佳开源CMS的结果 出来了,入围3甲的是Joomla!、Drupal和Plone,应该说具有一定的说服力。下面对最终获奖的3个产品进行一定的分析评价。
1、Joomla! http://www.joomla.org/ ? 中文社区:http://joomla.cn

Tags: cms, drupal, joomla, Plone, 开源, 获奖, 评析

网站刚从Sablog转到Drupal

模板前两天就开始做了,这个站从Sablog转到Drupal花了几个小时,这包括安装Drupal和安装各模块(module)和转化数据的时间。现在网站还有很多问题,请大家尽量先访问http://www.geniusy.com/sablog,今后那个网站也将一直存在的,毕竟我对Sablog是充满了感情的,今后还将为Sablog写一些模板,如果有时间,也会做一些Hack的。
等网站调试好后我会写一篇比较详尽的安装笔记的,要为Drupal的新朋友送点礼了,不然人家不接纳我啊。

Tags: drupal, geniusy, sablog, 模板, 转换