Recently, a friend of mine contacted me regarding his Drupal website; all website contents were missing and he even could not log into the website and check the situation.
He was in a great hurry and I checked the website shortly. Except the homepage -which looked to be set on /node- every other links were not accessible.
I asked him about any change in code and settings or anything unusual. He replied that he has not changed anything; just the fact that the web server was not fully responsive at the time of problem.
It's been a long time that I want to write about Ctools. I have two good reasons: They are extremely useful -God bless Earl Miles, and it is very short on documentation.
Ctools have many tools to offer and I am going to explain some of them, one at a time. This time, I want to show you how to use Dependent tool: It make form items appear and disappear based upon the selections in another item.
When using Dependent tool, you have two kind of fields:
Field that others are depended on its value can be one of these types: Radios, Checkbox and Select. Dependent fields can be anything, even markups.
Here is an old story: How to create a node in Drupal programatically. This is my version.
First, if you have a general knowledge of a node structure, it would be much easier for you to create nodes by code. If you do not have such knowledge, don't worry; I will show you in this article.
First of all, a node is a container, containing data of your Story or Page etc. In code, it is represented as a PHP Object. All we do is creating an object and putting our data in it:
Note that if you don't set some values -Status or Promote to front page for example, they will be initialized by default values in Content type settings. If you want to overrode those values, set them as well:
Here is a good place to have a look at a node structure. When you pass your node to function node_save(), it adds the necessary values to it and then save it. This function accepts your node as a refrenced variable, therefore after saving the node, you can have a look at it and see the complete structure of your new node using functions print_f() or dpm(). function dpm() is one of many useful utility functions in module Devel. If you have not installed Devel yet, I strongly recommend that do it right now! It is a must for every Drupal developer.