Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2024-01-22 10:11:08

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

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

#2 2024-01-22 11:42:27

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

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

#3 2024-01-22 14:16:32

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

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

#4 2024-01-22 14:59:57

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

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

#5 2024-01-22 23:10:56

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

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:

jcr_writenav_buttons


TXP Builders – finely-crafted code, design and txp

Offline

#6 2024-01-23 00:12:49

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

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

#7 2024-01-23 08:57:30

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

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

#8 2024-01-23 09:16:08

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

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

#9 2024-01-23 13:50:19

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

Re: Plugin to restore prev/next article in write pane?

etc wrote #336454:

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?

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

#10 2024-01-25 10:01:43

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

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

#11 2024-01-29 17:09:43

etc
Developer
Registered: 2010-11-11
Posts: 5,054
Website GitHub

Re: Plugin to restore prev/next article in write pane?

If someone has a chance to test @jacob plugin in recent dev on a pre-mysql8 server, I would be grateful for the feedback.

Offline

Board footer

Powered by FluxBB