Creating a resources page in Drupal using a CCK content type
Submitted by David Herron on Sun, 2009-08-30 12:46
An earlier blog post (see references below) discussed a website node type that I frequently use. One purpose for the website node type is to build "resources" web pages. The "resources" page is an old practice on the Web where a site might host a resources page listing useful sites. These resources pages can be a gold mine of information for users, but I suppose it can be a pain to maintain if the page is a static page you have to remember to edit to add a new resource link. For example an SEO practice is to request links from related websites, and each request means adding a link on the resources page. I want to show a simpler way to accomplish this task. The first step is to create a website node type using CCK to add link and emfield fields. The details are linked in the references section below. The topic of this tutorial is the second step, creating a view to assist with showing a selected list of website nodes inside other nodes. Assuming you already have Views installed and enabled, the additional module to install is: Insert View Insert View is a filter that allows users to embed content lists generated by the Views module into node bodies and blocks using relatively simple tag syntax. Naturally, it requires the Views module to operate. After installing the module you must go to the input formats admin page and enable the insert view filter. Views is very flexible and you can set this up any way you like. What I'll do is show my implementation, and why. The view name I chose is "link_list" because that's what it it, a list of links.
I have yet to explore whether it's useful to create a page view, or a feed, from these lists. Currently I am not generating either of them, and I can see how they both might be useful, or might not.
To embed the view simply use the "insert view" macro such as the following.
|Node published = yes||Only show website nodes that are already publicly visible (published)|
|Node type = website||Whatever content type you chose to create, make sure the view only lists those nodes|
|Taxonomy: Term ID||This is to flexibly select a subset of website nodes. Each website node should have relevant vocabulary terms, of course. Selecting website nodes by vocabulary term should be a useful list.|
|Content: Link, Node: title, Node: teaser||Fields are only useful with specific display types. I'm about to recommend using a Table display and of course fields are required for tables. These fields seem the most useful to me.|
|Style: table||I played around with several display types and settled on the table display. You may prefer one of the others. For example the unformatted display might be more like traditional resources pages.|
|Items per page: 20||This view is going to be inserted into another node, so "items per page" here means the items in the embedded listing. Set this number to your preference.|
|Use pager: YES||This generates a "pager" if your list results in more nodes than the items per page. The choosing here is between long pages (e.g. if you have lots of nodes in the reference list) or short, and whether to send the user to subsequent pages. A second setting that might be useful is 'Use AJAX' which is supposed to cause the embedded list to be loaded dynamically.|
[view:link_list=default=931]The '=' signs separate arguments to the view. The '=931' is the numerical term ID which you must discover. The term ID will be in the URL of the taxonomy list page for the term you wish to use, however pathauto obscures the term ID behind user friendly text. The other way to determine the numerical term ID is in the taxonomy admin area, edit the vocabulary, list the terms, find the term you want to use, then notice that the term ID is in the URL used to edit the term.