InsertNode
Description
This is a trivial filter allowing you to insert a node within another node's body (or wherever the filter is active, it will work in a block)
It should work on any Drupal path (i.e. the URL path, as it uses drupal_get_normal_path) or any node id. It won't work on non-nodes.
Compatibility
I do not know how many people are already using the collapsible and collapsed parameters. These two parameters have changed since version 6-1.1. They do NOT include the body content. Also they will function, they will look different since the title will be included within the frame (i.e. output content defaults to content). To avoid that side effect, edit your nodes and add the body parameter as in: [node:home body collapsed].
Installation
Decompress the module in your sites/all/modules folder.
Go to admin/build/modules (Admin -> Site Building -> Modules) and select the new module (under package named "Filters input")
Go to admin/settings/filters (Admin -> Site Configuration -> Input formats) and select the filters that you want to support this module. It is suggested that you create a new format if you are to use the filter only on a few pages. This way, you avoid wasting time on all pages. The filter will appear as "Insert node".
Make sure that the nodes using the [node:...] tag make use of the formats having this InsertNode filter turned on.
You are ready!
Upgrading from version 1.1 or older to 1.2 or newer (or -dev) by Drupal 6.x users
I changed the name of the module back to InsertNode (although I did not want to, I did not want to jeopardize the Drupal 5 version... which would probably have been fine, but well...)
So, the newer version of the D6 module is again called InsertNode.
To upgrade you will want to keep the other version running until you get the new version as the replacement (although you can manage your site the way you'd like this procedure let you switch from the previous version to the new version without having to turn off your site for a little while.)
- Extract the new version, it adds InsertNode in your list of modules (in your filesystem). It does NOT overwrite the previous version which was insert_node.
- Switch to your website and go to /admin/buid/modules
- Open the "Input filters" package
- Search for "Insert Node," you should see two of them, the old one says "A filter that includes content from one node in another", whereas the new one is a little more verbose and says: "A filter to include content from one node in another, or anywhere a filter is used (i.e. a block)"
- Select the new "Insert Node" filter, keep the old one selected
- Go to /admin/settings/filters
- Edit each filter (if you know which ones use the old Insert Node module, you may just edit those.)
- Switch between the old and new Insert Node. The old filter says: "Insert node". The new filter says: "Insert node [re-renamed]"
- Click on Save
- If the order is important, go back to your filter and change the order as required.
- Repeat the input filter procedure for all the filters where the Insert node filter is used
- Once done, go back to /admin/build/modules and disable the old Insert node
- You may go in and run the uninstall function but since there is no .install file, nothing will happen (there are no setting other than those defined in the tags...)
- If necessary, reset your caches (it should not be necessary since the new module will generate the same output.)
Coming back at the right place when adding/editing/deleting Comments
It is now possible (See #418004: Comments included --> Back after reply) to have Drupal send you back to the page that inserts the node instead of the inserted node. Say you create node A and B. You include node A inside node B. You are looking at node B now. You decide to add a comment on node A (that you see from within node B.) Click on the Add new comment link, write the comment and click Save. At that point, you probably want to come back to node B instead of node A.
This feature is only necessary if you have the links at the bottom of the node and allow comments to show up.
The feature requires the jQuery plugins module installed and enabled. It is in the package named User interface. Note that because most people do not need this feature turned on, the Insert Node module does not require the jQuery plugins to be installed (it is not a hard coded dependency.)
Usage
The syntax is:
[node:<name of node> <parameters>]The parameters are all optional. The default is content without comments.
In Drupal 5, you can specify only one parameter. And the collapsible option automatically includes the body.
In itself, the order of the parameters is not important. However, that defines the order in which you want the data to be displayed. So if you want the title, teaser and more link, you must enter them in that order as in:
[node:article41 title teaser more]Note: The version defined between parenthesis in the list below shows the time when the given parameter appeared. Parameters that were available in 5.0 are still available in 6.1, for instance.
- themed (6-1.0)
Display the themed body of the node and the terms as if you were looking at that very node. The CCK fields and links are not shown. Also, the tags are not filtered. This if you use a filter such as the footnotes filter with [fn]Info[/fn] tags, they will NOT be transformed. - title (6-1.1)
Display the title of the node inside an <h3> tag. It is otherwise unthemed. - body (5-1.x)
Display the body of the node, the terms and the CCK fields. Tags are transformed. - page (6-1.2)
Display the body of the node, the terms, the CCK fields, and the links. Tags are transformed. In this case the Insert Node tells the node that it is its page. - content (default) (6-1.0)
Display the body of node, the terms, the CCK fields, and the links. Tags are transformed. - teaser (5-1.x)
Display the teaser of the node and the terms. Tags are transformed. - more (6-1.1)
Display the words "Read more..." with a link to the node, unthemed. Useful when the teaser is being shown. - link (5-1.0)
Display the title of the node as a link to the node, unthemed. - demote (6-1.2)
Demote (positive) or promote (negative) the headers found in the output before inserting it to your node. This is useful if you want to include a complete node that has an H1 title, H2 sub-titles, etc. and make this sub-titles of your current page, maybe starting at H3 (i.e. using "... demote=2; ..." in your tag.) - collapsible (5-1.x)
Move the selected content inside a collapsible frame. The frame is expanded at the start. The title of the node is used as the title of the frame. - collapsed (6-1.0)
Move the selected content inside a collapsible frame. The frame is collapsed at the start. The title of the node is used as the title of the frame. - comments (6-1.1)
Attach the comments at the bottom of the node data. The comments will be shown just as in the regular page (i.e. flat, thread, expanded, collapsed.)
Examples
To send someone back to your home page:
You will find the necessary links on my home page: [node:home link]To include a hidden node as a reference in a post:
I talked about that in my post yesterday. [node:yesterday_post_name body collapsed]To include a node from a forum or story and keep the comments:
See this page: [node:57 themed comments]Extras
You can find some extras on my Linux website: http://linux.m2osw.com/insert_node
If you also have extras you want to share, send them my way!
For D5 users, this node: #395608: Process node content (eg CCK, filter tags) includes a patch to fix problems with CCK, Links and other fields that would otherwise not appear.
Known bugs
Version 5.x with patch in #395608: Process node content (eg CCK, filter tags) can generate infinite loops and thus break your server.
Security consideration
Although the accessibility of the node and comments are checked, it is a good idea to see this module as a security risk giving users a way to display nodes otherwise forbidden to them.
Because a lot of the data is used unfiltered, it is strongly suggest that you pay very close attention to the order of your filters. If you authorize this module for your users (i.e. where they can select an Input filter that includes this specific filter,) then look into checking the HTML code after this filter. Otherwise, a user could inject some unwanted HTML code.
Similar Projects
Link Node
There is a Link Node project that can be used to generate a link to a node using the node title or another user specified title.
Insert View
If you want to include a view, use the insert_view module instead.
Insert Block
If you want to include blocks in your nodes (or other blocks, scary, hey?!), use the insert_block module instead.
History
See http://drupal.org/node/87746 - where markfoodyburton took the code from.
Enjoy.
Releases
| Official releases | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 6.x-1.1 | 2009-Apr-13 | 7.89 KB | Download · Release notes | Recommended for 6.x | |
| 5.x-1.2 | 2009-Oct-28 | 6.77 KB | Download · Release notes | Recommended for 5.x | |
| Development snapshots | Date | Size | Links | Status | |
|---|---|---|---|---|---|
| 6.x-1.x-dev | 2009-Nov-16 | 9.74 KB | Download · Release notes | Development snapshot | |
| 5.x-1.x-dev | 2009-Oct-23 | 6.77 KB | Download · Release notes | Development snapshot | |
