Hey everyone,

I thought I'd start a thread to begin discussion of a Drupal 7 port.... I use this module quite a bit and would love to see us start working together towards a port sooner rather than later. Thoughts?

Cheers,
Ben

Comments

ndm’s picture

Very good idea, I hope to use with module in the future.

sun’s picture

Title: Drupal 7 port » Port to D7
Category: support » feature
Status: Active » Postponed

We (all of you + me) need to do a major revamp of the field's settings over in #489908: Per field instance default value settings first.

Afterwards, we can port this module to D7, which should be quite easy.

amitaibu’s picture

@sun,
Re-checking what are the plans for D7? I'd be happy to deprecate og_views in favor of this general module.

ConradFlashback’s picture

subscribe, this is a great module.

dsoares’s picture

subscribe for the D7 port

zazinteractive’s picture

Would love it in D7 as well

peter törnstrand’s picture

+1

a.siebel’s picture

+1

fusepilot’s picture

+1000

momper’s picture

+2000

momper’s picture

Title: Port to D7 » Viewfield: Port to D7
webankit’s picture

+1

aren cambre’s picture

subscribe

Unnamed’s picture

subscribe

pepemty’s picture

Subscribing

kirkcaraway’s picture

subcribing

bryancasler’s picture

subscribe

pmackay’s picture

subscribe

SilviaT’s picture

subscribe

keithm’s picture

Status: Needs review » Postponed

I've posted a patch in #489908-8: Per field instance default value settings that addresses the per field instance settings issue. I'm looking for community members to review that patch. As sun says in #2, once that issue is fixed, the port to D7 should be easy.

sw3b’s picture

subscribe

Isaaci’s picture

Is this mean View filed is already ported to Drupal 7?

Thank you
Isaac

ConradFlashback’s picture

No Isaaci, we still expect the porting of this very important module.
Subscribe ++

keithm’s picture

StatusFileSize
new14.85 KB

Initial attempt at a D7 port. Definitely alpha code - please check it out and report your experience.

* Initial D7 port
*
* Designed to work in any fieldable entity.
* Legacy tokens (%nid, %author, %viewer) are gone since they don't play
* well with entities. [node:nid] and [current-user:uid] do not cause an extra
* entity load, so these tokens should perform similarly to %nid and %viewer.
* Token module must be enabled for the construction of Placeholder Token list used
* in editing, but the module need not be enabled to render the field itself.

sun’s picture

Status: Postponed » Active

Nice to hear. However, can you provide a proper patch, please? See http://drupal.org/patch

keithm’s picture

Status: Active » Needs review
StatusFileSize
new30.24 KB

As #24 but patch against viewfield-6.x-1.x-dev.

maxime.deg’s picture

Subscribing
Really useful module

danny_joris’s picture

subscribing

valderama’s picture

subscribing

keithm’s picture

StatusFileSize
new30.41 KB

Slightly cleaned up version of #26.

Note that to test this patch (and I hope some of you will), you should note three changes from the Drupal 6 version.

1. super_defaults is gone (i.e., "Use a common default value for all nodes if the user does not override it on the node form." on the edit screen), so if you create content before adding your viewfield, you need to go back and supply viewfield values for it just like any other field.

2. Viewfields can now be attached to any fieldable entity (e.g., nodes, comments, users).

3. The legacy tokens (%nid, %author, %viewer) are no longer supported because they don't blend well with the Drupal 7 notion of fieldable entities. When working with nodes, you can substitute [node:nid], [node:author], and [current-user:uid] respectively instead of these legacy tokens. Enable the D7 version of the token module to see a complete list of available tokens. The token module is not required for token substitution, only to see the list of available tokens.

I have successfully converted D6 viewfields to D7 using this patch. To do this, enable the viewfield module then use the Content Migration project in the D7 version of CCK to migrate the field data for D7. You separately have to make sure that your D7 viewfield uses D7 tokens (see #3 above). I haven't worked on migrating D6 tokens to D7 equivalents yet.

Please test this patch.

keithm’s picture

StatusFileSize
new30.65 KB

Please use this patch instead of #30. That one was created against the older pre-git version of viewfield-6.x.

ConradFlashback’s picture

Thanks keithm. I'm testing your patch and it works.
Sorry, about #30 3):
I have to pass the argument %nid of a view to the viewfield.
I dont understand this tip: "When working with nodes, you can substitute [node:nid], [node:author], and [current-user:uid] respectively instead of these legacy tokens. "
I create a view with an %nid argument. Then I create the viewfield in my content type.
Where I substitute the legacy tokens %nid with the [node:nid]?. I can't find the place in the option of viewfield-field.
Thanks

keithm’s picture

StatusFileSize
new13.12 KB

ConradFlashback: Thanks for your review. In #30, note (3) is for people who are used to using the %nid (legacy) token as an argument in their viewfield. What I'm saying there is to use [node:nid] when you want to pass the node id to a view. See attached.

ConradFlashback’s picture

Thanks keithm.
I have not the select list with "Article references" and the field "Arguments" in my version of viewfield, but only the title "default value" and its label.
I can't now verify my installation patch. I will verify tomorrow.

keithm’s picture

Did you choose any Allowed Views when setting up the field? There is a viewfield bug that is carried over from D6 #1052370: If you don't restrict list of allowed views, viewfield doesn't work. You currently have to choose at least one allowed view.

ConradFlashback’s picture

StatusFileSize
new110.41 KB

Yes, I've selected one allowed view. See attached.

keithm’s picture

StatusFileSize
new37.02 KB

ConradFlashback: I haven't been able to reproduce your bug yet. Would you please use the attached patch, which fixes some other problems I found, and try again? If you still have the problem, I will need you to give me the steps to reproduce it. Thanks.

ConradFlashback’s picture

StatusFileSize
new208.71 KB
new36.2 KB
new29.44 KB
new51.42 KB

keithm: OK, now the default value works. Thanks.
I attach 4 images with my work with VF for D7 because the field does not appear in the node.
The process is the same that I use with VF for D6, please confirm me that is right also with this version:
1) I create the view with nid argument
2) I create VF field in content type with token association
3) I create content
4) VF doesn't appear
thanks for all

mraichelson’s picture

subscribing

keithm’s picture

ConradFlashback: Nice images and good description of the problem. It looks like you are setting everything up right. I have only seen your problem when the view itself is broken.

Could you please confirm that you are running latest views-7.x-3.x-dev and that your view previews correctly with the nid you are trying to pass? Another way to verify is to create a page display that accepts your nid argument, and verify it works.

alduya’s picture

@ConradFlashback: I had the same problem. Removing the argument form the view (not the view field) solved the problem for me. But I guess this is not the expected behavior.

@keithm: I wanted to configure the view field to always use the default value, but this gave an error "Multiple views are not supported if force default is enabled." while the number of values was set to 1.
I found that on line 131 of viewfield.module:
<?php if ($settings['force_default'] && $field['cardinality'] !== 1) { ?>
needed to be:
<?php if ($settings['force_default'] && $field['cardinality'] !== '1') ?>{
or:
<?php if ($settings['force_default'] && $field['cardinality'] != 1) { ?>

Thank you for the work you have already done.

alduya’s picture

I made a mistake. Removing the argument only solved part of the problem.
By removing the nid argument, results from all the nodes were showing. I didn't notice that right away.

After some more digging around I found that it is the function viewfield_views_query_alter that prevents the viewfield to show. This function prevents views from loading the node containing the view.

I guess it is up to the maintainer of this module to decide whether or not to allow to load the node that contains the view. Maybe this can be solved with a checkbox 'Allow loading of the node containing the view'?

keithm’s picture

I am not having a problem using a view with an argument ('Contextual Filter' in the new Views 3 terminology) referenced by a Viewfield.

The following works for me.

  1. Create an content type Article Reference and give it a node_reference field named Referenced Article.
  2. Create a view, Article References, filtered by the Article Reference type, and with a contextual filter (argument) on Referenced Article, and with the Title field displayed. The Referenced Article contextual filter will expect a nid as argument.
  3. Create a Viewfield in the Article type with view name: Article References and argument: [node:nid].
  4. Create two pieces of content: Article and an Article Reference. In the Article Reference, assign the 'Referenced Article' field to the nid of your Article.
  5. Test the Article References view by previewing it with the nid of your Article. You should see the title of your Article Reference.
  6. View your Article, and you should see the Article Reference in the page.

If you are having a problem, I need the exact steps to reproduce your problem.

alduya: thanks for the cardinality fix. The call to hook_views_query_alter() is there to prevent infinite recursion, and was there in D6 as well.

keithm’s picture

StatusFileSize
new37.01 KB

Latest patch. Cardinality bug from #41 fixed. Moved 'allowed_views' setting to more appropriate instance (bundle) level.

so4’s picture

subscribing

robertom’s picture

Status: Postponed » Needs review

subscribe

jamsilver’s picture

StatusFileSize
new36.88 KB

For my own benefit more than anything else - here is a re-roll of patch #44 that applies cleanly to the latest commit in the git repo (60c15d).

valderama’s picture

I am using this early port of viewfield and in combination with a link field I get this error (when viewing the node which has a link field):

    Notice: Undefined index: vname in theme_viewfield_formatter_default() (Zeile 24 von C:\_dev\xampp\htdocs\Inostudio\qs2m_website\sites\all\modules\_fields\viewfield\theme\viewfield.theme.inc).
    Notice: Undefined offset: 1 in theme_viewfield_formatter_default() (Zeile 24 von C:\_dev\xampp\htdocs\Inostudio\qs2m_website\sites\all\modules\_fields\viewfield\theme\viewfield.theme.inc).
    Notice: Undefined index: vargs in theme_viewfield_formatter_default() (Zeile 25 von C:\_dev\xampp\htdocs\Inostudio\qs2m_website\sites\all\modules\_fields\viewfield\theme\viewfield.theme.inc).
    Notice: Undefined variable: entity_info in field_views_field_default_views_data() (Zeile 177 von C:\_dev\xampp\htdocs\Inostudio\qs2m_website\sites\all\modules\_views\views\modules\field.views.inc).
    Notice: Undefined variable: entity_info in field_views_field_default_views_data() (Zeile 178 von C:\_dev\xampp\htdocs\Inostudio\qs2m_website\sites\all\modules\_views\views\modules\field.views.inc).

I guess that viewfield somehow disturbes the link field in some hook, probably.

NOTE: I am not having both, viewfield and link field, on the same node.

keithm’s picture

Assigned: Unassigned » keithm
Status: Needs review » Active

I have been added as co-maintainer and I plan on releasing a D7 dev version in the next couple of weeks. I suggest you wait for that version. All of the patches listed above this comment are experimental and will not necessarily upgrade cleanly to the official version.

iler’s picture

Looking forward to get the dev version for our ongoing development project! A nice way to test this module for bugs before release :)

jason.fisher’s picture

+011100110111010101100010011100110110001101110010011010010110001001100101

keithm’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new28.53 KB

Patch from 6.x-2.x for a new 7.x-2.x branch. This is a straight patch that only handles node entities. I plan to roll out full D7 entity support and theming cleanup once this gets in.

ngstigator’s picture

subscribe

chemicalroman’s picture

subscribe

AndrzejG’s picture

subscribe

keithm’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Status: Needs review » Closed (fixed)

I pushed a development release 7.x-2.x today in http://drupalcode.org/project/viewfield.git/commit/8bdd173. Please consult the Viewfield project page for important usage information.

This issue has become rather long and has served its purpose. As problems are found in the 7.x branch, please open new issues for them. Thanks.

ConradFlashback’s picture

thanks keithm. I will test as soon as possible your dev version.