Posted by TomMynd on January 14, 2009 at 7:47pm
Jump to:
| Project: | Typogrify |
| Version: | 6.x-1.x-dev |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (won't fix) |
Issue Summary
Hi,
I wonder if and how it would be possible to use the filter for the title of a node. Has anyone wrote a hook or something to get this to work?
Thanks in advance... Tom
Comments
#1
That is a good suggestion, thank you.
I figure that should be fairly easy to add by implementing the 'view' op of hook_formapi.
#2
Hmm... maybe I missing something, but which hook do you mean?
#3
Hi,
some small inserts regarding our short talk in Cologne: Not only the title should be "typogrifyabled" - e.g. content that is coming from CCK fields.
#4
I believe mikl meant to say the "view" op of hook_nodeapi. That would let Typogrify jump in and filter the title before output. However titles don't have an input format associated with them so really the Typogrify module would need a little admin form with options for the title specifically for it to make sense. However this should be doable.
CCK text areas should already have the ability to use Typogrify if they are set to use input filters and you have Typogrify enabled on the filter. CCK text fields however are in the same boat as the title where they don't have an associated input filter. So those would be different. Technically Typogrify could offer up a CCK "formatter" as an option for text fields, with settings in the admin also.
I'm certainly not trying to create work here :) but I do think the title feature would be worthwhile! After I wrap up my current project I'll look into adding it and submitting a patch if the maintainer is interested.
#5
Yeah, moonshine is correct on the nodeapi part – I actually thought of an even better way to do it, namely the preprocess_node theming hook. That should be safer, since the nodeapi approach might cause us to inject HTML in places where it ought not to be (page titles, RSS feeds, etc).
However, I'm unconvinced that this would be a good idea. Typogrify uses some rather complex regular expressions to do its work, and running those on every page view (as would be the case were we to use preprocess hooks) would be a major performance hit. The only reason that Typogrify is usable on body text is that the result of the filtering is stored in the filter cache.
#6
Any progress on title? Widont int title would be useful.
#7
Given that Typogrify intoduces HTML and/or HTML entities to the strings it processes, I think this would have to be to be done directly in the template, or perhaps in a preprocess hook, if it is to be considered safe.
If it's just widont you want, this will do the trick:
<?phpmodule_load_include('class.php', 'typogrify');
$text = Typogrify::widont($text);
?>
#8
Thanks!
#9
Unless someone can come up with a way we could do this without risking HTML-leakage into JavaScript, titles, attributes, etc., I'm considering this a "won't fix". Doing it on your own theme isn't that hard, and I'd rather not take the chance of doing something that would create a security issue.