Right now, if I'm not mistaken, this only works with the node body or comment field; it would be great to have this work with any CCk text field.

Comments

dagmar’s picture

Status: Active » Postponed (maintainer needs more info)

Sure, it would be nice. How do you think this can be achieved?

As you said, Canned Texts can be attached into a comment form, maybe the best way is provide a textfield to define a css selector to define to which textarea insert the loaded text.

Do you have any another idea?

bomarmonk’s picture

Well, it would be great if you could select a "canned text" option from a field edit page. If you allowed this, then canned text would work per field, rather than per content type, meaning that you could have multiple canned-text entries for each node. I imagine this could really be more complicated than what the code does now, but I also imagine it could be accomplished by looking at how other modules work with fields. Take a look at node relationships, which allows you to select nodes for node reference fields. Could it's strategy be used with canned text; instead of selecting nodes to reference, you are selecting fields to inject into the current field.

As a usage case: I have mission statements for divisions and for organic groups. This means that an organic group has a mission statement, but may also have a division mission statement. There is a form that group members create that needs to include their mission statement and their division mission statement (if there is one). These mission statements should not be recreated every time the form is submitted; instead, the person creating the form should be able to simply inject "canned text" or their existing mission statements into this form (there is already a separate node that contains each of these mission statements). There may be a way to do this with calculated fields or with PHP and views, but your module seemed like a possible solution.

I admit, I'm more of a Drupal administrator and end-user, rather than a developer, so I have no idea how hard this would be to accomplish. Thanks again for considering my feature request. Canned-text is a nice module either way.

bomarmonk’s picture

One other thought: some of what I want to do could be solved by just attaching a view or embedding a view of these mission statements into the node's display (or into the completed form once it is submitted). However, since the mission statement could change or be updated for next year's form, you would still want this year's form to reflect this year's mission statement (hence, the need to actually inject the current mission statement as canned or preexisting text into a field on the form-- that way it would be preserved in this document). Does that make sense? I have to use the "canned text" approach in some fashion in order to make my application work as it should.

dagmar’s picture

Status: Postponed (maintainer needs more info) » Active
Grayside’s picture

subscribe.

I was thinking about this feature in general earlier today. Glad to see the module.

In the end I determined I would rather avoid cluttering the UI of my node form by adding multiple text insertion selectors. In an ideal universe I would love a selector that could populate multiple fields, almost more of an ajax nodeclone functionality. In it's absence, I'll settle for my users learning to insert the text into the body field and then copying it to other textareas.

ksiebel’s picture

subscribe.

Would be very cool to see this functionality added... :)

Got a use case here...

asak’s picture

subscribe.

excellent thread going on here - just what i was looking for.

Being able to attach Canned Texts to specific CCK textfields would be ideal. we could then use specific views for every field, to filter the available texts for that specific one.

And to make it truly awesome - support multivalued fields ;)

I'll look into this myself as well... having even tried the module yet ;)

asak’s picture

Quick Update: ok - got it working with CCK text fields.

Went over the code - and noticed it's specifically mentioned that the JS was partialy "stolen" (all in good intentions!) from the insert.module - so i went back over and compared.

What was missing? this:

  // Keep track of the last active textarea (if not using WYSIWYG).
  $('.node-form textarea:not([name$="[data][title]"])', context).focus(insertSetActive).blur(insertRemoveActive);

  function insertSetActive() {
    insertTextarea = this;
    this.insertHasFocus = true;
  }

  function insertRemoveActive() {
    if (insertTextarea == this) {
      var thisTextarea = this;
      setTimeout(function() {
        thisTextarea.insertHasFocus = false;
      }, 1000);
    }
  }

So just added it to the canned_text.js file, where it was declared in the insert.js file, and it works - if you click inside a textarea before selecting a snippet - the text will be inserted into the "focused" (selected) textarea, and not inside the body.

It's a little buggy - especially when testing with multivalue CCK textarea fields - but it works.

More to come ;)

bomarmonk’s picture

Very good! Thanks, asak. Hopefully this can be added into the development version of the module and evolve further with multi-value fields. Thanks again.

ksiebel’s picture

for our use the solution is okay but for clients or end users its not usable.
think of users don't clicking inside the textarea... or what about multiple cck fields on one edit page - there should me multiple selects for canned texts.