谦卑的程序员






         静水流深

June 8, 2009

Wordpress MU插件概述

Filed under: Wordpress (mu) — Eric Tou @ 11:37 am
Tags: ,

 

按照来源区分,可分为兼容MU的Wordpress插件和针对MU开发的插件

  Wordpress MU是Wordpress的多用户版本,因为程序结构的关系,Wordpress MU并不一定能兼容Wordpress的插件。这里我们谈到的兼容,是指无需做任何修改即可在MU中直接使用的Wordpress插件。针对MU开发的插件中,分为在原Wordpress插件基础上修改的和针对MU全新开发的两种。

按照作用范围区分,可分为全局插件和分站点插件

  Wordpress中按照影响范围将插件分为两类,全局的插件和针对单个站点的插件,分别存放在不同的目录。

  /wp-content/mu-plugins/ 目录下存放的是全局的插件。此类插件一般属于比较简单的插件,没有插件目录,而只是由一个php文件组成。上传后该类插件后不会出现在各个博客后台的Plug-ins菜单里,而是出现在Site Admin菜单里(必要的话)。此类插件无需逐个博客激活插件,默认就已经自动调用。

  /wp-content/plugins/ 目录下存放的是分站点的插件。此类插件上传到后,需要用户手动在Plug-ins菜单的管理面板中启动(前提是管理员为该用户开启了该权限)。用户启用该插件仅影响该站点,而不会影响其他站点。

Wordpress MU插件的管理

  如果是单文件的简单插件,则直接作为全局插件上传即可,无须也无法做任何管理。(有一个为含目录的插件创建调用的文件并作为全局插件的方法,查询无果,略过)

  对于分站点的插件,如果管理员不想把启用和禁用插件的权限下放给用户,而想统一地为特定的博客启用和禁用插件,可以使用Plugin Commander或者WPMU Plugin Manager插件(两者孰优孰劣还没来得及比较)。

Wordpress MU插件的选择

  首先当然是选择针对MU开发的插件,相当部分在WP平台上广受欢迎的插件都有针对MU的修改版本,既经受过时间的考验而且在使用习惯上能够得到延续。无论有无WP的经验,首先查询WP的相关插件,然后查询在MU平台上是否有衍生品是不错的方法。

  当然针对WPMU全新开发的插件也有其优势,就是完全定制,在跨博客的兼容性方面会有比较全面的考虑。WPMU的官方站点的插件列表在这里。可惜的是数量与WP相比相差太多,活动也并不十分活跃,反倒是有相当一部分不错的插件被放在了需要付费的Premium区,当然这个WPMU的定位有关。

  至于那些默认兼容的插件,需要注意的就是不会有任何跨站点兼容的支持。比如通过Tag获取相关文章,其影响范围只能限于单个博客,在不修改的前提下想跨博客建立关联是不可能的,这很显而易见。

兼容性的问题

  因此Wordpress的部分简单的插件虽然可以默认兼容到Wordpress MU,但是还要谨慎对待。如何辨别是否兼容,区分的尺度方面,比如涉及到数据库的表,文件目录的操作,由于程序结构的关系,不修改恐怕是难以兼容的。其它的无非是多查询现有的资料以及自己尝试了。

  即使功能运行正常,在比如升级、创建新用户、创建新博客时还是将插件先关闭为好,同时要注意不同插件之间冲突的可能。

July 1, 2008

升级Drupal的Localizer模块自v1.10至v3版本

Filed under: 1.2 Web开发 — Eric Tou @ 11:39 pm
Tags: , , , ,

    My site is built on Drupal 5, and enable the Localizer module to provide multilingual content
    You have another choice: Internationalization (i18n).
    On Drupal you always have different choices, turn left or turn right, it’s a problem. Localizer is just my choice after I estimate two modules according my demands.

    When I first time set up my site, latest Localizer is v1.10 for Drupal 5, it works fine, especially with the Taxonomy Menu module,  this module can automatically transform my tags into the tree menu I need, it’s the main reason I choose Localizer module because i18n does this job terrible.
     The only problem for me is the RSS feed, I was confused by how to get the separate RSS feed for each language, when you visit http://{hostname}/rss.xml, you just get the RSS feed of contents in default language.
     This article <How does RSS work on a multi-lingual site?> describe how the Localizer provide RSS feed of contents in different languages.
     >. Active “Switch by locale parameter” setting of Localizer
     >. Access the RSS feed like:
        http://{hostname}/rss.xml?locale=en
        http://{hostname}/rss.xml?locale=zh-hans
     It works in the Web Browsers (Firefox, IE), But it doesn’t work in RSS Reader (Google Reader), FeedBurner neither. I guess it’s because “?” mark in the URL.
    So, still only can get contents in default language from RSS feed. I searched a lot, but failed to find a solution.

    Recently i found Localizer module is updated to v3, Give a try to see if they resolved the problem? Why not?
    The update process it’s easy, all you have to do is follow the Readme.txt file in the package.
    This module has changed hugely, how many changes occurred? Read here
    After installed this module, go to the setting page, you will find it does change a lot.
    ‘Switch by locale parameter’ option disappeared, instead of a ‘Language prefix’ option block. I guess that’s what I want, active the ‘Automatically append language prefix to all content (node) pages’ option and save, check the RSS feed again. Now the RSS feed becomes like:
        http://{hostname}/en/rss.xml
        http://{hostname}/zh-hans/rss.xml

    Cool, but wait, Why there are Chinese contents in English RSS feed? Go back to setting page, I found the Option ‘Activate content language fallback support’ in ‘Content settings’ block (previous ‘Support for different contents types’ block) is active.
    What’s meaning of ‘language fallback’? You can find the answer in here
    That’s not what I want, so I deactivated this option. Now my site contains English and Chinese contents, I want to set English as my BASE language, it means the Chinese reader can read the English content if it doesn’t have counterpart Chinese content, but the English reader only need to access the English contents.(Many Chinese speak English, But how many foreigners can understand Chinese?)
    My previous solution is post the English content I want to display in both languages as ‘ANY’ language. Let’s test it again, create a node, Oh….h.
Where is my lovely TinyMCE button? Where is my ‘ANY’ language?
    TinyMCE problem is easy, remember the language prefix? Go to the Setting page of TinyMCE, edit the Visibility option in profile, add the language prefix, save, done.
    But without ‘ANY’ language, things become troublesome, All of my contents in ‘ANY’ language are still there, but not displayed in any language. The solution is Change it into a specific language.But, to display the content in all languages, I have to create duplicated node in every languages.

    This is life, at least it gives me a reason to expect the next release.

June 25, 2008

Drupal的Attachment与Filemanager插件

Filed under: 1.2 Web开发 — Eric Tou @ 11:16 pm
Tags: , , ,

    drupal core already provided Upload module to allow users to upload and attach files to content, but Attachment + Filemanager do a better Job.

    Attachment module is an alternative to Drupal’s included upload module. Filemanager module provides file management API for attachment module to use.
    Attachment  module uses the filemanager module to allow a unique namespace per node and support large number of files. In addition this module allows you to give each attachment a title and description.

Installation steps:

    1. Upload Filemanager and Attachment module, enable them and disable upload module.
    2. Go to /admin/settings/filemanager , specify Public/Private file system path, and create folder on the server.
    3. Go to /admin/settings/attachment , config attachment module, I didn’t check the ‘Private files’ option, I prefer to stay public.
    4. Go to /admin/content/types/[type] to enable attachments.
    5. Go to /admin/user/access , give ‘add attachments’ permission to a role you prefer.
    6. Create a node, you will see the attachments section, done.

    known issue is the module can’t be compatible with double byte character like Chinese. It will lose the file name after uploaded the file.

June 24, 2008

提交网站至Google搜索引擎

Filed under: 1.2 Web开发 — Eric Tou @ 6:31 pm
Tags: , , ,

    After you published your website, Submit your website to search engine is a good idea to help your visitor find you. Firstly, of course my favorite Google.

    Through this url, you can submit the URL of your website to Google search engine, and then the GoogleBot will index the entire website.
    But that’s not enough, Through Webmaster Tools, you can submit a XML Sitemap of your website and use tools to increase your site’s visibility on Google.
    Why? Read <What is a Sitemap file and why should I have one>

    How? Manually create a sitemap file for a dynamic cms system like drupal is impossible, a mature cms always has its solution:
XML Sitemap module (replaced the old Google Sitemap from Drupal 5), can automatically create a site map which support Google, Yahoo, Windows Live, Ask engines.

    After installed and enabled this module, fill the location of the Sitemap file in Webmaster Tools like http://{hostname}/sitemap.xml , Done.

June 23, 2008

为网站添加Google Analytics

Filed under: 1.2 Web开发 — Eric Tou @ 6:57 pm
Tags: , ,

    Want to track visitors and traffic of  your website? Try Google Analytics, It’s free, and it can do more.

Steps:
    1. Use your google account to login to Analytics
    2. Click on Add Website Profile, A form displays
    3. Select Add a Profile for a New Domain
    4. Enter the URL of your site
    5. Select your country and time zone. Click Finish
    6. Analytics provides you two code blocks (the old one urchin.js and the new one ga.js) - to add to your site’s pages.
    7. Copy the code block (ga.js) to every page you want to add Analytics as below:
    <body>
        (Google Analytics Code Block is going to go here!!!)
    </body>

    Copy and paste the code block one by one? Don’t tell me you website doesn’t have a template. Today more and more people use content management system like Drupal, Joomla, Wordpress to publish their website and blog, some Web Hosts even provide 1-click installation, and you also can find one by youself at Open Source CMS.
    Once you walk on this way, things become quite easy. Basically, there will be a module/plugin which can be easily configurated.
    For example, i am using Durpal and this site are built by Drupal, all i need to do is go to the website, find the Google Analytics module, install it, configuration, fill a Goolge Analytics account number(in the code block, UA-xxxx-x), finish. and then DONE.

    Google Analytics need 24 hours to gether data, after one day, you can read the report.

WPMU Theme pack by WPMU-DEV.