Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2008-06-23 02:04:49
- net-carver
- Archived Plugin Author
- Registered: 2006-03-08
- Posts: 1,648
Proposed new public-side event: pretext_end
Hello,
I’d like to suggest the introduction of a new public interface event: pretext_end
in publish.php (following the introduction of textpattern_end
).
My reasoning (at present) is to allow for writing comment plugins that get a chance to…
- …override the variables setup by textpattern’s
pretext()
routine before thesaveComment()
function is called. Just hooking thecomments.save
event is too late for overriding the vars (similarly for hooking thetextpattern
event.) - …override some of the already extracted
$prefs
based on values set by textpattern’spretext()
function.
Something like this…
$pretext = !isset($pretext) ? array() : $pretext;
$pretext = array_merge($pretext, pretext($s,$prefs));
extract($pretext);
callback_event('pretext_end'); # New event
…would do the job nicely.
Last edited by net-carver (2008-06-23 04:52:53)
— Steve
Offline
Offline
Re: Proposed new public-side event: pretext_end
And it would save me from hacking the file. :)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Proposed new public-side event: pretext_end
And adds a gratifying symmetry to proceedings :-)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Proposed new public-side event: pretext_end
r2917. I’ve amended your proposal it wee bit to give a plugin the chance to modify $pretext
.
Offline
Re: Proposed new public-side event: pretext_end
Oh now that’s a cool place for it!
Thank you fine sirs for a well proposed and executed modification, that’s going to help enormously.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Proposed new public-side event: pretext_end
I generally think public event hooks are undervalued. From a gut feeling, I’d think we could fuel a lot of new plugin approaches with an extended clever set of event broadcasts. Open for well-formed suggestions…
Offline
Re: Proposed new public-side event: pretext_end
To keep naming consistent, I’d vote for pretext_end instead of pretext_set (similar to textpattern_end).
Is there any other use for this, except for comments?
Because if it’s just for comments it’s more efficient to just trigger a callback before a comment is saved.
Offline
#9 2008-06-24 01:46:32
- net-carver
- Archived Plugin Author
- Registered: 2006-03-08
- Posts: 1,648
Re: Proposed new public-side event: pretext_end
Wet
Fantastic! Yes, better to trigger the event before $pretext
is extracted; much neater.
Thank you!
Last edited by net-carver (2008-06-24 01:47:29)
— Steve
Offline
Re: Proposed new public-side event: pretext_end
That was quick. Thank you. I can remove the hack now. :)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
#11 2008-06-24 13:18:29
- net-carver
- Archived Plugin Author
- Registered: 2006-03-08
- Posts: 1,648
Re: Proposed new public-side event: pretext_end
Stuart
be careful of the name change there. If you are running the dev version then make sure you and change pretext_end
to pretext_set
in your plugin and all should be well.
— Steve
Offline
Re: Proposed new public-side event: pretext_end
Yep. Done that bit Steve. I spotted from Robert’s and Ruud’s comments that there was a slight difference to what you had asked for so I was forewarned. All is well. :)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline