3

For example I have a database table defined from the following SQL.

CREATE TABLE IF NOT EXISTS `mytable` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `base_id` int(11) NOT NULL,
  `page_type` smallint(4) NOT NULL,
  `page_title` varchar(50) NOT NULL,
  `page_content` text NOT NULL,
  `previous_id` int(11) NOT NULL,
  `next_positive_id` int(11) NOT NULL,
  `next_negative_id` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;  

I need to create nodes/content by using records inside that table. For example I have a base node, its id is 1. I get its title and its content from mytable. Inside this page I ask a question: "Do you like cats?" If the user selects yes, I send him to sub-node. I get sub-node address, title and content from mytable. You can see the flow like the below. Until the latest sub-node I give options to user. He selects YES or NO and sees relevant content/sub-node.

How can I make it with a Drupal 7 site?
I have another Drupal website but I have never used such complex flow. I created nodes and used contributed modules. Is it so hard to make this flow? Which modules should I use to setup such hierarchy and content management?

working flow

4

One solution would be to create a new content-type, let's call it Question-Page and the install Entity Reference, which provides a field type that can reference other nodes. Then you could add three new fields for previous_id, next_positive_id and next_negative_id.

Custom content-type

To import the data from your table I think you could use the Feeds module. First create one importer that will create the actual nodes. Second an importer that will update each node and set the node reference fields.

  1. First importer that will only create all nodes.

First Feeds Importer

  1. Second importer, that will setup the reference fields.

Second Feeds Importer

|improve this answer|||||
  • I just tried it and it seems to work just fine. – Cyclonecode Dec 14 '12 at 1:39
  • Thank you. I'm trying your solution. I stopped in "Feeds importers/Mapping for Node processor" step. Can feeds module import database tables or should I create a CVS file to use feeds importer? – trante Dec 14 '12 at 22:30
  • You should create a csv file to use with the importer. The GUID field is a unique field used by feeds you could fill in any value you like - just make sure that it's unique. You should also turn off periodical updates for your importers and set the content-type under processor settings. – Cyclonecode Dec 14 '12 at 22:33
  • Oh, you should also change the parser to CSV parser. – Cyclonecode Dec 14 '12 at 22:47
  • Let me know if you run in to problems, I can try to help you over the chat. – Cyclonecode Dec 14 '12 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.