Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Plugin to restore prev/next article in write pane?
I’m sure I saw a plugin somewhere that restored the old prev/next article buttons in the write pane but don’t seem to be able to find it. Can anyone point me in the right direction?
EDIT: have just realized they are still there in the source code, just commented out in /textpattern/include/txp_article.php
. The changes occurred in this commit.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Plugin to restore prev/next article in write pane?
It does not look possible to inject these links exactly where they were, but there is still two available pluggable_ui
entry points: ('article_ui', 'markup')
and ('article_ui', 'extend_col_1')
. So, all you need is
register_callback(function($event, $step, $pre, $rs) {
return article_partial_article_nav($rs);
}, 'article_ui', 'extend_col_1', 0);
Offline
Re: Plugin to restore prev/next article in write pane?
etc wrote #336446:
So, all you need is
Yes, for as long as the function sticks around in core. There’s a chance that if it’s unused then someone may delete it in future.
I happen to think the next and previous buttons are quite handy in some situations but it depends on your site structure. Blindly navigating based on article ID alone is perhaps not much use. But navigating to the next article in the category or section you are in could be useful.
The trouble is that there are many different use cases for this so choosing one out of the box is difficult. And making it configurable is a little messy.
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: Plugin to restore prev/next article in write pane?
etc wrote #336446:
It does not look possible to inject these links exactly where they were, but there is still two available
pluggable_ui
entry points:('article_ui', 'markup')
and('article_ui', 'extend_col_1')
. So, all you need is
register_callback(function($event, $step, $pre, $rs) {...
Thank you, that’s a good pointer.
Bloke wrote #336447:
Yes, for as long as the function sticks around in core. There’s a chance that if it’s unused then someone may delete it in future.
One could, of course, carry that function from core to a mini plugin with another name. [note to self]
I happen to think the next and previous buttons are quite handy in some situations but it depends on your site structure … The trouble is that there are many different use cases for this so choosing one out of the box is difficult. And making it configurable is a little messy.
I agree, It’s useful sometimes but rarely used in normal use. In this particular case I need to go through many articles that I’ve ported over from another system one by one to check for and clean up anomalies, and wanted a quicker way of stepping through the articles. Removing the commented out passages in txp_article.php proved quickest.
I seem to remember seeing a plugin that brought back that functionality – one of adi’s maybe? except I couldn’t find it.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Plugin to restore prev/next article in write pane?
I just put 2+2 together and put up a plugin that does what you suggested:
TXP Builders – finely-crafted code, design and txp
Offline
Re: Plugin to restore prev/next article in write pane?
jakob wrote #336449:
I just put 2+2 together and put up a plugin that does what you suggested
Nice!
One thing you might want to do is either:
A) Wrap your code and function in a (plugin prefixed) class and instantiate it in the if ($event == 'article') {}
block.
B) Leave it as is in the global scope but prefix/rename the function with your developer prefix and plugin name. Like jcr_writenav_buttons()
or something.
The reason is that because we’re using article_partial_article_* in core, there’s a (very slim, admittedly) chance we may introduce a function with the same name as yours, which will mean your plugin breaks when PHP finds two identically named function definitions.
Not vital at all, but just good practice for code longevity.
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: Plugin to restore prev/next article in write pane?
Ah yes, that’s better practice: jcr_writenav_buttons it is.
(any further advice welcome, specifically whether the nav function within the class is better as protected or public)
TXP Builders – finely-crafted code, design and txp
Offline
Re: Plugin to restore prev/next article in write pane?
BTW, why core is still retrieving next_id
and prev_id
, wasting 2 db queries, if they are not used by core itself? Shouldn’t this be delegated to plugins too?
Offline
Re: Plugin to restore prev/next article in write pane?
etc wrote #336454:
BTW, why core is still retrieving
next_id
andprev_id
, wasting 2 db queries, if they are not used by core itself? Shouldn’t this be delegated to plugins too?
Probably. Depends if we’re going full hardcore and ripping this functionality out or just softly removing it for the time being and seeing if anyone misses it.
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: Plugin to restore prev/next article in write pane?
These links availability is subjected now to has_handler('article_ui', 'extend_col_1')
condition. Also, the sort order should (in MySQL8+) use the column selected on the article list tab. If SQL window functions behave well on large datasets, we might consider using them more extensively.
Offline
Offline