A couple quick questions regarding taglist and fields.

1. I seem to be having trouble creating a taglist of a specific field when that field isn't in every content type. When trying to view the taglist, I get the following error.

Field field_document not found or is an unsupported field type. Supported fields must store a (single or multiple) value such as textfields & datefield (from date).

Should this be possible?

2. To get around this, I've added a display to a view which only lists the field I'm interested in. In this case, a filefield using a display of "Generic Files" (although I'm not sure this matters). The resulting taglist just lists links to the nodes ( #23: Comment Rating ) rather than links to the files. Does linodef support linking to filefields in Views based taglists?

Thanks.

CommentFileSizeAuthor
#5 taglist.patch2.65 KBimclean
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Roi Danton’s picture

Title: Taglists and fields » Add file/image/reference field support for taglists
Category: support » feature

1. I assume you have tried to embed the filefield. That this does not work is not related to content type issues but due to the fact that only fields with values ($field_database_info['columns']['value']) are supported. File/reference fields use ids and don't store the content itself. Taglists aren't capable to retrieve the file from its id yet (need of additional functions for each fieldtype). Marked this issue therefore as feature request. Patches are welcome (linodef_taglists/includes/taglist.load.inc).

2. The same happens when using views. Only fields with values are included. File/reference fields only store ids and aren't included therefore. This is actually a feature request but it won't matter anymore if #692520: Use rendered output of views can be added.

So it should be added to the documentation that file/image/reference fields do not work with taglists yet. If you'd like to add that information when creating taglists and exclude file/image/reference fields from the list available please patch linodef_taglists/includes/admin.inc -> linodef_taglists_wizard_source_form & linodef_taglists_wizard_form_source_options.

Sorry for the missing documentation and thanks for reporting!

imclean’s picture

Thanks for the quick response!

1. I can embed it using the normal syntax ( [#45:field_document] ) but as you've pointed out it does not work with taglists yet.

On a similar note, while I can embed filefields manually (display "Generic Files"), the embedded link uses the file name rather than description, when it exists, for the link text.

2. Okay, thanks for the info. I've tried using a computed field to generate the link for the View to display, but thinking about it now that may be overkill. I could probably just embed the computed field directly from an appropriate taglist.

Roi Danton’s picture

On a similar note, while I can embed filefields manually (display "Generic Files"), the embedded link uses the file name rather than description, when it exists, for the link text.

Try to use a different formatter with the option formatter. By default (when option formatter is not set) Linodef uses the formatter set for the current content type and build mode (teaser/full).

When using a computed field than heed that views (and therefore Linodef taglists) does not support computed fields that do not store their value in database. See #665584: Select any field for view taglists.

imclean’s picture

Try to use a different formatter with the option formatter. By default (when option formatter is not set) Linodef uses the formatter set for the current content type and build mode (teaser/full).

This is what I've done with the "Generic Files" formatter. This formatter does use the Description as the link text in the node with the filefield in it. When the filefield is embedded in another node using Linodef the filename is used. I can see that the correct formatter is being used by Linodef because is it displaying the document icon to the left of the link.

I think I've done everything correctly. Perhaps I should try manually setting the formatter anyway.

imclean’s picture

FileSize
2.65 KB

Here's a patch which adds filefield support for taglists, very much in need of testing and feedback. There are probably more efficient ways of doing this, some of the code is duplicated. As you've mentioned, functions for each field type would be the way to go.

I've used the file description as the description, or the file name if there is no description.

As I generally have one filefield which is used in a number of content types, I've added the content type to the description. It's written for my specific situation so I imagine there's scope for adding some field-specific settings.

Edit: the patch seems a bit messy. I use 2 spaces to indent code while taglist.load.inc seems to use tabs. What's the usual Drupal way of formatting?

imclean’s picture

Status: Active » Needs review

Changed status.

Roi Danton’s picture

Status: Needs review » Needs work

The functionality of the patch is fine. Thanks for providing!

However before commitment the duplicated code should be removed (and support for ref fields added). I.e. leave the first 18 lines of the patch as is and separate the rest also from $fieldvalues['columns']['value']. E.g. use $description for $ergebnis->value and $filelabel etc. Then it will be faster to add support for reference fields, too.

I use 2 spaces to indent code while taglist.load.inc seems to use tabs. What's the usual Drupal way of formatting?

Drupal uses 2 spaces for indentation. I use tabs in all my projects for good reason (the never ending story ;) ). If you want to use code review for Linodef than consider applying this patch to Coder module: #516800: Line indentation style should be optional or of minor priority (tabs instead of spaces). Of course you are free to stick to 2 spaces when providing patches - converting indentation is a matter of seconds.

Shishka’s picture

Title: Add file/image/reference field support for taglists » Descripton for multiple filefield?
Assigned: Unassigned » Shishka
Status: Needs work » Needs review

I try to use Linodef and 3 filefields, after this patch nothing not working, anybody testing with multiple filefields?

Also would be nice to have Description as option [#nid:field_,description]

imclean’s picture

Title: Descripton for multiple filefield? » Add file/image/reference field support for taglists
Assigned: Shishka » Unassigned
Status: Needs review » Needs work

Reverting status. I don't have time for this at the moment.