Finding information about fields in Drupal Views - drupal

I have a node type with multiple file attachments and would like a node view to show the latest file attached to the node.
In Views, I have options to sort by node:updated or revision:vid, but of course they don't tell me which file was added last. Is there a way to sort by the updated time of a field?
And, more generally, is there a way to find information about changes to parts of a node.

There is no revision records for individual CCK fields that I've ever heard of. I think I saw a blog entry about someone thinking of writing a module for it.
Here's how you get the file upload date into a View:
Create a Relationship with the particular FileField you are interested in.
In Fields there will now be a File category. It includes File Upload Date.
In Sort criteria there is also a File Upload Date.
If you also restrict your View to a single node, that should do it.

Related

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 data entry forms & db structure?

I'm trying to build a Drupal site in which users can input records containing data about "customers", "employees" and "sales".
I would like to be able to create a form(s) which takes data about a sale/customer/employee and can be associated with a record of a customer/employee(who made the sale)/sale.
I would also like to be able to display records showing a list of sales or customers or employees in which when clicking one record, it will open a page displaying all the relational data.
I'm new to development and am searching around like a headless chicken lol. I was thinking of using content types for sales/employees/customers and using individual nodes for each record then using something like views to displays filtered lists, but I am unsure if this is the best way to go about/structure it (maybe I should use separate custom tables or database and use a custom module to fetch the data?). It would also be nice if some of the fields can populate other fields based on it input and also if some fields can utilize a sort of auto-complete by garbing data from other records, or is that asking way too much?
Thank you for any suggestions you might be able to give me.
I, for one, would certainly prefer using a custom separate database and leave drupal databases to its own devices, if you would ever need to upgrade the site to a higher version of drupal it helps if you don't modify it, and also consider using webform (http://drupal.org/project/webform) as it makes development easier both in components and hooks.

Global data in drupal 7

I'm building one village's official site in Drupal 7. I need to create and store some information about village that will be accessible everywhere on the website (e.g. village's name, mayor's name, phone number, email, etc.). I want to define them in the admin site and access them in any node (e.g. all the data will be shown in the section about municipal office and some of them like phone number mentioned in the contact section. What is the best way to do that? Is there some module to handle that? Or should I write the own one? I have tried to search the answer there, but I found only topics about global variables (in PHP).
You can use the functions variable_get() and variable_set() to store arbitrary information that is available on all pages. It is easy to write a form that automatically saves all form fields with variable_set(), see http://drupal.org/node/222158.
Note:
- Saving variables with variable_set() will clear the cache of all variables, you should not use it for information that changes regularly.
- All variables are cached in a single, global cached and fetched on every single page request. You shouldn't store large amounts of data or data that is only used very seldomly.
The answer by Berdir is already very good in case you only want to store the raw data. However, if you always want to display the data in the same way like in some kind of widget format, you have other options, too.
For example, you could create a block with the contact details and you only show it on specific pages.
If you need more flexibility, you might consider to write a small module with different theming functions. You would either store the data directly in the module or in the variable table as outlined by Berdir.
In any case, if you want to allow the user to change this data on his own, you will probably need to write a small form in the backend. Otherwise, the user will need to manipulate the database directly to change the data.
You could also consider Creating advanced theme settings.
See how you can specify the site's logo path in your theme? You could do something similar with the info you would like to display on your site, practically setting up your theme as a template for a village website.
You get to add custom fields in your theme admin settings, field values can then be retrieved by using theme_get_setting()

Searching through Sheetnode data in Drupal

I'm using Sheetnode -- http://drupal.org/project/sheetnode -- to upload a big spreadsheet full of property data for a real estate tool I'm working on.
I've successfully uploaded all my spreadsheets; what I'm stuck on is creating the view (I'm very unfamiliar with the Views module).
Is there any way I can use Views to search through a particular column of Sheetnode data, i.e., how do I query a particular column and return results meeting a particular condition?
Sheetnode integrates with core Search, so cell content is indexed as part of node indexing. If you use the "Search: Search Terms" exposed filter, you will be able to search trough spreadsheet content. But you can't specify to only search through a particular column.
Add the fields you want to query as filters, you can then expose these fields creating a search form for your view.

Multiple content creation on a single page in Drupal

I want to allow the user to create 10 content nodes on a single page instead of clicking on "add a new node each" time. This is just to save the users time when he/she wants to create 80 nodes at one time.
Is there any such module which supports this functionality or will I need to write a module for my own?
The first module I can think of (reading your description) is Nodes, which is described using the following text:
The Nodes module allows a user to edit multiple nodes at once. The module provides a simple table layout, similar to Editview, so that multiple nodes can be seen at once, and quickly and easily edited.
Changes to a node are done using AJAX like calls, so that as each field is edited, it is changed on the live version of the node. This means that any edits that take place are not submitted in bulk, and therefore any problems that arise as editing takes place can be dealt with on a field by field basis.
Unfortunately, the project doesn't have any public release.
Editview, referred in the description, is a Views plugin that allows to create a view where all the listed nodes are editable.
Other modules you can find on drupal.org are:
Mass Content Creator
Node Repeat, which allows to create duplicates/clones of nodes
Multiple Node Add
Slickgrid can be used for this purpose.

Resources