Create a simple "Yahoo Answers" kind of site (D6 or D5), no code, no modules required (optional though)

Okay, i'm doing this in d6, but this should really be no different for d5. My requirement: i needed to have a question and answer site for a local community of users and i wanted to have it feel kind of like "yahoo answers" in terms of browsing questions by category, allowing anybody to answer and so on.

...and i didn't feel like touching any code, modules, any of that stuff to do it!

Please note: this is very different from the very excellent solution to creating an "Ask the Expert" site resolved by the "ask the expert module" (see http://drupal.org/node/191881 for more) - this didn't work for me because i wanted *anybody* to answer *any question*

This is targeted at **Very new to drupal** types who are just getting their arms around Drupal - so some of this might seem rather intuitive to experienced users. Really, this is a "workflow" solution - an elegant way to get drupal to do what you want without hacking it up.

First step: goto admin/content management/contenttypes and create a new content type - let's call it "Ask a Question" (in the 'name field') and then in the "machine-readable field name" put something simple but unique, like "questions" (this may show up in your address bar depending on your configuration, so that's a nice little bonus)

Important step: in the "Submission Form Settings" give the "Title" field a catchy title like "Your Question" - note: this field can hold roughly 30-40 words, an important element in this "Yahoo Answers style site" we're building (on my site, that field is actually called, "Your question - don't worry, this little field can hold about 30+ words" - because it appears to all users, seems silly, but whatever, it works)

in the same submission form settings, leave the "Body" completely blank! Make sure it is empty and it will not appear - this is important to achieve this 'look and feel' that we're going after. this forces users to keep questions reasonably brief, and if they want to elaborate then they can simply comment on their own questions (most will not btw, strange effect of restrictive interface options, cool huh? - makes 'em WAY easier to follow and read for site users)

Now, in comment settings, pick your configuration: i suggest (for this kind of site) leaving the defaults in place BUT make sure that "comment subject field" is disabled (it's kind of redundant i think, but if you want to leave it there then go nuts) and for "location of comment form" leave it on the same page (not a new page) - you want people to feel like they're looking at a question AND can type the answer on the same page, so that's important. Also, you should make sure that "Oldest first" is the ordering - because question authors may ammend their question with details, images, other things (depending on what you allow - like uploads)

Okay, so click save and now let's move on to the 'vocabulary'

go to admin/content management/taxonomy

add a vocabulary called "Question Category" (you want to be able to easily recognize it yourself, as site admin)

in "content types" section select ONLY "Ask a Question" (you created this before, so if it's not there then you did not click save ;)

in "settings" section, select ONLY "required" (do not select 'freetagging' - i'll touch on this shortly)

now click save and go back to that top level: content management/taxonomy - do you see your new vocabulary called "Question Category" under name, with "Ask a Question" under type? good...

now click "add terms" (for "Question Category") and in a separate browser window, open up yahoo answers and then copy every single term and save each, one at a time (oh, i'm just kidding, sort of....you are going to need a bunch of categories for your site - so if it's computers, you've got: laptops, desktops, and so on - but choose carefully young skywalker, you do not want users encountering a drop down menu that goes off the screen)

IF you want to have "multiple" vocabularies associated with your questions, then simply repeat the above steps to create another vocabulary for content type "Ask a Question" - why might one do this? perhaps you've got people selecting "type of computer" (laptop, desktop) and "operating system" (mac, linux, etc) and "brand" and so on..and you want those to all be required, separately, because you'll want people to browse around by those separate things...

...but dave, i want users to be able to add cool web 2.0 style tags to questions! how can i do that? everybody else is doing it!

(for TAGS) ...you simply go to the default "Tags" vocabulary (in admin/content management/taxonomy - in drupal6 this is there by default, not sure about d5) and enable it for "Ask a Question" under content types - if you do this, then users will see the "required category selection box" that you created when you added those terms above into the "Question Category" vocabulary and they'll also see a "freetagging" box where they can put random tags like "sucky computers" or "blue screen" and so on...

WOW! you're almost all done. can you believe it? all you did was add ONE content type and ONE vocabulary and soon microsoft will be beating down your door as they expand their internet acquisition spree...or yahoo will call and be all like, "dude, where did you get those question categories?"...no modules, no code, nothing but core drupal!

okay, you're all done with the "work part" - but now you need to do a few things:

go to admin/user management/user permissions - you'll see that your new content type "Ask a Question" is inside the the "Node module" section of that page - **make sure** that authenticated/anonymous/other user types can access content AND "create questions content" (remember, "questions" is the 'machine readable' name for "ask a question" content type)

on sites running Drupal 6, do NOT let users have "delete questions" permission - if you do, then all comments will be lost and screwy! let 'em edit, but deleting is dangerous in a Q&A style site! on sites running Drupal 5, you only have create, edit and edit own permissions, so be sure to only allow the "create questions" permission.

go to admin/site building/menus and select "navigation" - you'll see a section called "create content" and in there you can edit what the "ask a question" text will look like for your users (e.g. change it to "Ask a Question" - duh)

want to add it to your big "primary links" up top like on yahoo answers? then remember - machine readable name is "questions" so:

go to admin/sitebuilding/menus and select "primary links" and click "add item" - in the path line, put: node/add/questions (just like that, no "http" part, no / before node, just the relative url in your drupal install) - and give it a catchy title like "Ask a Question" - now when a user clicks that link he/she will be brought **directly** to the 'ask a question content creation type'

so, uh, what have i done exactly? what's gonna happen for site users asking questions?

here's what's going to happen: site user clicks "ask a question" and sees only a single line for text - no big 'body' box - he types up 30 or 40 words (more than enough for most questions, correct me if i'm wrong)

also sees a required 'drop down' box listing all of the question categories, picks one, clicks submit (unless you've also added 'tags' and the user adds some tags too)

...but dave, is that it? can i make it fancier with code and modules? i'm all about fancy...plus what will users see when they're trying to look at all of the questions? you totally skipped that part, the part where users look at all the questions so they can answer them, y'know? where is it?

here are a few ideas, things i'm actually doing:

for fanciness: the amazing image taxonomy module (wahoo, peace out) at http://drupal.org/project/taxonomy_image - what's it do? it lets you add a little image for each term in your vocabulary. for example, youve got a little 'laptop icon' and it appears next to all questions in the category term 'laptop' (you can do much more with it too, like only show on full pages and not 'teasers' and so on - check it out!)

for viewing questions - a simple menu item linking to a page that shows all questions from all 'terms' in the vocabulary: remember above when you added "ask a question" to the "primary links" for your site? well, go on back there and add a new item, but this time call it "Answer Questions" or something like that...in the path line, put (without http or /): taxonomy/term/13+14+15 [one number + the next number for each of your taxonomy terms]

huh? 13+14? what are those numbers? you lost me

sorry...open a new tab, go to admin/content management/taxonomy - look at "Question Category" and see where it says "list terms"? click that. in the "operations" column, where it says "edit" simply mouse-over each term's 'edit' link (don't click it) and you'll see some long url, but early on it will say something like admin/content/taxonomy/edit/term/34.... - you just want that number. get all of the numbers for all of the terms and you're going to replace 13+14+15 with whatever they are - you may have five numbers, twenty, just put 'em all in there, one number + the next one...

click save. click that 'primary link' way up top and voila, you'll see all of the teasers for every question - BUT what's awesome is that because there's no 'body' in the content type "Ask a Question," what your users really see is just a list of questions auto-formatted in the font and header size used for titles...cool, huh? (with tags and so on, whatever shows in your theme's teaser style)

...but dave, at the top of that same page i just created it's listing every term and that is crazy ugly! it looks dumb - will people think i'm dumb?

you're right, that is ugly. so since i'm trying to show you how to do this without views (you know, that "views module" that people always talk about?), you're going to want a page snippet. but that's sorta another whole "site recipe" and it's already been covered before by many drupal users...check out the "php page snippets" in the drupal handbook.

come on dude, just give me the snippet that you're using on your site to show all of the questions on one page that gets linked to from the primary menu...

okay, for my site, on DRUPAL 6 - i create a page called "All Questions" and used this code (after enabling 'php module' and selecting 'php' as input type) - created for me (actually a sort of repair of some old drupal site code) by zetazoo - http://drupal.org/user/138528 :

<?php
  $vid
= 5;         // <---- put correct vocabulary ID here
 
$terms = taxonomy_get_tree($vid);
 
$tids = array();

  foreach (
$terms as $term) {
   
$tids[] = $term->tid;
  }
 
// Note: the number of nodes selected is controlled by 'feed_default_items' from the RSS publishing settings page.

 
$result = taxonomy_select_nodes($tids, 'or', 0, FALSE, 'n.sticky DESC, n.created DESC');
  echo
"\n<ul>";
  while (
$node = db_fetch_object($result)) {
    echo
"\n<li>". node_view(node_load($node->nid), TRUE, FALSE, FALSE) .'</li>';
  }
  echo
'</ul>';
?>

...to show the page, i just did that whole admin/...menu - add primary link - put the path to the page created immediately above and voila, there it is.

...to get that "vocabulary ID" i went back to admin/content management/taxonomy and simply 'moused over' the "question category" vocabulary's "edit" button and saw the "number" in the url (as opposed to the thing we did for 'each term' in the same area of the site earlier)

...um, dave, dude, you said 'without code' way up top - isn't that code?

oh, yeah, it is. whatever. it actually says "optional"....and there's so much more you can do with BLOCK SNIPPETS (in handbook) like:
show a list of all of the question categories in a block and have them link through to the page for just those questions, show the same list, but with a count of the total number of questions, other stuff - look at the handbook!

hope this helped at least one person...

 
 

Drupal is a registered trademark of Dries Buytaert.