InsertNode

markfoodyburton - January 10, 2008 - 14:03

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 (if you want to include a view, use the insert_view module instead.)

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. 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!

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.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)
    Display the title of the node inside an <h3> tag. It is otherwise unthemed.
  • body (5.0)
    Display the body of the node, the terms and the CCK fields. Tags are transformed.
  • content (default) (6.0)
    Display the body of node, the terms, the CCK fields and the links. Tags are transformed.
  • teaser (5.0)
    Display the teaser of the node and the terms. Tags are transformed.
  • more (6.1)
    Display the words "Read more..." with a link to the node, unthemed. Useful when the teaser is being shown.
  • link (5.0)
    Display the title of the node as a link to the node, unthemed.
  • collapsible (5.0)
    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.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)
    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.

History

See http://drupal.org/node/87746 - where markfoodyburton took the code from.

Enjoy.

Releases

Official releasesDateSizeLinksStatus
6.x-1.12009-Apr-137.89 KBRecommended for 6.xThis is currently the recommended release for 6.x.
5.x-1.12008-Mar-046.73 KBRecommended for 5.xThis is currently the recommended release for 5.x.
Development snapshotsDateSizeLinksStatus
6.x-1.x-dev2009-Apr-168.02 KBDevelopment snapshotDevelopment snapshots are automatically regenerated and their contents can frequently change, so they are not recommended for production use.
5.x-1.x-dev2008-Mar-056.73 KBDevelopment snapshotDevelopment snapshots are automatically regenerated and their contents can frequently change, so they are not recommended for production use.


 
 

Drupal is a registered trademark of Dries Buytaert.