My first post here. Any help is greatly appreciated. I am quite new to Drupal but I have plenty of PHP/mysql experience. My site contains a collection of game records for a particular game which is stored in database already. I have the following key functions in my old site:

search_by_date.php?......
search_by_player.php?...... several ways to search, all presenting a list of games
view.php?gameid=xxx to present one particular game

I've already done my homework in Drupal, including reading the "Beginning Drupal 7" book and studying online for 2 weeks. I successfully created a new module, wrote code for a couple of blocks (some including dynamic contents generated from my old database). But I have several technical questions:

(1) How to organize files in my new module. In the old CMS, I simply created multiple PHP files as shown above and created menu items as entry points to use them. I am not clear how to organize these custom PHP files in a drupal module.

(2) An individual game sounds like the concept of 'node' in Drupal. On one hand I don't want my games to be 'node' because I do not want to inherit things like 'title', 'uid', revision history, etc. that are not relevant to my data. On the other hand, I'd love to use the Drupal facilities, such as comments (allow users to comment on individual game), access control (which types of user can see which game?), and many others. So what's the best way to present my games?

(3) My final question is about filtering user input. Let's say in a forum post or a comment, my user type in text in a pre-defined data format, for example ................. I already have a PHP class to convert the data between the tags into an image so that user can virualize the data. How do I incorporate this filter in drupal?

Comments

Jaypan’s picture

(1) How to organize files in my new module. In the old CMS, I simply created multiple PHP files as shown above and created menu items as entry points to use them. I am not clear how to organize these custom PHP files in a drupal module.

Generally you won't use custom files in a Drupal module. If you really need non-Drupal files, you will create a library and use hook_libraries() to register it. But usually code needs to be re-written using Drupal hooks, it generally cannot be used as-is.

(2) An individual game sounds like the concept of 'node' in Drupal. On one hand I don't want my games to be 'node' because I do not want to inherit things like 'title', 'uid', revision history, etc. that are not relevant to my data. On the other hand, I'd love to use the Drupal facilities, such as comments (allow users to comment on individual game), access control (which types of user can see which game?), and many others. So what's the best way to present my games?

In Drupal 6, the only data type available was a node, which could then be broken down into content types. IN Drupal 7, the concept of an Entity was added. A node is a type of Drupal Entity, but you are by no means required to use these. But with so many users coming from D6, and with the Node system shipping with core, most people still do use nodes. The advantage to using nodes is that it's a developed system that has already been well tested, and there are many, many modules that integrate with the node system.

I personally don't use nodes though, unless I am creating some type of article. I create custom entities for each entity type I need. For example I've recently created a private messaging system for a client site, and I created a custom 'private message' entity type to work with this. The advantage being that the system is much more lightweight than the node system, with the disadvantage being that there are less contributed modules to use with it, and I need to write custom integration for some of the more popular modules (Views, Simpletest etc).

(3) My final question is about filtering user input. Let's say in a forum post or a comment, my user type in text in a pre-defined data format, for example ................. I already have a PHP class to convert the data between the tags into an image so that user can virualize the data. How do I incorporate this filter in drupal?

You implement hook_filter_info() and in your callback function, you can implement your class and run the text through that.

macelee’s picture

Following the advices above, I managed to build a custom module that incorporates most of the functions of my old site (using hook_menu). Everything worked brilliantly and I built 10 new pages all hooked to the menu system, until this morning - no matter what I do the 11th page does not appear. The new pages I have supposedly added also did not appear in Structure>Menu.... I know that each time I add a new menu item I need to 'clear cache'. Is there any other procedure I need to follow to make sure new pages being picked up by drupal?

macelee’s picture

The situation has become worse since my last post. I tried to disable my custom module and re-enable it. Now all custom menus I created disappear. Any one can help? Thanks in advance.

macelee’s picture

Solved the problem with the help of the logs under "Reports > Recent log messages". I turns out that I put an invalid value while creating entries for hook_menu. Because of that, Drupal generated an invalid SQL statement while building the menu, causing a rather serious-looking error like:

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value:......

Luckily I am quite familiar with SQL so I spot the problem quickly.