Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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…

  1. …override the variables setup by textpattern’s pretext() routine before the saveComment() function is called. Just hooking the comments.save event is too late for overriding the vars (similarly for hooking the textpattern event.)
  2. …override some of the already extracted $prefs based on values set by textpattern’s pretext() 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

#2 2008-06-23 04:26:40

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Proposed new public-side event: pretext_end

Yes, this sounds nice indeed and would be really helpful :)

Offline

#3 2008-06-23 14:54:50

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#4 2008-06-23 15:07:38

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

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

#5 2008-06-23 18:19:42

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

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

#6 2008-06-23 18:26:30

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,448
Website GitHub

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

#7 2008-06-23 18:29:42

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

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

#8 2008-06-23 18:35:16

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#10 2008-06-24 13:06:27

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

#12 2008-06-24 16:29:15

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

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

Board footer

Powered by FluxBB