Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-01-10 09:38:55

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,003
Website

previewing draft articles

I started writing this in the Troubleshooting forum but realised that it’s probably the code I am using and not a problem with txp.

Previewing draft articles in the Blog section of our site, returns the article twice. This is not a huge issue as the article appears just fine in live or sticky status. Interestingly, all the other sections parse the articles OK when in draft. Can anyone spot why this is happening?


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

#2 2019-01-10 09:57:52

etc
Developer
Registered: 2010-11-11
Posts: 3,016
Website

Re: previewing draft articles

Hi Yiannis,

you seem to have two (sticky and live) article tags in your template. But status is discarded in preview mode, so both tags output the article. Dunno how this should (?) be fixed.


etc_[ query | search | pagination | date | tree | cache ]

Offline

#3 2019-01-10 10:53:55

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,003
Website

Re: previewing draft articles

I suspected that much. It does not really bother me, I just thought I should check.

There is one way of ‘correcting’ the issue but I think that it would be hard in the core.

Basically we have two types of publicly reached articles: live and sticky.

We also have three types on ‘private’ articles: draft, hidden, and pending.

If these statuses types were separated, so as to be able to select live or sticky and a second dropdown could have draft, hidden, pending and published, then the articles may appear just fine.

As I said… This is not a big issue. Let’s leave it as is:)


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

#4 2019-01-10 11:32:17

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 3,223
Website

Re: previewing draft articles

An interesting situation and totally understandable how it comes about. It’s kind of an edge case and I’m not sure if it’s common enough to warrant separating out “draft” from the intended publishing state.

Another approach – if it bugs you – might be to accommodate this special case in your page template by detecting the presence of the txpreview url variable which shows only on article preview situations. e.g.:

<txp:adi_gps name="txpreview" quiet="1" />
...
<txp:if_variable name="txpreview">
    <!-- only shows once on an article preview -->
    <txp:article limit="1" form="your_form" />
<txp:else />
    <!-- regular page code with your sticky and live txp:article tags -->
    ....
</txp:if_variable>

TXP Builders – finely-crafted code, design and txp

Offline

#5 2019-01-10 11:39:27

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 8,493
Website

Re: previewing draft articles

Interesting indeed. This is the sort of thing I’d like the status-mods branch to be able to handle, if it ever sees the light of day in core. That groups statuses into “published” and “unpublished” by default (and allows you to define your own new statuses or groups via plugin) which should make it possible for us to handle the preview feature better.

Though I don’t know how exactly we could prevent both calls to <txp:article> appearing if used in a template, besides passing the status forward.


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

#6 2019-01-10 13:36:42

etc
Developer
Registered: 2010-11-11
Posts: 3,016
Website

Re: previewing draft articles

In 4.7 you can output live and sticky articles at once. You can try (untested)

<txp:article status>
<txp:if_custom_field name="status" value="5">
    <!-- sticky article -->
<txp:else />
    <!-- other articles -->
</txp:if_custom_field>
</txp:article>

etc_[ query | search | pagination | date | tree | cache ]

Offline

#7 2019-01-10 14:01:10

jakob
Moderator
From: Germany
Registered: 2005-01-20
Posts: 3,223
Website

Re: previewing draft articles

Another mini-gem! So here status means status="true" but not “1”.

You couldn’t use that for status="3" though with the preview function because the notion of status is discarded, right? You’d need to use the txpreview method above?


TXP Builders – finely-crafted code, design and txp

Offline

#8 2019-01-10 14:13:47

etc
Developer
Registered: 2010-11-11
Posts: 3,016
Website

Re: previewing draft articles

We can not set status="3", indeed, but I think Draft articles will be output as “other” by this block in preview mode. So Yiannis could simply replace two separate <txp:article />s with this one.


etc_[ query | search | pagination | date | tree | cache ]

Offline

#9 2019-01-10 15:25:38

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,003
Website

Re: previewing draft articles

i’m in between meetings but i’ll experiment with it tomorrow…


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

#10 2019-01-11 07:35:03

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,003
Website

Re: previewing draft articles

I have written a post here last night but it seems to have disappeared so here it is again:)

I have tried Oleg’s suggestion which actually works but unfortunately, not for the way we wish our site to function.

<txp:article status> returns 10 sticky & live articles on the front page of the section but what we need is the unlimited stycky articles (which represent our near future, current, and ongoing activities), and 10 live articles which represent current competitions, calls, info, etc, by others as well as recently passed posts. As such the section’s front page contains all the info we need people to see, whereas the rest of the pages are there as an archive, mostly needed for the archaeologists amongst us.

I am nevertheless hugely impressed with how flexible and economical txp tags have become in the past couple of releases and hope that this thread will be of use to others as I know it will be for me in the future.


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github

Offline

Board footer

Powered by FluxBB