Making a page of questions and answers

garyo - May 17, 2009 - 03:12

[I'm posting to Theme Development because I'm not sure where this should go. Feel free to tell me where it ought to go.]

I need to make a page that contains a series of questions and answers. I'm happy writing whatever PHP & CSS code I need to. I think the way to go is to make each question/answer pair into a Node with a particular Content Type, where the title is the question and the answer is the body. (I know I can use CCK to add extra fields too.)

My question is how to make a page which aggregates and displays all of these nodes onto a single page, with my CSS theming? I have played with existing Drupal themes and am good with PHP, but am still a newbie with Drupal itself, architecturally. I don't see where in Drupal I make new page types; only content types (which I think are "nodes", i.e. chunks of content that may be displayed one at a time, multiples on a page, or not at all) -- I just don't know where the logic is that chooses how to select which nodes get onto which pages I guess. Any help appreciated!

thx,
Gary

=-=

VM - May 17, 2009 - 03:15

you may want to look into the already existing question.module and/or the faq.module w/ faq_ask.module

Thanks, I have been looking

garyo - May 17, 2009 - 03:46

Thanks, I have been looking at those, but I'd like to understand how to do it myself if I can... I'd learn more anyway!

-- Gary

To create pages with lists of

cog.rusty - May 17, 2009 - 04:45

To create pages with lists of nodes you can
- either tag the nodes with some taxonomy term, to get a taxonomy/term/[term-id] page with a node listing (you can alias this URL afterwards).
- or use the views module to generate the node listing pages, based on a taxonomy term, or based on a content type, or based on the value of some field.

Placing nodes on a page in Drupal

Drupalace - May 17, 2009 - 12:37

"I just don't know where the logic is that chooses how to select which nodes get onto which pages I guess."

What trips up some newcomers – maybe you too, maybe not, I'm not sure – is that in Drupal, you don't create a page and then decide what nodes will go on that page. Rather, you either 1) create a node, which by default gets its own path, allowing it be displayed as (part of) a page; or 2) as others noted, use Views or taxonomy terms to create logic that aggregates a number of nodes; this aggregation also gets a path, allowing the list to be displayed as (part of) a page.

Or in other words, the key process in Drupal is not creating pages per se, but creating *paths*, each of which instructs Drupal to create a page on the fly from a node and other components (header, blocks, etc.), or from a list of nodes and other components. (The front page is an exception; that's the one instance in which you do tell Drupal to place nodes on a specific page, though even there "front page" is something Drupal builds on the fly, and not a static file.)

An oversimplification, but the above thinking helped me "get" Drupal at the start. (And if it's essentially a misguided take, I welcome correction from the more experienced!)

The following links might be useful to anyone with questions like yours:
http://drupal.org/node/176252
http://www.drupalace.com/understanding_node_list_pages
http://www.drupalace.com/EDAM/placing_content

--------

Manuals, Q&A and more for the Drupal beginner

Thanks so much, Drupalace

garyo - May 17, 2009 - 15:52

Thanks so much, Drupalace (and others)! You're right I am still learning the Drupal Way. I'm not sure I still understand everything you said about paths, but indeed Views turn out to be just what I want. I can create a content type called Question, then create a View called questions that collects a bunch of nodes of type=question and outputs various fields of them in a table style. I found out how to theme them in my css by looking at the generated HTML; div.view-questions { ... } works great.

I really like how Views shows you the generated sql query; for a sql weenie like me that really makes me feel comfortable.

(I tried taxonomies for this, but I don't really understand them yet obviously because even though I made a new vocabulary and a new term, and I thought I used it on some nodes, those nodes didn't even get listed on the taxonomy/term/N page. But selecting in Views by content type is working great for me now, so I guess I don't care :-))

-- Gary

 
 

Drupal is a registered trademark of Dries Buytaert.