Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2020-12-13 17:11:55

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,680
GitHub Twitter

Re: [Solved] Displaying a random article but not the current one

Maybe I misunderstood. But since 4.8.4 (see: https://github.com/textpattern/textpattern/blob/dev/HISTORY.txt#L21) short attributes fields (from the textpattern table) are available.

From this example: select section (the current one) id (articles but randomized) and cf_name (custom field name but only populated) and exclude id (current article one), finally, only one (limit="1").

Last edited by Pat64 (2020-12-13 17:19:32)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#17 2020-12-13 17:57:30

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,395
Website GitHub Mastodon Twitter

Re: [Solved] Displaying a random article but not the current one

I might have misunderstood too but why are articles with cf_name are excluded from this list? I would think that including cf_name, the article_custom would include not exclude those articles. Unless of course you actually did want to include them.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#18 2020-12-13 18:27:39

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,680
GitHub Twitter

Re: [Solved] Displaying a random article but not the current one

Yannis.

If you turn your website into “debug” mode, the page source show us all the magic our Devs make each day with their intelligence:

<txp:article_custom section id epuise exclude="id, epuise" limit="1" sort="rand()">
    174,55 |     0,01 | 		<txp:article_custom section id epuise exclude="id, epuise" limit="1" sort="rand()">
    174,57 |          | 		</txp:article_custom>
    174,61 |     1,55 | 		[SQL: SELECT *, UNIX_TIMESTAMP(Posted) AS uPosted, UNIX_TIMESTAMP(Expires) AS uExpires, UNIX_TIMESTAMP(LastMod) AS uLastMod FROM textpattern WHERE 1 AND `Posted` <= from_unixtime(2147483647) AND (Expires IS NULL OR from_unixtime(1608907599) <= Expires) AND ID NOT IN (5) AND Section  IN ('catalogue-general') AND Status IN (4,5) AND (NOT custom_3 != '')  ORDER BY rand() LIMIT 0, 1 ]
    176,16 |          | 		[Rows: 1]
    176,20 |          | 		[Article: '4']
    176,22 |          | 		[true]

SELECTAND (NOT custom_3 != '')

But you’re right. In my case, my custom_3 is empty for the attempted results I got!


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#19 2020-12-13 18:57:08

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,276
Website Mastodon

Re: [Solved] Displaying a random article but not the current one

Pat64 wrote #327462:

My solution doesn’t work at all. I kept it here to show how I’m a bad TXP user.

what happened to your Cara TM website?


…. texted postive

Offline

Board footer

Powered by FluxBB