How can a user choose items from a view? - drupal

I've 3 types of users:
Author
Reader
Site Admin
What I've done so far?:
I've created Content Type named Book. Authorscreate account on my site & login & then add the information about the books they authored. I've a View with page-display named books which lists all the books which can be seen even by Anonymous user.
What do I need?
Reader should be able to pick 'x' no. of books from the this view. The no. of books a Reader can pick depends on his level Voracious Reader, Moderate Reader, Occasional Reader.
After Reader choosing Book(s), Site Admin will be see the list of books picked by all Readers.
He'll then ship the book to their address (offline) & update the status as "Shipped".
of course Readers should be able to see the list of all the books they've chosen along with its status.
How do I accomplish the rest?

Install the field collection module.
Create a new field_collection field on the user profile called "ordered books".
Edit your "ordered books" field collection and add 2 fields:
1 called book - this will be an entity reference to your books
content type. You will need the entity reference module for
this.
1 called status. This can be a list with values of "ordered" and
"sent".
Now when users edit their profile then can select which books they want.
You will need to disable the status field at this point to lock it to ordered. (Use hook_form_alter).
Then also using hook_form_alter in a custom module add some extra validation to the user profile form.
In your new validation function check what sort of user is submitting the form (Voracious, Moderate or Occasional) and how many books they have selected and raise any errors as appropriate.
When a user looks back at their profile they will see a list of books and their statuses.
You may want to look into creating a new node type called "orders" or something. This could have an entity reference to the user, and entity references to books. That way you could have a status for the order a a whole as well as the separate books, but this is just an idea - you may not need it.

Related

WP: Best approach to to link a post to a person

I think this question is common, but I dont find a final solution.
Lets say I have a post type "event", what is the best approach to link a certain post to a certain person (speaker).
at the end i need a list of all speakers (alphabetical, according to their lastname) and of course the information of the speaker in a list of posts and single post view.
The speaker needs 4 data-fields: firstname, lastname, short-bio, weblink.
For a single event the amount of speker could be 1 ore many.
As far as I consider there a three different approaches to do this:
Custom fields
All needed custom fields are added directly to the cpt "events" using for example an acf repeater field.
the fields are blank textfields but a jquery ui script is providing an autocompleate feature with all values from the database (all firstnames, lastnames…)
Disadvantages from my perspektive: not so easy to query (especially when i have more than one speaker). The information about one certain speaker needed to give for every events.
Advantage: all information about a certain event, including the information about the speaker are editable on one page in the backend.
Posttype: "Speaker"
A second posttype named "speaker" will store all the infos about one speaker. An event could be related to one ore many speakers, for example by using the acf relationship field.
Disadvantages: all the information about the speaker are to be edit on another page in the backend. The user has first to create a speaker and second link this speaker to an event.
- question: is it possible, to include a second posttype into the backend of another posttype? For example by providing the possibility to create a new speaker inside the backend of the poststype "events"?
advantages: easy to query, easy to link a event to many speaker
Custom Taxonomy
I never tried this but maybe it is a good idea if possible.
The user can choose, add and edit a custom taxonomy providing all the informations (name, firstname, bio etc).
Is it possible to use more than one field for a custom taxonomy directly in the edit post view?
Maybe there is a final answer for this question?
I don't think their is a best approach, it depends on your need and your information architecture.
For example I may have a archive page of all speakers, so I can list all speakers and I can display the speaker's detail through the url http://mysite/speaker/ucheng. In this condition, I would prefer the post type solution.
Another Solution: Speaker User Role
What if you allow the speaker to edit their profile or upload some material for the event? If you want to do this, use default WordPress User and create a speaker role for it, so you can do some access control. Also, I can list the speakers on the frontend, and link the user to the event by using ACF.
For me, I would prefer the user role solution.

Are Dexterity z3c relations between non-cataloged content possible?

Specifically, I want to be able to use Dexterity content that has a z3c relationfield pointing to a user in acl_users.source_users. The Plone documentation demonstrates how to create relations in the schema using plone.formwidget.contenttree, but the binders all seem to be based on catalog searches. Since users aren't content in this sense they aren't cataloged.
I'm not sure if this is even the best approach, but being able to link to a user seems simple as an abstract concept. I suppose the alternative would be to store the userid as a simple string field and listen for user management events.
There are two possible approaches:
(1) low-level indexing of relationships between content and users, possibly collective.subscribe (disclosure, I am the principal author, and the only example of this in use is collective.inviting, an event RSVP add-on). There are no widgets or UIs for this.
(2) If you simply want to pick users, you could just use a Choice field in your schema with a dynamic vocabulary of users in your system (example), and store the user-id on your content (unrelated warning: user name and user id can be distinct from each other; if you use email as login in Plone 4, I suggest you use collective.emaillogin4). The content tree widget is not going to work here, so look at either using a drop-down (for <200 users) or an auto-complete widget).

How to set relationship when I create a new (custom) content to another (custom) content in Drupal

Premise: I'm new in the world of Drupal, so sorry if this is a stupid question.
What I need is to set some relationships for some new content types I created. For example, I created the "Person" content type and the "Group" content type. Using the "Relation" module I have defined the relation "is in", but now if I want to add a field for setting the relation at creation time, there are no edit widget available. The only way I found to set relationships is using the entity collector: too complicated for a user.
Example: a user creates the Person "John", and he want for him to set the relation "is in" with the Group "Drupal fans". So, during the creation of this Person he needs, for example, a select control that lets him to choose from all the groups already registered in the site.
In brief, I need to manage some entities created by me, with CRUD controls, list, etc. and I need to set some relationships from these entities.
What is the best method/ what are the best module/ how I can do this?
Try the references module: http://drupal.org/project/references
You can create an taxanomy list of your'e groups at Structure -> Taxonomy.
This list you can use in creating an field. By the creation of the field choose for "Term reference" type and then "Autocomplete term widget". Click on save and choose the Taxonomy list that you created.
Hope this is what you need!

Link some users to a content

I have created a content type called "Event". For each event, I would like to be able to specify contacts (people in charge of organising).
Therefore I would like to add a field "Contact" to the Event type, where a widget would give access to the list of users. One could then pick one or several users.
This field would be displayed as a list of links to the profiles of those users.
I seem to remember there was a module providing that widget in Drupal 6, but I am now using Drupal 7, and haven't been able to find the necessary module!
Thanks!
(NB: I'm not using the Event module, but Date + Calendar.)
Here are two possible options you can check out:
Entity Reference module - can reference user entities
Provides a field type that can reference arbitrary entities
Relation module
Relation is an API module and storage model for both simple and the
most complex relations between entities. The module can handle both
directional and symmetrical relations very well.

Drupal Views Content Profile User as an argument

I have a normal Drupal User. I have used the content_profile module to create a profile content type. This content type contains a node reference to another content type company. The company node then references a type of node called Task.
I want to create a view that list all the tasks for a given user id.
So I imagine I would create a view with an argument of user id. Then I would add the relationship to the profile and the company and output the Task title.
The user id used seems to work on the created used ID and not the user id of the content profile that it is referencing. In our system the "admin" user creates the profiles so it causing some problems.
Any ideas? I feel I may need to write a custom module to do what I want.
i have answered a similar question in the past about how to create a view using part of the url as an argument to filter the view by the user profile. check out this url. the answer you are looking for may be a variation of my original response.
also, how are you creating those profiles? on one of my sites, when i created the profile page, its author ID is automatically changed to the user it is associated with.

Resources