主题
drupal主题制作1:info文件
八 31st
drupal主题制作1:info文件
以废话开始
最近一直在研究drupal,第一件事就是用它做个企业站,前些时间在型里面的分类组织以及cck和views插件。现在在看drupal的主题制作,困惑的是怎么把主题和views结合在一起,估计这一点还得花上一两天时间去研究。当然,目标是在这个星期内把公司的企业站搞定。废话少说,转入正题,记述下我在弄drupal时的一些心得,初学者,错误是难免的,希望能够提出帮我改进了。
废话end
drupal主题文件虽然有很多,对于新手而言,只要有两个文件就可以实现其表现层的展示。分别是info文件和page.php.tpl。前者定义了drupal的一些基本要素如主题名称、版本号、使用模板引擎的文件供drupal识别。
注意事项:
1:在使用自己建的主题文件以前,要先在administrator theme里面将管理员模板从default改成galand或者其它系统核心模板,不然在调试自制的模板时因为函数尚未加入的原因,显示不出界面从而导致你无法控制网站;
2:在site/all下面新建themes文件夹并将主题文件放入,这一点不是必须的,但是在以后升级、换服务器时只要将site文件夹下面的内容拷出以及数据库转移即可,不用更改drupal的核心内容,极大地缩短这个过程的时间;
3:在每次更改完主题后,进入administrator-performance,执行一次clear cached data清空缓存数据。
主题文件实例:info
文件名:ruobiz.info
文件内容:
name = ruobiz
description = div css by ruo.
version = VERSION
core = 6.x
engine = phptemplate
文件说明:
name:指模板的名称
description:文件说明
version:版本号,也可以直接自己定义为version=1.0这样子,前者显示出的drupal系统上的版本号,如drupal用的是6.13,则显示6.13,后者则是自己定义的了。
engine:模板使用的php模板引擎。
下面这张图来自官方网站是在管理员页面中对上述内容的解释

drupal主题info文件解释
其它相关的info文件函数还有:
screenshot 截图:发布到网上的话,这个东东应该很需要了
base theme 基主题:如果你不自己写div,而只通过css来改变外观,这是一个很好的选择,没有深入研究。
regions 可以将$left这种主题内部使用的函数自定义化。
features 可以自定义网站logo、口号这些表现层的东西
stylesheets css样式表的引用
scripts 引用的js脚本这些
php php
其它有用的资源
下面这个链接是drupal官方网站关于info文件构建要素的解释:
http://drupal.org/node/171205#name#name
西天也许有;空想前往,又有何用
八 18th
西天也许有;空想前往,又有何用
苏东坡临死时说的
不想自己死的时候重复这句话。
努力了,放弃幻想,脚踏实地。
垃圾站50M的数据库,计划在昨天转移完成的,却因为地震导致了光缆中断无法进行操作,今天却马上恢复了正常,有人说是将路由进行转移过的原因。用上帝国备份王,顺利地转移了数据。下一步就是将采集的关键词恢复正常的,等等google adsense的帐号到达$100试下会不会被K号。
垃圾站采用新页面主题的优化和采集关键词的恢复大致需要两天时间,两天后就可以和老姐搞国内的东西了。谁让我是一个被穷疯的人呢。
高手的后续:很庆幸,我没有丧失思考的能力与思考的空间。他说的和我平常了解的也没有什么区别,区别在于有没有用心去做。当然,周日在茶馆里面的交流和这两天在网上的沟通以及看了他写的seo方案,触到还是挺大的,至少我一直所想要的系统性思维我就没做好。当然最重要的一点,他毕竟现在在做浙江在线的seo工作,所以整个思维的高度也和我的不一样。
just a log
七 25th
花了一天时间,初步仿了一个gmail格式的wordpress主题,估计还得花上一天去完善,并对主题做相应的seo优化。下一步就是将其axaj化,这个还得花上一天的时间。时间真的不够用啊。
这个主题对adsense做了相当多的空位。目的么就是用在英文站。
just so so.
做了很多半途而废的东西的,现在都把它们给完善起来。
努力……为了钱。
魔兽世界开放了下载器http://wow.163.com。打开后却是跳出没有找到下载源的对话框。真不知道这场纠纷什么时候能结束,去玩台服也是一个不错的选择,人民币升值之下,月卡只要80-90块钱了。
wordpress主题
三 14th
前几天一直在给公司做wordpress的cms主题,感觉自己设计方面实在没有天赋,于是晚上一直在找别人已经设计好的主题,在一些英文之中突然发现这个主题的的微缩图竟然有中文的,那么,像我这种懒人,考虑中文显示这类细节自然是能省就省。
ps:另一个原因是,下午骑了两个多小时的车,在联华找了个怀子,那个样子和头部的杯子挺像的。
当然对于杯子来说,它就长那样,都差不多……
很想用win wendy的主题,可是每次到了情人节(今天还是白加黑的)才发现是一个人,可以点击这里欣赏一下这个界面。
这个网站(http://rin-wendy.com/)的布局很特别,首页是三栏,左右不同的颜色,文章页根据不同的作者显示不同的颜色,页面又是一种风格。
1. 首先区分页面,首页,作者A和作者B。
- <?php if (is_page()) {
$style_item = ‘page’;
} elseif (is_single()) {
if ($post->post_author == ‘1′) {
$style_item = ‘left’;
}
elseif ($post->post_author == ‘2′) {
$style_item = ‘right’;
}
} else {
$style_item = ‘normal’;
} ?>
把定义的$style_item加在DIV框架内,以方便用CSS控制显示。
- <div id=”page” class=”wrap-<?php echo($style_item); ?>”>
2. 首页左右作者的实现可以用query_posts来控制
一开始用query_posts(’author=1′ ) 发现这样不能正常分页,查找了相关资料最后找到了如下代码:
- <?php
- $limit = get_option(’posts_per_page’);
- $paged = (get_query_var(’paged’)) ? get_query_var(’paged’) : 1;
- query_posts(’author=1′ . ‘&paged=’ . $paged);
- ?>
注意:
- <?php endwhile; ?>
下方加上一句
- <?php wp_reset_query(); ?>
不加的话会使侧栏的if (is_category())这样的判断失效。
评论部分:
1. 修改comments.php,在wp_list_comments代码那加上&callback=my_comment。
- <?php wp_list_comments(’type=comment&callback=my_comment’); ?>
2. 修改function.php,加入如下代码
- function my_comment($comment, $args, $depth) {
- $GLOBALS['comment'] = $comment; ?>
- <li <?php love_class(); ?> id=”li-comment-<?php comment_ID() ?>”>
- <div id=”comment-<?php comment_ID(); ?>”>
- <div class=”comment-text”>
- <div class=”comment-text-top”> </div>
- <?php comment_text() ?>
- <?php if ($comment->comment_approved == ‘0′) : ?>
- <em><?php _e(’Your comment is awaiting moderation.’) ?></em>
- <?php endif; ?>
- <?php edit_comment_link(__(’(Edit)’),’ ‘,”) ?>
- <div class=”comment-text-bot”> </div>
- </div>
- <div class=”comment-author vcard”>
- <?php echo get_avatar($comment,$size=’48′,$default=’<path_to_url>’ ); ?>
- <?php printf(__(’<cite class=”fn”>%s</cite> <span class=”says”>says:</span>’), get_comment_author_link()) ?>
- </div>
- <div class=”comment-meta commentmetadata”>
- <?php printf(__(’%1$s at %2$s’), get_comment_date(), get_comment_time()) ?>
- </div>
- </div>
- }
3. function.php,加入如下代码
- function love_class( $class = ”, $comment_id = null, $post_id = null, $echo = true ) {
- // Separates classes with a single space, collates classes for comment DIV
- $class = ‘class=”’ . join( ‘ ‘, love_comment_class( $class, $comment_id, $post_id ) ) . ‘”’;
- if ( $echo)
- echo $class;
- else
- return $class;
- }
- function love_comment_class( $class = ”, $comment_id = null, $post_id = null ) {
- global $comment_alt, $comment_depth, $comment_thread_alt;
- $comment = get_comment($comment_id);
- $classes = array();
- // Get the comment type (comment, trackback),
- $classes[] = ( empty( $comment->comment_type ) ) ? ‘comment’ : $comment->comment_type;
- // If the comment author has an id (registered), then print the log in name
- if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
- // For all registered users, ‘byuser’
- $classes[] = ‘byuser comment-author-’ . $user->user_nicename;
- // For comment authors who are the author of the post
- if ( $post = get_post($post_id) ) {
- if ( $comment->user_id === $post->post_author )
- $classes[] = ‘bypostauthor’;
- }
- }
- if ( empty($comment_alt) )
- $comment_alt = 0;
- if ( empty($comment_depth) )
- $comment_depth = 1;
- if ( empty($comment_thread_alt) )
- $comment_thread_alt = 0;
- if ( $comment_alt % 2 ) {
- if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
- $classes[] = ‘odd-’ . $user->user_login;
- $classes[] = ‘alt-’ . $user->user_login;
- } else {
- $classes[] = ‘odd’;
- $classes[] = ‘alt’;
- }
- } else {
- if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
- $classes[] = ‘even-’ . $user->user_login;
- } else {
- $classes[] = ‘even’;
- }
- }
- $comment_alt++;
- // Alt for top-level comments
- if ( 1 == $comment_depth ) {
- if ( $comment_thread_alt % 2 ) {
- $classes[] = ‘thread-odd’;
- $classes[] = ‘thread-alt’;
- } else {
- $classes[] = ‘thread-even’;
- }
- $comment_thread_alt++;
- }
- $classes[] = “depth-$comment_depth”;
- if ( !empty($class) ) {
- if ( !is_array( $class ) )
- $class = preg_split(’#\s+#’, $class);
- $classes = array_merge($classes, $class);
- }
- return apply_filters(’comment_class’, $classes, $class, $comment_id, $post_id);
- }