Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Callback to alter article html before saving
My “authors” often import their articles from some Office application, royally ignoring Textile, TinyMCE and whatever else. The result is fubar. There is nothing I can do about it, except cleaning articles html. Would it be possible to add a callback that allows for Body_html/Excerpt_html
modification right before article save?
Edit: actually, all article fields should be modifiable before save.
Last edited by etc (2012-10-18 10:42:34)
Offline
Re: Callback to alter article html before saving
In Textpattern 4.6 we will introduce textfilters which essentially define how raw text is translated into the final HTML. This callback textfilter
/ filter
exists in the latest development version.
See wet_sample_textfilter_postprocessor for a sample plugin.
Offline
Re: Callback to alter article html before saving
Very cute, thank you, Robert, will play with it! Will it be called only for Body
and Excerpt
, or in some other contexts too?
Since heavens have heard me, I would also like to have access to the whole article array at once, for example, to be able to auto-extract and save Keywords
from the Body
. Would article_ui
callback allow for such alteration? Why $rs
is passed by reference to callback_event_ref
, but by value to article_validate
?
Offline
Re: Callback to alter article html before saving
etc wrote:
Will it be called only for
Body
andExcerpt
, or in some other contexts too?
We apply filters to the excerpt and the body and nowhere else. Look into textile_main_fields() in txp_article.php. Since this is very new code we do not have much documentation around besides the actual code. It might also change slightly until the final release.
I would also like to have access to the whole article array at once, for example, to be able to auto-extract and save
Keywords
from theBody
.
You might want to look into article partials and how Textpattern uses AJAX on the article tab. Here’s a sample plugin. I’ve written a bit about article partials here.
Offline
Offline