Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-12-02 01:03:59

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

Re: Section article listing beginning with current day's article

speeke wrote:

I’ve tried defaults="pg:0" and defaults="pg:1".

Sorry for the ambiguity and brain-ache; defaults is (definitely, this time!) an smd_query tag attribute, not a MySQL feature :-)

Last edited by Bloke (2009-12-02 01:05:05)


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

#14 2009-12-02 01:10:06

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Re: Section article listing beginning with current day's article

Like this?

<txp:smd_query query="SELECT posted FROM textpattern WHERE section = '?s' AND status = 4 AND DATE_FORMAT(posted,'%m-%d') <= DATE_FORMAT(CURDATE(),'%m-%d') GROUP BY posted DESC OFFSET "?pg" LIMIT 3" defaults="pg:0">

If so, I still have a problem with the quotes (ie articles render, but everything else in the page below them is not rendered).


“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#15 2009-12-02 01:14:01

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

Re: Section article listing beginning with current day's article

speeke wrote:

Like this?

Close! Try taking out the quotes around the ?pg in the query. The parser is seeing those and thinking it’s the end of your query attribute. viz:

<txp:smd_query query="SELECT posted FROM textpattern WHERE section = '?s' AND status = 4 AND DATE_FORMAT(posted,'%m-%d') <= DATE_FORMAT(CURDATE(),'%m-%d') GROUP BY posted DESC OFFSET ?pg LIMIT 3" defaults="pg:0">

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

#16 2009-12-02 01:20:06

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Re: Section article listing beginning with current day's article

Sorry to be a pain… But I now get:

Textpattern Warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OFFSET pg LIMIT 3' at line 1

“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#17 2009-12-02 01:38:13

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

Re: Section article listing beginning with current day's article

speeke wrote:

OFFSET pg LIMIT 3’ at line 1

Nuts, it’s a subtle bug in the plugin. It’s treating pg LIMIT 3 as the name of your variable :-\

Luckily, you can bypass it for now by swapping the order of the paramters so the OFFSET comes last in the query. I’ll have to fix that, sorry.


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

#18 2009-12-02 02:01:22

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Re: Section article listing beginning with current day's article

I’ve used:

<txp:smd_query query="SELECT posted FROM textpattern WHERE section = '?s' AND status = 4 AND DATE_FORMAT(posted,'%m-%d') <= DATE_FORMAT(CURDATE(),'%m-%d') GROUP BY posted DESC LIMIT 3 OFFSET ?pg" defaults="pg:0">

But I’m now getting duplication of the articles again :-( (Also tried defaults="pg:1" – no luck).


“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#19 2009-12-02 02:35:07

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

Re: Section article listing beginning with current day's article

speeke wrote:

But I’m now getting duplication of the articles again :-(

Hmmm, this is getting out of hand! It’s probably going to be easier to pause until I build paging into the plugin.

I’ve fixed a few bugs just now (thanks) and I have some vague notions on how to do paging floating round my head but it’s not easy so I’m going to have to sleep on it because it’s 2:30am and my brain is starting to go south. If I get a chance tomorrow I’ll see what I can do to get paging running directly in the plugin without faffing around with embedded article/article_custom tags.

Incidentally, I noticed something in your code several posts above: there’s no ‘section’ attribute in <txp:article /> and even if there was, it certainly won’t like ?s as a parameter :-)


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

#20 2009-12-02 02:39:37

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Re: Section article listing beginning with current day's article

Many thanks, Bloke – ‘till then! :-)

there’s no ‘section’ attribute in <txp:article />

Ah yes, left over from the article_custom tag I used earlier. Wouldn’t that have been nice if it had fixed the problem!


“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#21 2009-12-02 19:52:50

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

Re: Section article listing beginning with current day's article


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

#22 2009-12-02 21:21:59

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Re: Section article listing beginning with current day's article

Wow, you’re lightening fast! Will download now, and check out later today. Many thanks, Stef.


“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#23 2009-12-02 21:37:49

speeke
Member
From: Bruny Island, Australia
Registered: 2009-03-29
Posts: 161
Website

Re: Section article listing beginning with current day's article

Well “later today” became right now, and all appears OK. I notice the plugin has a number of other attributes which I haven’t dived into yet, but this is the code I’ve used, which seems to work:

<txp:adi_gps name="pg" quiet="1" />
<txp:adi_calc name="pg" multiply="1" />
<txp:smd_query query="SELECT posted FROM textpattern WHERE section = '?s' AND status = 4 AND DATE_FORMAT(posted,'%m-%d') <= DATE_FORMAT(CURDATE(),'%m-%d') GROUP BY posted DESC LIMIT 3" offset="?pg" limit="1">
    <txp:article listform="article_list" month="{posted}" limit="1" />
</txp:smd_query>

I assumed I wouldn’t need the defaults="pg:0" tag. <txp:article /> appears to still need a limit too.

Thanks again!

Last edited by speeke (2009-12-02 21:39:43)


“People who value their privileges above their principles soon lose both.”
Dwight D. Eisenhower

Offline

#24 2009-12-02 21:51:50

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

Re: Section article listing beginning with current day's article

speeke wrote:

I assumed I wouldn’t need the defaults="pg:0" tag. <txp:article /> appears to still need a limit too.

Well this version of smd_query does things in a radically different way, so in theory you won’t need the article embedded inside it, nor will you need the adi_gps or adi_calc plugins (I hope!) because smd_query now understands paging natively.

Thus:

<txp:smd_query query="some way of extracting articles in date order, starting today" limit="3">
{Excerpt}
</txp:smd_query>
<txp:newer>Previous 3</txp:newer> <txp:older>Next 3</txp:older>

will show 3 excerpts at a time from your query and allow you to page up and down through your articles in multiples of 3 using older/newer. Significantly easier than before!

Last edited by Bloke (2009-12-02 21:52:53)


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

Board footer

Powered by FluxBB