Closed (fixed)
Project:
Insert View
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Aug 2007 at 17:17 UTC
Updated:
31 Dec 2008 at 15:53 UTC
Jump to comment: Most recent file
Comments
Comment #1
lias commentedFYI the way to add view with php and without insert_view is listed in the handbooks page: http://drupal.org/node/47417
Comment #2
mlsamuelson commentedlsabug,
It is indeed possible to insert a view into a CCK field. In my test site, I just inserted the tracker view into a CCK text field.
The snippet you mentioned can come in handy when pager issues crop up with inserted views.
mlsamuelson
Comment #3
lias commentedThanks for the confirmation on the snippet.
Is there any plan to have insert view work with cck?
Comment #4
mlsamuelson commentedMy testing indicates that it does work within CCK text fields in Drupal 5.
I don't think I tried the title field, but with the filtering on that field, it probably won't work (nor can I think of an implementation where you'd really want it to).
What version of CCK are you using? What field types have you tried inserting into?
Comment #5
lias commentedI had created a cck "content" field to replace the default "body" field. I found that whenever I removed the "body" from a content type insert_view would no longer work. It seems to need the drupal's body filter. I've tried this on two different 5.2 installations, one on Windows/Apache and one on Linux/Apache and both do the same thing.
As a workaround I created a separate content type with the default "body" field just so I could insert a view. It works okay, I"m using it with OG so that certain types of content are posted on specific group pages.
Comment #6
mlsamuelson commentedOkay, so what's probably happening is that hook_nodeapi() isn't triggered when you're not displaying the body... and nook_nodeapi() is where Insert View's magic happens.
I'll look into this further as time allows.
Thanks for the detailed description of the problem, lsabug!
mlsamuelson
Comment #7
erikhopp commentedHi.
I'm having the exact same problem.
I've done something like this in a content type template:
I've confirmed that when doing this:
it works.
But I don't want all the fields to print, thus only called my custom $body.
Is there a way to fire the node_api hook through template.php for a specific content type?
Thanks!
Erik.
Comment #8
erikhopp commentedSo, this is probably not finalized code that should go inthe module, but I think I have a fix that is pretty easy.
The following patch is attached:
Comment #9
mlsamuelson commentedI've done some testing today. I was able to insert a view despite turning off the body on a custom CCK content type - but I think I've determined what must be going wrong... thanks in large part to erikhopp's patch which illuminated the problem, though doesn't solve it in a larger sense.
The issue, I surmise, arises from individuals printing out non-standard theme variables in their node.tpl.php files. Not all of these variables are affected by the insert_view_nodeapi() function which is used to do the Insert View magic.
In node.tpl.php, insert view tags work when printing out:
$contentor$node->bodyYou'll only see the [view:viewname] tag with these:
$node->content['body']['#value']or a CCK field like$node->content['field_custom']['#value']Not very helpful if what you want is to use Insert View and trick out your theme at the same time.
My feeling is that Insert View should stay simple, at this point, however, and not start second guessing other processes in Drupal.
I'm very open to other's thoughts and ideas, however...
Comment #10
mlsamuelson commentedSide note: I forgot to point out to folks that you have to be very careful when printing out non-standards variables in your themes, as when you use the non-standard variables, you become responsible for sanitizing the content. In that case, filter_xss() is you friend. See http://api.drupal.org/api/function/filter_xss/5 .
(Just wanted to share that since it's a matter of security. Let's not have this issue queue become a thread on this topic, though. Let's stick with the issue.)
Comment #11
tommo commentedWith reference to Isabug's first comment (#1) - I think there may be an issue when trying to use this code in a cck tpl file as in this cas: http://drupal.org/node/192655 .
Any thoughts?
Tom
Comment #12
mlsamuelson commentedUsing Insert View tags in cck fields should now work as long as the field uses an input format associated with it. For the solution, see recently committed patches http://drupal.org/node/224987 and http://drupal.org/node/180042. They make Insert View a true filter module (ie. it now does its work via hook_filter() rather than hook_nodeapi()).
Currently the updates are in HEAD and the D5 branch, but I'm planning to make an actual release before long.
I'm marking this issue as fixed. But please open it up again if you experience any issues.
mlsamuelson
Comment #13
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #14
arnaldex commentedHi there,
I'm using the CCK "Computed field", instead of use this line:
I use this one:
and everything is fine! (without the PHP tags, of course).