Posted by mongolito404 on July 29, 2009 at 1:32pm
| Project: | Taxonomy Image |
| Version: | 6.x-1.6 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
Hi,
The Content Taxonomy module defines a field type for taxonomy terms. Here is a simple module that provides formatters using Taxonomy Image for this type. Formatters are provided for the ORIGINAL profile and available ImageCache presets.
| Attachment | Size |
|---|---|
| content_taxonomy_image.zip | 1008 bytes |
Comments
#1
Thanks for creating this
#2
works as expected
+1 for including this as a contribution
one feature might need to be added though
when image does not exist for a term the regular text link should be displayed (current implementation shows nothing)
#3
If you need to display image + text link then replace following function
<?phpfunction theme_content_taxonomy_image_formatter($element){
if (!empty($element['#item']['value'])) {
$term = taxonomy_image_get_object($element['#item']['value']);
_content_taxonomy_localize_term($term);
$tname = " ". taxonomy_image_tt("taxonomy:term:$term->tid:name", $term->name);
return l(taxonomy_image_display($term->tid, NULL, $element['#formatter'], array('wrapper' => FALSE)).$tname, 'taxonomy/term/' . $term->tid, array('html'=>TRUE));
}
}
?>
It also solves problem with terms with no image from being displayed
#4
This is so great! Thank you!
#5
Thanks for this. Do you know how I can have the image and link/text in its own div and assign a class?
#6
modify the formatter above
#7
Thank you Giorgos, though as I don't know much about PHP I'm not sure what to do exactly.
#8
Thank you for doing this.
Unfortunately I do not seem to make it work.
My config is:
- Drupal 6.16
- CCK 2.6
- Content Taxonomy 1.0-rc2
- Taxonomy Image 1.6
This is what I have done:
1. Installed and enabled Taxonomy Image
2. Installed and enabled your content_taxonomy_image module (content_taxonomy_image.zip)
3. Configured Taxonomy Image with ImageCache preset = ORIGINAL (see picture for screen shot of configuration)
4. Created taxonomy vocabulary (my example: Coffee)
5. Created taxonomy terms for that vocabulary (my example: each term is a type of coffee)
6. Inserted an image for each taxonomy term in that vocabulary (my example: pictures of coffee capsule)
7. Created content type: Coffee
8. Added Content Taxonomy Field: My favorite coffee; and linked it to vocabulary Coffee
When I create a new content: Coffee, the images are not displayed
Could you give me a hint of what I am doing wrong / forgot to do please?
Thank you!!!
#9
Sorry for the double entry. It took some time for the first entry to display after loading.
#10
#11
As announced this is a formatter for the Content Taxonomy field. Formatters are used to display the values of fields when viewing nodes. Not when creating a new node. What you seek is a widget for Content Taxonomy that use the images from Taxonomy Image. I'm not aware of any such widget.
#12
I see what you mean
Thank you for explaining the difference
#13
So, once it's installed and enabled, how do you work it?
#14
Please don't change category
this is still a feature request for the developer to incorporate when they have the time
but needs a proper patch
#15
The answer to my own question:
Install and enable the formatter.
Edit your content type.
Show the Display Fields tab.
Find your content taxonomy field name and scan over to
Full Node (or Teaser if that's what you want).
Select "as image linked to term".
Save.
Thanks for your help GiorgosK ;)
#16
@GiorgosK: What do you mean by "needs a proper patch" ? The archives contains two new files. No Taxonomy Image original files has been modified. Sure, adding the files can be done with a .patch file but it's not really needed.
#17
If you want the option to not link the image to the term then replace with this file instead.
#18
Any chance this module could be used in Views? I've tried it, but I can't get it to work...
#19
@chimychimy
are you sure your question is relevant to this issue ?
if not please open up a support or feature request ..
#20
This works in views just make sure you select "As image linked to term" in the format dropdown when configuring your view field.
Plus also works in the node.
Now I just need to modify so the image doesn't link to the term.
#21
Thanks a lot for this. It works as expected.
#22
#17 This modification gives you an extra field in views also as to display the field as image only rather than the default Image linked to term.
But when i select just "image" it still links to its term - has anyone got this to work in views correctly?
#23
hello,
thanks for the patch.
Is it possible to display the term title if no image is linked to the term ?
Thank you in advance for your suggestion,
Xavier
#24
this is a hack so far
but I believe this is what I have accomplished in #3
#25
hello, thanks for the reply.
In fact, I think that #3 displays title base on the image attribute . So, if no image, no title.
I would like to display the $term->title if no image.
#26
No it does not work the way you describe the name is the name of the taxonomy
not an attribute
if it does not do what you want this code is a hack
you have to hack it to work the way you want to
the maintainer does not seem to have time to include it in core
and here is a quick modification which I have not tested but should work
<?phpfunction theme_content_taxonomy_image_formatter($element){
if (!empty($element['#item']['value'])) {
$term = taxonomy_image_get_object($element['#item']['value']);
_content_taxonomy_localize_term($term);
$display = taxonomy_image_display($term->tid, NULL, $element['#formatter'], array('wrapper' => FALSE)), 'taxonomy/term/' . $term->tid, array('html'=>TRUE);
if($display == "")
$display = " ". taxonomy_image_tt("taxonomy:term:$term->tid:name", $term->name);
return l($display);
}
}
?>
#27
#17 doesn't work, i only want to display taxonomy image and don't want it to link to taxonomy. Any help?
#28
Might have done something wrong ... but when I apply #26, replacing the original function theme_content_taxonomy_image_formatter($element) in the content_taxonomy_image.module file I get this error message:
Parse error: syntax error, unexpected ',' in /var/www/web1009/html/sites/all/modules/content_taxonomy_image/content_taxonomy_image.module on line 45
I really don't know much about php so I can't work it out myself. Help would be appreciated. The original file works perfectly.
One question though. The way it is displayed right now, when I assign more than one term the images are listed underneath each other.
image1
image2
image3
I would love to display them in one line like
image1 image2 image3
Like I said: don't know much about php and therefore I have no idea how to get that done. Any ideas??
#29
Hello,
thank you for this module.
Do you think it could be possible to add a class to the term link ?
Thanks again :)
#30
Answer to #22 and #23 and #27 :
There was an error in #17, you have to change the function into this one :
<?phpfunction theme_content_taxonomy_image_formatter($element, $link = FALSE) {
if (!empty($element['#item']['value'])) {
$term = taxonomy_image_get_object($element['#item']['value']);
_content_taxonomy_localize_term($term);
$display = taxonomy_image_display($term->tid, NULL, $element['#formatter'], array('wrapper' => FALSE));
return $link ? l($display, 'taxonomy/term/' . $term->tid, array('html'=>TRUE)) : $display;
}
}
?>
Here is the fixed version of the module.
#31
Actually there was still an error as 'arguments' key in hook_theme only works when using a template file.
#32
Actually, the last version #31 of the module broke my views.
All images disappeared; new links were provided :
ex: /sites/default/files/imagecache/icons_link/category_pictures/myimage.png where "icons" is the preset name. Of course the icons_link folder doesn't exist.
#33
Right. In my use case I set the formatter attribute manually, so I don't see the bug. Does this work better ?
#34
Same behaviour with this last module, the taxonomy images are not saved anymore.
I upload them but they disappear and don't seem to be saved. I set all imagecache permissions to 777 to make a test : same result.
What's even more weird is that if I create a view to display 3 nodes with same taxonomy image field (with or without a link to the term), the taxonomy image is displayed for only two rows... The code shows an empty field for this last row, no image at all.
The corresponding image is in the imagecache folder, displayed for only two rows and not displayed on the /admin/content/taxonomy/taxonomy_image page.
I'm lost... ^^
#35
I tested it and it works well on an empty Drupal. Even with imagecache. Does it works for you if you don't use an imagecache preset in the field's display settings ?
#36
@GaëlG This issue is supposed to be a request for inclusion of the module as "contrib" into the main Taxonomy Image module. Something which is obviously not happening. I made the request because, at that time, this seemed to be the easiest way to share my code.
For some time, Drupal.org now support sandbox projects. If I were still working on this module, I would create a sandbox for it. I recommend you, or somebody else, do it. It will allow this issue to be closed instead of being used to track your work on the module and new issues (a sandbox projects have their own issues queue). See http://drupal.org/node/1011196, http://drupal.org/node/1068950 and http://drupal.org/node/1053378.
#37
OK, I will consider this.
#38
Sandbox created here : http://drupal.org/sandbox/gaelg/1182358 I hope I did it not too bad...