Hello everyone,

I have been playing around with Drupal for some weeks, bought 2 books and do understand how to install and use existing modules. My intention is to create my own application within Drupal to make use of it's functionality as a complete supporting framework.

First idea is a little application to display stats, which are read from a database and displayed in a table. The selection is weekly, so of course you should be able to change the date. In addition, to every item within the table there is an extra page with information, which then includes comments and so on.

So my question is: what do I have to create? A single module? Nodes? Pages? Content types? How do I deal with input parameters? I just haven't found any useful tutorial so far for explaining those elements and how to use "interactive" content (parameters). The hook documentation doesn't give an introductory start to me. Any hints? Tutorials? Sample code?

Cheers
Mike

Comments

inforeto’s picture

You may need a combination, since you can think of drupal modules as helper modules.
For example, you can use views and cck and then build a custom module to add new functionality.
Theming the functions can also be done in a custom module, using the hooks.

Performace can also be improved by moving some code into a custom module.
For example, the Views API functions are faster if running from php without invoking the gui every time.
Loading cck field values in php instead of views also helps performance.
Depending of what you want to build, this may be be easier than writing a custom module from scratch.

In the custom module, you add the blocks, admin pages and settings, node types and default views so that they run from php without too much database intervention.
You can then use the hooks to benefit from other modules or to alter queries to improve performance.

In general, try to use any existing API before building new ones.
Post issues and contributions whenever there's something that should work better or needs fixing.
After all, reusing and combining modules are one of the best features of drupal.
(personally, i moved from xoops just for this)

bluepuma’s picture

This is how I want the page to look like:

Week 26    2007-06-27 to 2007-07-01
[< Last week]      [Next week >]

      Mon    Tue    Wed    Thu    Fri    Sat    Sun
07    [a>]   [b>]   [a>]   ...
08    [b>]   [d>]   [j>]
09    [c>]   [g>]   [k>]
10    [d>]   [a>]   [d>]
11    [e>]   [h>]   [g>]
12    [f>]   [c>]   [b>]
...

Data is retrieved with queries from database and placed in a table, the letters are links to detail pages.

I need to change the week, so I have to process an input parameter somehow.

Can I do this with Views and CCK? Or should I create my own module? It there good sample code or up-to-date tutorial?

inforeto’s picture

There's many date and calendar functions to work with views and cck, but you must review them.

However, note that a good deal of power in these modules lies in the API that can be used via php.
So if you can code by all means do so, because it'd let you optimize it as much as it'd could be if it were custom code.
Besides by contributing it you'll get others to debug and troubleshoot it for you.

Make a custom module AND use themed views on it to display the table, and code your own handlers and filters if need and store the data in cck, use the available jscalendar to navigate, etc.
With basic php skills you can roll a first version in considerably less time that it'd take creating everything from scratch.

There's a good amount of sample code and performance help, and some tutorials in the handbooks.
The downside is that it'd take some time to browse the site for the pieces.
I recommend you to get familiar with all the concepts, the modules that you'll like to use and the views API.
The best thing to do it is to make a less complex view first to get the hang of it (all in php, not the ui).

bluepuma’s picture

Thanks again for your feedback, I read again through some of the drupal documentation for module creation, like How to create your own simple node type (5.x) and Creating new node types - a tutorial.

I guess what I still don't understand is the concept of nodes in Drupal. Usually a node in Drupal has a specific fixed content, be it a book page or a profile. What I want is a node/content/page with variable content, which is set by a parameter. So in my example, I want the week parameter to create the content on the fly, linking back to itself with different paramteres for different weeks instead of creating 52 nodes with the according content.

Does that make sense or is it totally against Drupal concepts? How can I realize that? Did I just miss that tiny bit of information on how to parse the request URL?

inforeto’s picture

Yes, nodes can have variable content. Just note that not all pages are nodes.
Nodes are only used to store content, but you can have other pages through url alias, modules, views, etc.

Nodes can run php, so they can have variable output.
You can have a node that works as a php script and pass the week as an argument from the query string.
In the code you can pick data from other nodes, the database, a form, a query string, etc.
It will be easy to insert views using the existing calendar views.

In this way you can do your weekly table of links without a module or template.
But since it is php you can still code it as a module and it will load from disk instead of mysql, which is a bit faster.
However, only do this if you need hooks and blocks and settings, otherwise it is an overkill.

Also note that if you use cache, you need a query string to be able to cache the different pages from the same node.

inforeto’s picture