Great module! How do I make it so that the user doesn't have a choice which view they use. In other words, when I create a content type I choose the view that shows up and no one can change in the module itself.

I'm not a coder - so if you've already got a way to do this please pass it on.

Thanks again
Simon

CommentFileSizeAuthor
#11 viewfield.module.txt5.68 KBmarkfoodyburton
#6 viewfield.zip_.txt20.22 KBBevan

Comments

Bevan’s picture

Title: Don't give the user a choice » Set view per node-type, not per node
Assigned: Unassigned » Bevan
Status: Active » Postponed (maintainer needs more info)

We're working on converting viewfield.module to do this. We were going to release it as a different module, seeing as it provides different functionality to viewfield, but this would essentially be a fork. To the maintainer of viewfield, do you think we could merge this into viewfield as a feature? There is a considerable amount of code in common.

Viewfield module could then provide two CCK field types; "Different view in each node", and "Different view in each node type".

We are working on a couple of bugs with our module right now, but I will upload a patch once we have it working smoothly.

WDYT?

thepanz’s picture

+1 for this feature!

bobo’s picture

Great! Thanks for that.

Bevan’s picture

We have this working but are dealing with a bug to do with CCK field formatters. I'll post it here for testing when we get that fixed. Remind me if I forget...

looplog’s picture

another hand up from the back of the class for this... any progress?

Bevan’s picture

StatusFileSize
new20.22 KB

Please test the attached module. I haven't been very involved with the writing / code of this, but I'm using it successfully on a site. We're not sure if it would be best released as a separate module to viewfield, or integrated back in to viewfield to merge the features of each. Suggestions and ideas would be appreciated.

B/

looplog’s picture

I've given the module you attached a quick test and can't seem to get it to display anything. I just added a tracker view to a fresh content type as a test but nothing shows up. Am I missing something obvious?

Bevan’s picture

You need to create a field using CCK, then possibly choose it's display type in the content type's display settings. Make sure the view you select works (and doesn't have an empty result set) independently first. If that doesn't work, try creating a field using the normal viewfield module, then swap it for this one, and repeat the above.

Bug fixes will be appreciated! :)

B/

looplog’s picture

ok. I finally had some time to try the module in one of my existing test-sites which uses the older version and it works fine. Exactly what I was looking for. I'll be testing it out some more over this weekend and get back with any feedback.

markfoodyburton’s picture

Simple, straightforward, seems to work, please make this a module!

markfoodyburton’s picture

StatusFileSize
new5.68 KB

For me, the following patch is important: http://drupal.org/node/165321

Attached is the module file from the above tar ball patched (by hand)....

Bevan’s picture

It would be great if someone could adopt this and maintain it as a new project/module or integrate it back into viewfield.module (to provide two field types). We are no longer useing this code on the project we wrote it for so it is out of line to expect the client to fund our maintaining it, and AFAIK none of the team has a personal interest in it.

Hmmm, I wonder if this is GHOP-worthy?

markfoodyburton’s picture

I'll contact Mark, see what he thinks too

Bevan’s picture

jfall’s picture

+1 - this would make a great addition to the viewfield module - exactly what I need.

There is a way to get some of this functionality without viewfield though, if you are using a template theme, at least...

  1. Create the single view you want to associate with a particular node type;
  2. Create a node-type.tpl.php file (simply copy node.tpl.php, where "type" is the type name for the node you are associating with this view);
  3. Add the statement:
    theme('view', $view_name, $limit = NULL, $use_pager = NULL, $type = 'embed', $view_args = array())
    (inside a PHP tag, of course, substituting the $arg parameters with the values you want);

Although this method does not actually provide an actual DB relationship between the node and the view, it does provide the desired output relationship. One drawback - you can only position the view before or after the node "content" - viewfield would allow much finer grain on where the view was actually rendered.

I hope that helps someone.

doc2@drupalfr.org’s picture

+1 to committing this!

darren oh’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

This has been fixed for a while.