Community Documentation

Documentation collection

Last updated December 5, 2012. Created by Itangalo on May 14, 2012.
Edited by aberglas. Log in to edit this page.

Warning: It is unclear whether this example can be built using the information provided in the book to this point. It is unclear how reference nodes can be added. Maybe extra modules are required? It also appears to promote obsolete technologies (References intead of Entity References).

As site member I want to be able to create documentation collections, referring to one or several documentation pages. There should be room for entering a description for each collection. This is important since it allows me to organize the on-line documentation in a way that is meaningful to me, as well as take part of documentation structures others find useful.

View a video of this exercise and its suggested solution.


Figure 6.4: An example of how the finished documentation collection may look.

How to demo

  1. Log in to the site.
  2. Create a new documentation collection, containing a description and referring to at least two documentation pages.
  3. Verify that the collection description and links to the documentation pages are displayed when viewing the saved documentation collection.
  4. Edit the collection and change the order of documentation page references. Verify that the list order has changed accordingly when viewing the saved collection.
  5. Log out and log in with another account. Verify that the documentation collection is not editable.

Preparation

  • A number of documentation pages should be available on the site (see previous exercise).
  • The References project should be downloaded and the Node Reference module installed. (Alternatively, a stable release of the Relation module could be used.) Note: Entity reference can replace References.

Suggested solution

  1. Add a new content type Documentation collection. Provide it with a description. Click save and add fields to go to the fields overview page. (See node types and node administration.)
  2. Make sure that the Node reference module is enabled. Then add a node reference field, for example using the label documentation pages. (See adding new fields.)
  3. Allow the node reference field to point to documentation pages only. Mark it as required, provide it with a help text, and allow users to enter an unlimited number of references in each field. (See adding new fields.)
  4. Go to the permissions list for the website, and set permissions to allow authenticated users to create and edit their own documentation collections. (See permissions and roles.)

Comments

  • The suggested solution should be updated to use the Entity reference module, rather than References.
  • As with documentation pages, it does not really make sense to add collections to menu, so all menus may be deselected in the node type settings.
AttachmentSize
05.4 Documentation collection.png74.17 KB

Comments

Reference field with links

I'm not sure the screenshot used is appropriate for the exercise. It shows a filled up Documentations page field where the referenced nodes were links. When accomplishing the exercise using the suggested solution, it doesn't turn into links; in fact, I had to google how to make my own list do that, and the solution was to change something under Manage Display, an option that readers going through the book sequentially wouldn't encounter until a future chapter.

Can you update the post to either explain that the links shouldn't appear as they do in the screenshot, or simply get a more appropriate screenshot with the reference list appearing without links? It might confuse beginners using this book to learn Drupal, like me.

Pinoy pride.

Solution Step 2 Confusion

I'm assuming my confusion on this page is due to the fact that "Entity References" has replaced the "References" module.

I downloaded and enabled the Entity References module. I created my new content type for Document Collection. But then for step 2 it says:

"2. Make sure that the Node reference module is enabled. Then add a node reference field, for example using the label documentation pages. "

Which has me (a newbie) confused since I don't see a Node reference module on drupal.org and it's not included in the Entity References module (at least not that I can see) .

So I'm stuck at the moment but going to see what I can find out :-D

***EDIT***
I have a little more of this figured out.

1) Create the content type of "Document Collection"
1) Add a field type of "Entity Reference"
3) Widget defaults to "Autocomplete", but for this example it was easier for me to change the value to "checkbox / radio buttons" so I could easily see mydocuments listed when I got to adding content of type Document Collection

Click "Save" and you'll go to the field settings page.

On this page I selected:

Target Type: "Node"
Entity selection mode: "Simple" (not sure what changing this setting does yet, haven't experiemented)
Target Bundles: "Document Page"
Sort : "Don't Sort" (didn't play with this setting much yet)

Save

The next page the only change I made was I swiched "Number of Values" from 1 to Unlimted.

Now when I Add content of type "Document Collection" I'm able to select from a list of already existing "Document Page" content types. Once I save my new content and view it the documents I selected from are showing up on that page.

**Edit #2***
As the comment above pointed out, after doing this my document pages are listed but do NOT display as links. So to make that part work I did this:

Structure --> Content Types --> Document Collection --> "Manage Display" tab

Under the format column you'll see the text "no link" and to the right of that a gear.
Click on the gear.
Once you do that you'll see a checkbox appear that says:
"Link label to the referenced entity"

Click that checkbox then click on the "Update" button. You'll now see "Link label to the referenced entity" in text.

Now make sure you click the "Save" button too or else that change won't stick.

View your Document Collection page again, and the unlinked document pages are now links!