You have been so kind to follow my suggestions in #337299: Wish list: new filter syntax!, so may I ask you to add additional options "teaser" and "full"? If the "teaser" option is added, the tag is rendered in teaser view only, if "full" is specified, the tag is rendered in full node view only. If none is specified (the default), it is the same as "teaser,full", i.e. the tag is rendered in teaser and full node view.
A use case (for me) is the insertion of images using texy! and linodef as described in #335191: CCK fields formatting (support Image- and Filefield)#4. Currently I resize the images in teaser view using css, with this new options I could a) omit the display of the image in teaser view or b) load the thumbnail (and not the full image) in teaser view.
I could also imagine other use cases for this.
If you add a "block" option, you can extend this to block views, too! ;)
Thank you!
Comments
Comment #1
Pepe Roni CreditAttribution: Pepe Roni commentedComment #2
Roi Danton CreditAttribution: Roi Danton commentedSorry for the late reply, I only checked the "My Issues" queue so I haven't seen the new posts here.
So you want an option for field tags with "teaser" and "full", like set in the display formatter options for fields of a content type (e.g. admin/content/node-type/story/display)?
Currently Linodef retrieves the field values by loading the node object (linodef-filter.inc, line 241, 271ff):
node_load() doesn't heed any display settings (teaser, full) and always loads the plain field value. Therefore a step must follow to get the teaser and full view for the field.
D6 does this with node_view (e.g. for the front page) but this returns only HTML (and this function is removed in D7 either). Additionally the function node_build_content returns an object containing the filtered field (which is already bad for our purpose) but doesn't heed the display options of a field (always the full field is loaded here, too, though the node state can be set to teaser or full).
So we have to use a function of CCK for this purpose. Yet I haven't had a decent look in their API so I don't know where CCK sets the display for its fields. Surely the Field API of D7 is a good start.
Or maybe you know already how to retrieve the display formatters set for a certain field of a certain node type?
Comment #3
Pepe Roni CreditAttribution: Pepe Roni commentedSorry, if I was not clear enough in my question. It is not a matter of how to display the inserted content, but what to display in different views. For example, in teaser view I want to insert the content of field1, in full view the content of field2, and not in teaser view the teaser view of field1 and in full view the full view of field2. This would be another issue, and can be handled, in my opinion, with cck fields then.
Comment #4
Pepe Roni CreditAttribution: Pepe Roni commentedComment #5
Roi Danton CreditAttribution: Roi Danton commentedI've searched Drupal for "node teaser full filter" (and other keyword combinations however this seemed to be the most promising) but there seems to be no way for querying the view of a node (teaser of full) with a function out of Linodef due to Drupals input filter behavior. I'm using
node_load()
and it doesn't include the display state since it doesn't matter for loading the node.When the input filters are applied to a node then there is no information about the node view (teaser or full) available. This happens afterwards with the theme module.
See this for a discussion about Drupals input filter and contextual information: #67969: Support for separate image sizes for teaser and body.
Other module writers had similar assumption, e.g. #181856: Add teaser/full option for syntax arguments.
Maybe there is a way/function/object (changing the default workflow or caching things or similar). If someone knows one share your knowledge here, please. :)
Comment #6
Roi Danton CreditAttribution: Roi Danton commentedFurthermore in D7 teasers will likely be overhauled, see #372743: Body and teaser as fields. If the patch turns out as it is planned and will be accepted then you will be able to define custom text as teaser so this feature requested here won't be needed.
Comment #7
Pepe Roni CreditAttribution: Pepe Roni commentedThank you for your reply. I've found http://drupal.org/project/teaserthumbnail, that probably might fit my needs. What I want is thumbnails for images within teaser view and fullsize images in full node view (what the requested filter option should do).
Thanks again for your valuable work!
[edit]: teaserthumbnail does not work as expected. But I have found a filter module, that includes different filters for teaser and full view (according to its documentation): http://drupal.org/project/filter_macros. Perhaps that may help you to include the desired functions into linodef?
Comment #8
Roi Danton CreditAttribution: Roi Danton commentedThanks for looking for possible solutions!
Filter macros uses hook_nodeapi to edit the node's content (for teaser and body view) directly in the database. This may be valid for filter macros (which isn't a filter module by itself but to support other filter modules) however this doesn't fit to a filter module (as far as I know): E.g. the dynamic replacement of filter tags won't work properly then.
Comment #9
Pepe Roni CreditAttribution: Pepe Roni commentedYeah, that seems fine to me!
The option, what to show in full view and what to show in teaser view can not be dynamic and does not need to be dynamic. Separate a filter directive with this option into two filter directives when saving the node, one for teaser and one for full view and apply your filter dynamically to these directives. When in teaser view, your filter will only see the filter directive for the teaser and when in full view it will only see the filter directive for full view.
What do you think about this?
Comment #10
Roi Danton CreditAttribution: Roi Danton commentedCould you specify filter directive, please?
Comment #11
Pepe Roni CreditAttribution: Pepe Roni commentedA filter directive is the expression between the two [] including these characters.
Comment #12
Roi Danton CreditAttribution: Roi Danton commentedAh okay, I understand. When using hook_nodeapi that could be applied at action 'presave' or 'view' (if view is applied before the filters what I don't know yet). However, lets using 'view' so the content saved in the database is untouched by Linodef (in comment #8 I wasn't aware of 'view' action). Then the function would be like this:
This will only work for tags in node body fields and not in CCK fields. Furthermore it will have a performance impact on every node view so using 'presave' instead of 'view' might be better. But then Linodef would change the database content directly what isn't the purpose of a filter. Finally the most important fact against this method is the fact that Linodef won't know when to apply that search and replace and when not. It shall never be applied on body fields which use an input format that doesn't contain the Linodef filter. Currently I don't know how to retrieve this information therefore there is no patch.
Comment #13
Roi Danton CreditAttribution: Roi Danton commentedThe arg() function could be a solution. So
arg(0) == 'node'
could fit to check if we are currently in teaser or full view.Already known issue:
However, is there still a need for this feature (tag awareness for the current context type (visibility options, CCK formatters)) so I should do further investigations?
Comment #14
Roi Danton CreditAttribution: Roi Danton commentedNever mind, I got it. I've added an option called 'visibility' to control in what context the tag is visible.
Comment #15
Roi Danton CreditAttribution: Roi Danton commentedThis has been committed, too.