Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2017-03-20 11:17:38

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

Re: Including article body inside another article

In 4.6+ this probably works to get the next/prev article id:

<txp:php>
    global $thisarticle;
    echo $thisarticle['next']['ID'];
    echo $thisarticle['prev']['ID'];
</txp:php>

Offline

#26 2017-03-20 12:46:07

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Including article body inside another article

etc wrote #304931:

In 4.6+ this probably works to get the next/prev article id

Is that valid also for non-core sort values like “position” (created by stm_article_custom order)?

Last edited by uli (2017-03-20 14:30:47)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#27 2017-03-20 14:04:59

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Including article body inside another article

etc wrote #304931:

In 4.6+ this probably works to get the next/prev article id:

I tested it and got:

Tag error: <txp:php> ->  Notice: Undefined index: ID while parsing form pagination-next on page section

Offline

#28 2017-03-20 14:20:40

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

Re: Including article body inside another article

uli wrote #304937:

Is that valid also for non-core sort values like “position” (created by stm_article_custom)?

If stm_article_custom is just creating and populating some custom field — yes, it should. Otherwise I don’t know. :-)

michaelkpate wrote #304938:

Tag error: <txp:php> -> Notice: Undefined index: ID while parsing form pagination-next on page section...

Yes, it must be $thisarticle['next']['thisid'], sorry. And you probably have to call <txp:link_to_next /> before, to populate it.

Offline

#29 2017-03-20 14:35:21

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Including article body inside another article

etc wrote #304940:

If stm_article_custom is just creating and populating some custom field — yes, it should. Otherwise I don’t know. :-)

Yes, it does. (Uncertainty probably caused by my faulty plugin name, I meant stm_article_order


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#30 2017-03-20 15:23:57

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Including article body inside another article

etc wrote #304940:

Yes, it must be $thisarticle['next']['thisid'], sorry.

I never like to use raw PHP code where a plugin would work just as well and is so much cleaner.

// TXP 4.6 tag registration
if (class_exists('\Textpattern\Tag\Registry')) {
Txp::get('\Textpattern\Tag\Registry')
->register('mkp_next_id')
->register('mkp_prev_id')
;
}

function mkp_next_id()
{
    global $thisarticle;
    return ($thisarticle['next']['thisid']);
}

function mkp_prev_id()
{
    global $thisarticle;
    return ($thisarticle['prev']['thisid']);
} 

I actually think, though, these might be useful tags to add to 4.7.

Offline

#31 2017-03-22 19:49:33

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: Including article body inside another article

michaelkpate wrote #304942:

I actually think, though, these might be useful tags to add to 4.7.

Cheers to new useful tags.


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#32 2017-03-23 08:59:08

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

Re: Including article body inside another article

michaelkpate wrote #304942:

I actually think, though, these might be useful tags to add to 4.7.

Would something like this do?

<txp:link_to_next>
    <!-- article tags are populated with the next article data -->
    <h3><txp:title /></h3>
    <txp:excerpt />
    ...
</txp:link_to_next>

Offline

#33 2017-03-23 10:24:34

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

Re: Including article body inside another article

etc wrote #304992:

Would something like this do?

I like your idea of making more content available to the existing tag. There are situations where you want to preview the next article with an image or perhaps some custom_field info.

Thinking aloud, would it be possible/useful to also add an optional attribute to the link_to_next to constrain next/prev to a particular criterion? I admit I haven’t thought it through.


TXP Builders – finely-crafted code, design and txp

Offline

#34 2017-03-23 10:34:47

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

Re: Including article body inside another article

jakob wrote #304995:

Thinking aloud, would it be possible/useful to also add an optional attribute to the link_to_next to constrain next/prev to a particular criterion?

You mean, like smd_horizon? If so, yeah, that’d make my hacky plugin obsolete, which is good in my book.

Next article in category xyz, next article in section abc, next article with custom_field book_title, …

Last edited by Bloke (2017-03-23 10:37:42)


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

#35 2017-03-23 14:20:05

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

Re: Including article body inside another article

jakob wrote #304995:

I like your idea of making more content available to the existing tag. There are situations where you want to preview the next article with an image or perhaps some custom_field info.

This one is committed now, invalidating (but superseding) Mickael plugin in 4.7.

Thinking aloud, would it be possible/useful to also add an optional attribute to the link_to_next to constrain next/prev to a particular criterion?

Next article in category xyz, next article in section abc, next article with custom_field book_title, …

This one is internally more tricky and would make link_to_ another article_custom clone. Doable, but needs some thinking.

Offline

#36 2017-03-23 16:32:13

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Including article body inside another article

etc wrote #305001:

This one is committed now, invalidating (but superseding) Mickael plugin in 4.7.

Yay! I always prefer to do things with core tags rather than a plugin. And I really like the way you implemented it in such a textpatterny way.

Offline

Board footer

Powered by FluxBB