First of all, excellent concept, I've got immediate use for this.

Sorry to lump all these together, if I have further questions or put in feature requests I'll split them into separate issues, or if you prefer let me know and I'll split them up before you answer. Thanks in advance. . .

Q1 If linking is disabled, can it be made to look exactly as if it's local?

Q2 Is all the formatting from the source preserved? Q3 What about links, e.g. inline html, actual link-type fields, Glossary module flags, do these all look and behave the same as in the original node?

Q4 Does it respect node-access security? Q5 What about CCK field-level security?

Q6 Is there any way to back-reference from the source, so if I've embedded content from one field in five other nodes I can quickly review the context in the target locations when editing the source content, or confirm all the targets are deleted before I delete the source?

OT

Q7 Any (future?) support for sharing display of CCK image fields, and if so, different imagecache derivative versions?

Q8 How close do you reckon this is to being ready for production site use?

Q9 Any chance of a D5 backport once you've gone stable? If not this still looks useful enough for me to maybe make the jump to D6, but I'm still waiting for some other key modules to be upgraded.

Comments

Roi Danton’s picture

Title: Lots of questions, mostly re text field content displayed from other nodes » Q&A for people with many different questions in mind

If I begin to work on one of the questions/issues or you have further ideas to one question then a separate issue should be opened.

Q1 No, see answer Q2/3 (if I understood your question correct).

Q2/3 No, all formatting is removed since I use check_plain()/l() for security reasons and to avoid infinite referencing (imagine an embedded textfield embeds itself with a Linodef tag). If you think it is important to preserve certain formatting than open a separate issue and list the tags you need (HTML filter, flags etc). Coding that could take a while or is limited to a small amount of tags because I have to heed possible security flaws.

Q4 Yes. Now details can be found at the drupal.org documentation (I've copied the page from the help documentation included in Linodef).
Q5 Linodef only uses default permissions. Permissions from other modules (e.g. node based, CCK based) are not supported yet. Though it shouldn't be difficult to include support at least for the CCK submodule Content Permissions.

Q6 Yes there are ways but it's not intended for Linodef (I want to keep Linodef lightweight): The tags are simply saved as content in the textfield. and I don't want that Linodef modifies the database layout (an extra column for each node could be added which contains IDs where the tag is used). But: This could be a task for Inline API. I recommend to mention it there.

Q7 I hadn't had a look into the code of image field/file field yet. I assume it's doable but I can't promise if it'll be done in the near future.

Q8 With rc2 I'll introduce a slightly new tag layout for no links ([#IDnl] instead of [#nlID]). Afterwards I don't expect further chances in tag layout, so rc2 should be future safe for production use. Furthermore it uses default Drupal access rights and there is no (known) lack of security.

Q9 Thats unlikely since FAPI has altered from D5 -> D6 and I'll focus on improvements than on creating a backport.

HansBKK’s picture

Q1-3 - submitted issue #335433: Enable "pass-through" of filtered layout of embedded fields

Q4&5 - submitted issue #335438: Respect access control via CCK Content Permissions

Q6 What about storing the nids-->link of target nodes in an array in a CCK field within the source node? No not asking, just throwing it out there :)

User workaround in the meantime: define a "hidden for editor" CCK field in the source node with links to the target nodes referencing that source and manually edit it each time references are added or deleted.

Q7 Should be done by imagefield itself anyway shouldn't it. . .

Q8 Excellent, how close (ballpark do you reckon rc2 is - weeks, months. . ?

Q9 Sounds like a plan!

Thanks for such detailed answers and again, thanks for launching what looks to be an excellent and original new set of functionality for Drupal!

HansBKK’s picture

"This could be a task for Inline API. I recommend to mention it there."

Done http://drupal.org/node/80170#comment-1108966

Pepe Roni’s picture

Q7: I did this with texy! filter, computed field and linodef!
1. added a computed field to my "image" node containing that image field. This computed field "field_filename" gets the filename from the image field.
2. defined a BuEditor button for inserting from "field_filename"
3. added linodef (and of course html-filter) to the texy filter and arranged them in this sequence: linodef (to change a linodef tag into a filename), texy! to do the texy stuff (eg. insert the image from a filename) and html-filter to remove disallowed html-tags.

My content then looks like this:
[* [nl#8:field_filename] *] (old syntax)
[* [#8:field_filename,nolink] *]

First, linodef transforms [nl#8:field_filename] into a filename, then the intermediate content will look like this:
[* myimage.jpg *]

Then, texy! transforms this into an img-tag.

Roi Danton’s picture

Hehe, nice one. :)

Please heed that with Linodef rc2 the no link tags will change because I added this feature to term links also. They will look like [#IDnl] resp [#tIDnl]. If you already have many no link tags in your installation a search and replace module could come in handy upon upgrade to rc2. The dev version already uses the new tag layout. It is the first and likely the last time that something like that does change! (in an emergency I could provide a backwards compatibility but I'd like to avoid that additional code)

Q7 Filefield and Imagefield are storing a FileID and the other information in a serialized string. Hence to support that I can't use my functions as they are. Maybe I do that in a later version (not rc2). Until that time druppi found a neat solution. :)

Q8 Weeks.

HansBKK’s picture

Correct me if I'm wrong, but my understanding is that you're now able to display an image referenced by an imagefield inline with body content. True?

If so, KEWWL! Is this limited to same-node use, or could it be a way to get Image-module like referencing/re-use from a "container" node to more than one "displaying" nodes?

If the latter, could you please expand your example?

And I would suggest cross-posting to imagefield's queue, lots of people looking for this (if I understood it right)

Pepe Roni’s picture

Here is the code for the computed field field_filename
$node_field[0]['value'] = $node->field_image[0]['filename'];
You see, it's really no secret. field_image is the system name of the image field, and my images (a cck-defined content type) contain only one occurrence of the field_image.

Here are my BuEditor buttons:
The "Insert image" button (linodef):

php: // Button for Linodef tags.
$drupal_element_type = 'field_filename';
// Enter the fieldname, content type or vocabulary ID above, e.g. '10' or 'field_example'.
// If you want to add a "no link" marker to the tag, set this to True
$no_link = True;

// Do not modify.
if (module_hook(linodef_bueditor, buttons)) {
    return linodef_bueditor_buttons($drupal_element_type, $no_link);
}
else {
    return t('Module !module not enabled!', array('!module' => 'Linodef - BUEditor'));
}

The "Image left" button (Texy!):
[* %TEXT% <] ***
and the "Image right" button (Texy!)
[* %TEXT% >] ***
You can then first press the "image left" or "image right" button, and then the "insert image" button.

An example would be:
[* [#nl5:field_filename] >] *** [#5]
In this example you would see the image and, as caption, the image title, as clickable link. For details see also the Texy! documentation.

I used image field to enable translation of images (without duplicating the images).

I also have some ideas about attaching images and referencing these in the content (place them into the content and not at the bottom of the content). But that will become another thread.

HansBKK’s picture

Posted a note about this to the "re-use" issue on Imagefield http://drupal.org/node/119539

momper’s picture

subscribing

SerenityNow’s picture

Hi- This project sounds like exactly what I am looking for - unfortunately, I will be using 5.x. In your description for Linodef, you mention several other similar Drupal projects (internal link managers). Can you please list these other projects as an FYI, since there will not be any backport of Linodef to 5.x?

Thanks!

Roi Danton’s picture

Thats right, there will be no backport of Linodef for Drupal 5 unless someone other than me is willing to do.

Search the contributed module list for filters. E.g. you'll find Pearwiki Filter or Freelinking (Camel Case and Wiki Syntax). However, I don't know of another module than Linodef that embeds content from other nodes or fields etc.
EDIT: Insert Node insert nodes and its fields. However the version for D5 has problems with infinite loops I stumbled across in past, too. If you use this module please give a feedback here since I've got to know about Insert Node just from that very moment. :)

Btw, from a point of view of an admin, I recommend to use D6 since it's much easier/faster to set up a site with views & CCK 2. Sorry for being Off-Topic. ;)

imclean’s picture

Thanks for the great idea, druppi (and of course the great module Roi). For linking to a FileField field I used a similar method.

Computed field (field_document_link):

$node_field[0]['value'] = l($node->title,file_create_url($node->field_file[0]['filepath']));

This creates a link from the document node title to the file which can then be inserted into the text using the normal method:

[#32:field_document_link]

Roi Danton’s picture

I added links to your instructions to the supported element types page in the documentation.

awakash’s picture

How would we use nolink option for pull say field_body from node id?

We can add nolink to tid (e.g. [#5,tid,nolink]), but what if we wanted to use nolink for this tag: [#2:field_body] ? I tried this but didn't work [#2:field_body,nolink]

Roi Danton’s picture

You want to embed the default node body or you have a field called field_body?

awakash’s picture

Good question - took me some time to figure out but I have a field called field_body. What I did was enable 'computed field' within CCK to make a hidden field that pulls the default node body (without appending the copy data into the database). So, now I have a field called field_body. Any ideas on how to use 'nolink' ? I would like for the text I'm pulling not to be a hotlink - and I'd like to prevent from hacking/changing the module myself.

Roi Danton’s picture

I did a test with the 'nolink' option and several fields (computed, text, number) using rc3 release. I could reproduce your problem that nolink and other options without values doesn't work everytime. I posted the bug and fix:#543694: Options without values are not heeded

Thanks for reporting that bug! Btw, the next version will support embedding node body by option. I never needed it since I use fields for everything.

Furthermore I close this issue since:

  • having an issue with many different topics doesn't fit to the Drupal issue queue conventions
  • the herein discussed embedding of Image- and Filefields already work with my development copy of Linodef - now all embedded fields use their context sensitive formatters (and I'm very happy about this :) )

If you have a question please open a new issue so other users with the same question can find the answer quickly.

Roi Danton’s picture

Status: Active » Closed (fixed)
Roi Danton’s picture

Title: Q&A for people with many different questions in mind » CCK fields formatting (support Image- and Filefield)
Category: support » feature
Status: Closed (fixed) » Fixed

CCK formatter support commited to D6 branch. Now Linodef (dev release) is capable of embedding all fields, including Image- and Filefields. Usage like always: [#19:field_image] (field_image = and image field of your site attached to node 19). Here the CCK formatter you set on your content type is used.

You also can define another formatter for the field by writing: [#19:field_image,formatter="formatter_name"]

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Pepe Roni’s picture

Status: Closed (fixed) » Active

Here is another approach to embed an image from an imagefield into the node body:

In the node with the imagefield field_image define a computed field field_image_left, not stored into database!, with the following computed value:

$no         = 0;
$teaserview = 'small_quadrat'; // formatter for teaser image
$nodeview   = 'medium'; // formatter for display in full node view
$float      = 'left';

$title      = $node->field_image[$no]['data']['title'];
$alt        = $node->field_image[$no]['data']['alt'];
$caption    = $node->field_image[$no]['data']['description'];
$node_url   = url('node/' . $node->nid, array('absolute' => TRUE));

$filepath   = $node->field_image[$no]['filepath'];
$attrteaser = array('class' => 'imagecache imagecache-'. $teaserview . ' teaserview');
$attrnode   = array('class' => 'imagecache imagecache-'. $nodeview . ' nodeview');
$node_field[$no]['value'] =
  '<dl class="field_image' . ' field_image-' . $float . '">'
    . '<dt>'
      . theme('imagecache', $teaserview, $filepath, $alt, $title, $attrteaser)
      . '<a href="' . $node_url . '">'
        . theme('imagecache', $nodeview, $filepath, $alt, $title, $attrnode)
      . '</a>'
    . '</dt>'
    . '<dd>' . $caption . '</dd>'
   . '</dl>';

In your embedding node you can refer to this field by [#id:field_image_left,nolink] and this will insert the whole html code for a teaser view image and a full node view image. The full node view image will also contain a caption (the description attribute. With css you have to omit the display of the full node image in teaser view and the display of the teaser image in the full node view. The larger image is linked to its node. (you also can omit the nolink, as in the current version the link is not placed correctly by linodef and thus does not work)

This is only a working example. It should lead you to more ideas what you can do with linodef and imagefield!

Roi Danton’s picture

Status: Active » Fixed

Thanks for sharing your approach! I have added a user tips section to the Linodef handbook pages. All user instructions should go there in future. Please add a child page with your instructions of #21 there, too.

Btw, I haven't looked into the details of your code but think using formatters should enable a similar result. However that could be discussed on the doc page. This issue should be reserved for bug reports or comments regarding the fields implementation. Marking as fixed so other users are getting attention to your instructions for 2 weeks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.