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

Dealing with taxonomy display

A little foreword on Drupal theming

Most of you reading now aware of that it’s said: Drupal is a great CMS. It is a completely flexible platform and serves as a great foundation to build nearly any kind of website. It has a well structured system which nearly completely separates code, content and style. Perhaps this flexibility causes most issues when dealing with theming. Creating templates for Drupal is wonderfully simple when it comes to the basics. Vast documentation and a helpful community stands there for the template developer but there are so many possibilities and so many available options that it’s often not enough.

Apart from creativity, developing themes for Drupal needs a widely open brain who understands the logic behind the scenes and can take the advantage of flexibility. Indeed it needs both a designer and a developer in mind.

During one of my latest works I realized why the majority of Drupal themes are very similar, because its developers don’t take their time to go beyond the basics. I believe this is a must if you wish to create something that you want to be outstanding from the crowd. Nada to say Ubiquity isn’t that outstanding that way, too. As you can see it only serves basic needs but it might be a nice base for customizing.

Anyway, I decided to publish some of my theming tricks, bits and pieces what I used before. It will cover css, php and Drupal. I mostly use the core PHPTemplate engine. Why not using some of the custom engines like Smarty? Smarty is great but I believe performance is really what shouldn’t be overlooked and the richer the template engine is in features the faster it will die under high load. PHPTemplate is just fine for what we do.
Cut to the cheese

Enough said, let’s deal with taxonomy display.

Tags: display, taxonomy, 分类信息

太兴奋了,百度收录了!

  呵呵,我说的当然不是这个网站了,geniusy.com被收录是很正常的。我指的是52acca,不过不是52acca.com,是52acca.cn,之前准备从dedecms转到phpcms时的试验站点,全部文章都已经转换过去了的,但是之前查一直也都没收录,今天无意中site:52acca.cn了一下,发现竟然有100多页收录了,我今后到底该怎么办呢?难道要从52acca.com转到52acca.cn,这太不像话了吧?况且现在网站多数流量都是老客户,都只知道52acca.com,如果转的话会损失很多客户的;其实,google对我的站还不错,关键字排名都很靠前的,acca已经排到第二位了,这都不是新站所能达到的权重啊。哎,这可真让我为难了啊,以前正常情况下百度的流量是google的两倍,如果没被baidu封站的话,网站流量可以轻松翻番的。

  谁可以给我点建议啊,如果真转域名的话,是可以通过url_rewrite将google的流量暂时转到52acca.cn的,但是一段时间后链接肯定会被降权的,到时候从google来的流量也就真是没落了,而且百度到底会怎样对待我的站,这也是个很大的未知数啊。

刚才还google了一下,发现同样也是很令人欣慰的一件事。我之前发的那篇文章竟然在发布后半个小时内就被收录了,google的效率真高啊,倒是百度最近倒像是人到老年了,要么不收录,要么N天才来收录几页,哎,难道真的是中了百毒?

Tags: 52acca.cn, 52acca.com,google, site, 收录, 百度

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, 文章, 次数, 评论数, 调用, 阅读