Drupal: module, cck or other - drupal

I have a legacy PHP form that I'm moving over to Drupal 6. I'm trying to make things easy for me as well as the future admins of the site. The below form is the heart of the old site data. So far in cck I have Locations, in taxonomy I have Countries, now I just need to allow these Species data to be added. I would do it in CCK, but I also want to be able to add N number of Species to each form with all 12 Quadrats of % Cover and Density. (For each species in that location there is % Cover, Density, Flower, Fruit, etc ie alot of data!)
Basically my question is, can this form be accomplished in 1) CCK where the whole form can be filled out on one page, 2) by creating a custom CCK field to enter in a Species (using FormAPI) or 3) bite the bullet and write a custom module with FormAPI fields and keep track of the data in tables myself?
Thanks for your insight.

It can be helpful to think of CCK the way you would an Object Oriented challenge: what are my Things, and how do they relate to each other.
If I'm reading you correctly, you're creating some kind of Botanical Entry type. I gather that Location is set up as a separate type, and that field could be a node reference in BE. (Or perhaps it's just a list in an text field with a drop down widget.) Same thing with Transect and Station. Researchers could be a user reference field.
Then you want to add your species data (the second form). I don't really know what all those fields are for, but I'll bet that interface could be simplified. Species might be a separate CCK type, which you'd connect via node reference, or you could create a custom CCK field type. Either way, you could allow adding more than one of those to a node to get the mulitple entries. If you do the node reference approach, you could probably use http://drupal.org/project/popups_reference to make the adding easier.
HTH

Related

wordpress custom fields: structured data table

I know how to make custom fields for my custom post types. But I need a pretty complex custom field this time.
I'm making a website about agricultural machinery. There are a lot of types of machines. For every type of machine there are some products available with properties like size, mass, diameter, capacity, ....
Per type there is only one description, one title and one image needed. So my custom post-type machine contains posts (custom type = machines) with the basic information. For every machine I would like to sum up all the different size - mass - capacity - prize information in a table. I know I could just create a html table in the description, but I would really like the data to be structured so I can nicely style it, and eventually even do structured searches for price and stuff.
So ideally I would like to have a custom field that looks a bit like an excel sheet where I can create some columns and add rows per available product in the category. Any ideas how I can do this?
EDIT: I'm trying out the Types wordpress plugin http://wordpress.org/extend/plugins/types/. There's an option to group custom fields together and also an option to allow multiple instances of one field. Would be useful for me if there would be a possibility to allow multiple instances of a group. Does something like that exist?
EDIT: This looks promising. http://wp-types.com/documentation/user-guides/bulk-content-editing-with-fields-table/
I will look into it and maybe answer myself if it turns out to work :)
It seems like wp-types had the solution all along.
http://wp-types.com/documentation/user-guides/bulk-content-editing-with-fields-table/
This is what my custom data table looks like now:
Behind the scenes, all data is not actually saved in a single post. But wp-types allows you to create hierarchical relations between post types, and then provides a way to quickly create sub-posts straight from the parent. That's awesome enough for me.
In my case I created two post types. One called machine-type and another called machine.
machine-type holds all the basic information about the machine (title, description and image) while it's sub-type machine holds the specs for any of the different variants.

Drupal 7 Views : How to reuse one view for multiple fields OR how to let user select which field view displays?

My Task: I have content type which have 100+ different mostly numeric fields (big questionnaire for NGO with yearly reports). For one field I can use Views module to let user select which reports include (for example one year) and display it as nice graph (using for example Views+Charts). I would have to define about 100+ nearly identical views, which differs only by what field data they use.
My Question: Is there any way how to reuse one view definition and just change data from which field id display?
Solutions so far: I found two not really good solutions:
Create one view, export it (using Features or similar way) and then clone this export, rewrite field it uses as source and than add. But this just speed up creating one view for each 100+ fields.
Use module Views Dynamic Fields - it allows user to select which fields to display. But I would still have separate definition how to display for each field, so not much better than add one view for each 100+ fields.
I suggest writing your own Views field display plugin! This is actually all documented within the Views module folder: views/docs/views.api.php. Depending on your fields I'm not sure how you would exactly connect the data to the view.
Another alternative would be to just use a PHP Code field, and figure out a way to programmatically display the data from the field you wanted. The downside to this is that you wont be able to use that field to sort/search on with any filters as far as I know.

Drupal Views.. how to combine duplicate values and then display nodes that have that value?

I have a site where students can post their own content on it. Whenever they create content they are asked to type in their School Name. Since there will be multiple students from the same school I want to combine all of the duplicate values for the School Name field. I also want to link each School Name so it displays content from only the selected School. Is this possible? If so, how?
you really should consider using the school_name variable for a taxonomy vocabulary (http://drupal.org/node/23405), this way, the field wont be a duplicate, because it references the same term in the vocabulary.
then, when creating the content-type (or user) fields, use the 'relation to taxonomy' field option.
since it seems like you do not know all possible schools, use the tag widget.
in any case, you should think about deduplication, since this builtin method is not considering misspellings or different spellings of the same school name. (although the tag field has a autocomplete function).
a better approach is to present the user with all possible schools, however, that means you need to know all possible schools..
[EDIT] this, of course, is suggesting you are using drupal7 (or later). if not, use cck instead.
From the tags, it seems the situation is Drupal-6.
I think for you to get really good advice, we would need more information about the scope of the project and how many schools would be covered. If you are talking about a worldwide or US-wide scope, there are many schools with the same name, so you might need a school name / City combination (or something) to have a unique identifier for a school. I would suggest you have some way of selecting from a preset list, whether the project covers just a small school district, or there are thousands of schools, that way you won't have issues with duplicate "schools" created during the content creation process.
Since taxonomy terms are not fieldable entities in Drupal 6, you might want to consider creating a separate content type for schools (which would allow you to include location information, etc) and which would be represented as a node reference when students enter content that identifies a school. In Drupal 7, a vocabulary should work for the "school", since you can add fields, but there might be modules that you'd want to use which work better with nodes (a content type) than with fieldable entities (e.g. adding location data or other fields to a vocabulary).

Drupal node demystified

I'm new to Drupal, and wish to understand how this platform works.
Specifically, I'm mystified by the Node object.
What is it, how does Content-Type get in?!
It seems like the whole of Drupal is just nodes, nodes, nodes.
Would love to hear you insights.
The node, in Drupal, is an odd animal when you first encounter Drupal, but once you get it you'll find that it's quite useful.
A Drupal Node is a unit of information. Usually, it's a unit of interrelated information that for the site is not usefully divisible. For example, if you had a node that represented people and their addresses, you could split it into address nodes and people nodes and associate them, but unless you've got functionality that displays how many people are at a given address, it's not useful to split it into two nodes, and better to keep them together as one unit. Consider: If you were sorting the data out onto index cards, or pages of paper, would you list the information together, or would it be more useful to keep it apart? If together, then they probably belong together on a node.
Since most of the data on a Drupal site are nodes, it's useful to classify the nodes so you can find the ones you're interested in. One of the most basic of these classifications is the Content Type, which is basically what kind of information the node represents, and is not changeable once created. Each Content type has it's own separate form for creating and editing the node type, and represents a different type of information. Page nodes are nodes that represent static pages on your site - like an About page. A Story node represents an article or story which should show up in lists of content. A Blog node would represent a blog entry... in Drupal 6 you can create as many Content Types as you like.
Once you go beyond Content Types, there's quite a lot of different ways to classify your nodes. CCK (The Content Construction Kit) is a wildly useful one, and it's so useful that in Drupal 7 most of the functionality in CCK has been included in the core of Drupal. CCK allows you add many types of fields to a node out of the box, and then there are other modules (Filefield, Imagefield, Link, Location) that create new field types to add.
In core, another way of sorting out your nodes is the Taxonomy module, which allows you to define vocabularies of tags or terms that can be assigned to nodes. These terms can be defined by the site admins ahead of time, or they can create a 'Tag' vocabulary which allows users to create terms as they create or edit their nodes.
A node is a content container. Nearly all content in Drupal resides in nodes. Non-content data (e.g. users) does not typically reside in nodes. As most data on a website is content, nodes are a central concept in Drupal. There are several ways to assign content types to nodes, but the most common is the CCK module.

Range search based on price field in drupal

I have a CCK field price which the user can fill in. I would like to create a search form with dropdown price field with different ranges (such as below 100$, 100$-1000$, more than 1000$). The problem is that the user input is an integer so I cannot achieve range search using filter exposure. The user would have to specify the exact value to perform searching, but this is rather useless. Is there a way ( amodule, etc) to create ranges out of integer values so that the user is able to perform range based search?
Obviously people grab views and CCK for most solutions. But often a small module sith just a hook_menu(), a calback and a theme function will suffice.
In that callback you can perform whatever complex query you want.
Such modules, most of the time, contain less then 100 lines of PHP.
If you know PHP such a functionality might take you less then an hour to build. Whereas writing addons and behaviours for CCK and Views often costs much more.
The advantage of building views and CCK addons, is that your code is better re-usable.
The way I did it in the past was to use hook_form_alter to change that field to a select drop down range (a min and max drop down), then alter the views query if a value was provided.
The other way to do ranged facets would be to explore Apache Solr integration or Search Lucene facets. Keep in mind that its not exactly plug n play tech, though.
To sort out out your price into various categories you need to create a CCK Select list and then populate the list automatically using the Rules module. You need to also hide this select list using content permissions.
I've created a mini-case study on graphing using Rules & Views. As part of the mini case study, it shows you how to categorize the cost field using Rules -- which is precisely what you want. It also shows you how to hide the field using content permissions. Please check the below link for a video:
http://www.noparrots.com/content/mini-case-study-creating-a-bar-chart-in-drupal

Resources