Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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
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
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
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
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
Online
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
Offline