website-drupal

A trail of 29 pages, marked with comments, by enjoylife
About this trail:

I love the Drupal CMS. One of my favorite features of Drupal is the ability to do a multisite install. This site and my other blog, i <3 stella, are hosted on the same box, using the same Drupal install. Several sites can share one codebase. Updates are easily rolled out to every site simultaneously. Overall, it's a wonderful idea. But I have some problems with the implementation...

The standard way to set up a multisite install is to point each of the domain names at the Drupal install folder and let Drupal sort out which domain each request is coming from. It does a good job, too. But this method introduces some complications. For example, any content uploaded to site a is accessible from site b. A user that visits http://site1.com/myimage.jpg will find the same image as she finds at http://site2.com/myimage.jpg. Websites can't have domain specific .htaccess or robots.txt files either, which might hurt search engine optimization of individual sites.

An interesting side effect of this is if you want to install something in a subdirectory of your site, for example a WordPress blog at http://site1.com/blog, that exact same WordPress blog will exist in its full glory at http://site2.com/blog...

Another, and perhaps more grave, problem is that all that stands between the interweb and your very own personal settings is an .htaccess file. Install scripts, includes, site configurations and database passwords are in web accessible directories, and that is never a good thing.

We'll look at one solution to these problems.

I assume here that you are using Linux hosting, that you have shell access, and that you have at least a passing acquaintance with symlinks. If you're looking for a webhost that meets these requirements, check out 1and1 shared hosting. I've been happy with them, and all of their packages above $9.99/mo will do what you need.

Microsoft/IIS guys, you can't do a symlink. You're looking for something called a junction... good luck with that.

29 marks in this trail
1

I love the Drupal CMS. One of my favorite features of Drupal is the ability to do a multisite install. This site and my other blog, i <3 stella, are hosted on the same box, using the same Drupal install. Several sites can share one codebase. Updates are easily rolled out to every site simultaneously. Overall, it's a wonderful idea. But I have some problems with the implementation...

The standard way to set up a multisite install is to point each of the domain names at the Drupal install folder and let Drupal sort out which domain each request is coming from. It does a good job, too. But this method introduces some complications. For example, any content uploaded to site a is accessible from site b. A user that visits http://site1.com/myimage.jpg will find the same image as she finds at http://site2.com/myimage.jpg. Websites can't have domain specific .htaccess or robots.txt files either, which might hurt search engine optimization of individual sites.

An interesting side effect of this is if you want to install something in a subdirectory of your site, for example a WordPress blog at http://site1.com/blog, that exact same WordPress blog will exist in its full glory at http://site2.com/blog...

Another, and perhaps more grave, problem is that all that stands between the interweb and your very own personal settings is an .htaccess file. Install scripts, includes, site configurations and database passwords are in web accessible directories, and that is never a good thing.

We'll look at one solution to these problems.

I assume here that you are using Linux hosting, that you have shell access, and that you have at least a passing acquaintance with symlinks. If you're looking for a webhost that meets these requirements, check out 1and1 shared hosting. I've been happy with them, and all of their packages above $9.99/mo will do what you need.

Microsoft/IIS guys, you can't do a symlink. You're looking for something called a junction... good luck with that.

2
adding the php.ini but removing them from the .htaccess resolved that problem.  Which led me to...

Since LP is php 4 and apache 1 I tried removing these 4 lines from the .htaccess

php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value memory_limit          12M
  php_value session.auto_start              0

and adding these 4 lines to my new php.ini

magic_quotes_gpc = 0
register_globals = 0
memory_limit = 12m
session.auto_start = 0

still I can't upload files and I haven't even looked at the clean url thing yet.  So hopefully this will get answered and spare you the same tireless hours of fiddling.

oh btw setting up the db and installing drupal was a breeze.  had it all done inside an hour.
3

Code snippet: How to set the disabled attribute of a CCK field

Last modified: January 11, 2009 - 10:41

Here's a code snippet that you can use to set the disabled attribute of a CCK field.

First, you need to create a small module containing the following code:

/**
* @file
* Custom module to set the disabled attribute of CCK fields.
*/

/**
* Implementation of hook_form_alter().
*/
function mysnippet_form_alter(&$form, $form_state, $form_id) {
  if (isset(
$form['type']) && isset($form['#node'])) {
   
// Use this check to match node edit form for a particular content type.
   
if ('mytype_node_form' == $form_id) {
     
$form['#after_build'][] = '_mysnippet_after_build';
    }
   
// Use this check to match node edit form for any content type.
//    if ($form['type']['#value'] .'_node_form' == $form_id) {
//      $form['#after_build'][] = '_mysnippet_after_build';
//    }
 
}
}

/**
* Custom after_build callback handler.
*/
function _mysnippet_after_build($form, &$form_state) {
 
// Use this one if the field is placed on top of the form.
 
_mysnippet_fix_disabled($form['field_myfield']);
 
// Use this one if the field is placed inside a fieldgroup.
//  _mysnippet_fix_disabled($form['group_mygroup']['field_myfield']);
 
return $form;
}

/**
* Recursively set the disabled attribute of a CCK field
* and all its dependent FAPI elements.
*/
function _mysnippet_fix_disabled(&$elements) {
  foreach (
element_children($elements) as $key) {
    if (isset(
$elements[$key]) && $elements[$key]) {

     
// Recurse through all children elements.
     
_mysnippet_fix_disabled($elements[$key]);
    }
  }

  if (!isset(
$elements['#attributes'])) {
   
$elements['#attributes'] = array();
  }
 
$elements['#attributes']['disabled'] = 'disabled';
}
?>

Explanation:

Setting the #disabled attribute of the element in form_alter doesn't work because the FAPI process handler of the CCK field won't transfer the #disabled attribute to its children elements. So we need to find a different method...

We can do this using our own #after_build handler, but here we cannot simple set the $element['#disabled'] attribute of the element. The reason is this attribute is transformed into $element['#attributes']['disabled'] by _form_builder_handle_input_element executes(), which is the format FAPI theme functions know about. However, _form_builder_handle_input_element executes() is executed before #after_build handlers are invoked, so our own handler needs to set the value as the theme functions expect. See form_builder().

Finally, we need to use a recursive function so that we can set the disabled attribute of all the FAPI elements that depend on the CCK field we're interested in. Think for example about a checkboxes element, etc.

4
Part 8: Enhancing the form with Javascript, AJAX

We can think of more ideas to enhance the form.

For example, we can save the user clicking the "Update location field" button by... clicking it for him. We do this by attaching an onchange event handler to the 'country' and 'state' fields. This onchange handler would automatically click the button for the user. Furthermore, the user don't even have to see this button, so we can hide it (hide it via Javascript so in case no Javascript support is there the user can still access the button).

That was one idea.

But we have another idea, a marvelous one with chocolate on top:

We don't like the way all the page gets refreshed when this button is clicked. Why don't we channel the response from the server into a hidden frame (IFRAME), load this textual response from here into a Javascript variable and finally replace only the "Location" fieldset the user sees on screen with this response? This would have a pleasant visual effect: the user would feel he never

9
Drupal v5.12 CCK node reference modify a named field


Hi this is actually a very simple solution.  You just need to forget about Drupal, CCK etc, and focus on the jQuery because all you need is some JavaScript to populate the relevant fields with the data which I assume you can already get.

There's a great page here, and the Simple tab has a demo: http://www.keyframesandcode.com/resources/javascript/jQuery/demos/populate-demo.html
10

It is still possible to execute shell code without shell access. To execute shell code in Drupal, simply create a PHP page with the following and execute it from your root Drupal directory:

print `ln -s /root_path/public_html/ /root_path/public_html/newsite`; ?> 

11

Drupal Internationalization: Part I, and introduction

Ethan's picture
Tags: 

We've recently begun putting together the infrastructure for a number of upcoming projects which will organize people around the world toward some pretty powerful, ambitious goals. While the details of those sites are still in the works, working with Drupal to create multi-language sites has been a great experience involving a great deal of learning. This is the first of a two part series covering how Drupal works with multiple languages and the best practices/tricks of the trade for making the most of the Drupal Local, i18n and L10n systems.

12

上圖顯示了一個經過修改的 user page 的 tabs

tabs 其實來自一個 hook(), menu_local_tasks()
用 theme developer 指一下便可以看到
但這次介紹的並不是要修改這個 hook 的 theme template
而是使用 views, 新增一個tab 到這個地方

在上圖的例子,
一個 url 為 [root]/user 的 頁面,
要在 views 建立一個的 tab,

  1. 建立一個 page views
  2. 正常的輸入所需的資料 (sort, filter.....)
  3. page 的 path 要設定為 user/%/[joe] ([joe]為任何值)
  4. 在 page 的參數選項之中, 有一個 men
13

log4drupal - a logging api for drupal

if your career as a developer has included a stay in the j2ee world, then when you arrived at drupal one of your initial questions was "where's the log file?". eventually, someone told you about the watchdog table. you decided to try that for about five minutes, and then were reduced to using a combination of

 and print_r to scrawl debug data across your web browser.

when you tired of that, you learned a little php, did a little web research and discovered the PEAR log package and debug_backtrace(). the former is comfortably reminiscent of good old log4j and the latter finally gave you the stacktrace you'd been yearning for. still, separately, neither gave you quite what you were looking for : a log file in which every entry includes the filename and line number from which the log message originated. put them together though, and you've got log4drupal
log4drupal is a simple api that writes messages to a log file. each message is tagged with a particular log priority level (debug, info, warn, error or em
14

One of the powerful features in Drupal is the node_access system. This is an API within Drupal which allows modules to do fine grained access access contol to individual nodes.

If you are using Drupal core, this system does nothing. You need to either enable one of the many node access modules, or write your own module to do that.

Writing a simple specialized node access module is what this article covers.

Privacy for resumes

The resume_access module is part of the Drupal jobsearch module, which 2bits wrote. In a nutshell, the jobsearch modules allows you to define one or more content types to be job postings (openings, contracts, ...etc), and one or more to be resumes (CVs for those across the pond). Then for the job postings, there is an "apply" link that prompts job candidates to apply to the job.

One request is to make resumes private so job applicants cannot see other job applicants' resumes.

The module we are discussing today is called resume_access, and it does this by using the node_access system.

First we define a permission called "view resumes". Under Roles, you select one or more roles that has the right to see resumes, for example employers, recruiters, ...etc.

15

Drupal Code Search helps you find Drupal code easier!

  • Search source code from thousands of Drupal modules and themes.
  • Use the power of regular expressions to find exactly what you need.
  • Easily restrict results to specific Drupal versions and programming languages.
  • Results provided by the Google Code Search API.

Search Examples

16

to custom-theme a node type

Monday, October 23rd, 2006

make a template called “node-type.tpl.php”. for cck circa aug 2006, this is ‘node-content_cust_content_name.tpl.php’. then put this in to find out what info is available:

gleaned from creating a template handbook.

views module patch

Monday, October 23rd, 2006
17

This is a collection of useful links on debugging, tracing, and profiling Drupal.

Got a good article about debugging Drupal or hints and tips on that? Post it as a comment below

18

However, there are sometimes side effects to enabling the devel module on 4.6 and 4.7, that may manifest itself in certain situations. For example, showing errors on the screen directly.

If you want the timer functionality without the full devel, here is a tiny module that displays the timer at the bottom of every page.

To configure it, you have to add the following to the bottom of your settings.php file.

19
But after copying CCK's content-field.tpl.php into my theme and renaming it I couldn't seem to get the theme to pick it up. Roger López gave me the frustratingly simple answer on irc: "i think you need to have both templates in place"... duh. Copied content-field.tpl.php into my theme and everything worked great.
23

http://www.comeongame.com/ english game site, online games, flash games
其实我不知道用drupal是否适合设计这样的站,但是用drupal已经习惯了,就设计个,不会php, 虽然难了点,但还是被他强大的灵活性所吸引,欲罢不能...
这次我用了6.x设计我的game搜集站,主要是因为image field可以有link to node,并且图片和swf文件的上传都采用 用户ID/年月...这个方式,避免了大量文件都传到一个文件夹下的情况.... 以后站大了,这样做文件管理也好些... 这次是5.7版的comeongame(www.greenidea.net)的升级。。。
第一:主题设计
关于主题设计主要是采用了复写,在这里感谢drupaluser.cn提供给我的帮助,使我终于脱离了panels模块, 可以随意设计自己的排版!
page-front.tpl.php 复写首页
page-taxonomy.tpl.php 复写列表页
page-flashnode.tpl.php 和 node-flashnode.tpl.php 复写flash内页
复写page-flashnode.tpl.php注意....直接复写并不会成功,参照http://drupaluser.cn/html/mytheme/2009-01-01/332.html

这里主要是采用drupal的复写机制... 首先在.info文件里面建立自己的region, like this:
regions[left] = Left sidebar
regions[right] = Right sidebar
regions[content] = Content
regions[header] = Header
regions[footer] = Footer
然后你可以用css+div写自己的模板,将regins放在你想放的地方... regions不能放在node上... 如果想法似乎要搞template.php,我也尝试过,成功了!

关于flash游戏页面的设计,$content变量被我具体化成很多变量,主要是我想按照自己的div排版安排位置...这里我主要用content templete去找变量...然后同样道理用div+css结合变量去设计layout....这样可以方便随意设计出自己的排版.....为了有很好的seo, mate keywords和desciption部分我也加入了部分变量输出.....

第二:模块的使用
因为我的站是flash小游戏搜集站,所以主要依靠flash node的功能.....输出用view2+cck, 然后还有投票的功能我用了vote up and down....你也需要cck的image field去输出游戏的截图, 用pathauto去定义了下node的url,形式是...../分类名/文章标题,分类用 Taxonomy

主要有6大类,分别在首页输出block,关于view2的主题制作也是复写....用css+div控制下就可以了

大概就是这么个流程.... 希望高手指点....

24

有很多朋友拿到了我的主题,启用以后却发现和我的主题有很多差别,这是因为我的主题是定制的,
不像drupal官方提供的那样拿过来就能直接用,区块的位置和我的后台设置的不一样的话,样式都会乱
所以我在这里只是提供一个制作方法;

在第一部分当中,我已经介绍过了,Drupal使用者中文社区[ http://drupaluser.cn ]的tpl文件主要是以下几个

首页我们使用page-front.tpl.php文件覆写
列表页面我们使用page-taxonomy.tpl.php文件覆写
内容显示我们使用page-story.tpl.php和 node-story.tpl.php来覆写
其他的静态页面我们使用page-page.tpl.php和node-page.tpl.php来覆写

其中page-story.tpl.php 和page-page.tpl.php不是默认就会起作用,比较常见的有两种方法可以让他起作用,

一种是drupal的风格,在template.php中覆写函数实现,这种方法老葛的zhupou上面有介绍,在此不再赘述了
另一种是比较容易理解的风格,可以在page.tpl.php上面写一个判断,让他根据内容类型自己选择模板文件,
如以下写法:

25

最近在盤算在兩個freelance 之間擠出些時間做一個全新的theme
碰巧又沒有什麼特別的題目或教學
所以發表些我定制這個theme 時的一些小技巧
(這些小技巧不一定會出現在未完成的這個theme 內)

比如說我要在 "Read more" "Add new comment" 之前加個可愛的icon

但因為"Read more" 和 "Add new comment" 畏使用不同的icon (當然吧)
所以要看看從css 上它們的class 或 id 值有否特定
才可以用css 定制不同的icon
如不, 可能要hack 核心或使用js 來忙了

26

Check out Zucker's post entitled " Sorry I didn't respond sooner" at http://drupal.org/node/23991. Let me know if this answers your question.

28

Drupal Tutorials

<!-- google_ad_client = "pub-0289052664169907"; google_ad_width = 468; google_ad_height = 60; google_ad_format = "468x60_as"; google_ad_type = "text_image"; //2007-10-15: TIPS-banner-top-rounded google_ad_channel = "8580387666"; google_color_border = "FFFFFF"; google_color_bg = "FFFFFF"; google_color_link = "0000FF"; google_color_text = "333333"; google_color_url = "CCCCCC"; google_ui_features = "rc:10"; //-->
Tags:

This section of the site contains Drupal tutorials. When browsing the Drupal-specific areas of this site, look for the Drupal tutorials menu that appears on the left sidebar. The list of tutorials is also listed below.


Add your comment: