Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-04-03 00:49:57

duchamp
Member
From: Patagonia
Registered: 2005-02-03
Posts: 222
Website

Show Daily Content

As Kurt Raschke suggest in this other Thread I will request a feature to show DAILY content with TXP.
As I’m developing an small Newspaper powered by Textpattern I want to show only daily contents/articles in the Home Page … but, oh surprise! I can’t!
Someone talks about the if_different tag but I don’t know if that tag could show just the articles published today!
The nearest tag to this requirement is <code><txp:article_custom /></code> but needs a new parameter:

KurtRaschke wrote:

That would be a job for <code><txp:article_custom /></code>, however, presently <code><txp:article_custom /></code> only lets you restrict the articles by month, not day. What would really be needed is for the time parameter to take an option like today.

What do you think?

I can’t believe that there’s no way to show just TODAY articles!

Offline

#2 2006-04-03 04:57:18

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,339
Website GitHub Mastodon

Re: Show Daily Content

Peeking at the code of doArticles, I think you can achieve this with month anyway as month is just used as a selection criterion for the Posted article attribute (it adds "and Posted like " . $month ."%" to the SQL conditional clause).

Just pass in a date like ’2006-02-28’ and it will list all articles of that given date. You will need a small snippet of <txp:php> to read todays date, but basically it will work.

Offline

#3 2006-04-03 07:15:05

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

Re: Show Daily Content

as there is a solution for this one, I have moved to to the “how do I” forum


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

Offline

#4 2006-04-03 10:16:29

duchamp
Member
From: Patagonia
Registered: 2005-02-03
Posts: 222
Website

Re: Show Daily Content

colak wrote:

as there is a solution for this one, I have moved to to the “how do I” forum

Sorry colak but I’m not sure about that solution, that’s a hack not a solution that comes with the default installation or a plugin. A Plugin could help, of course, but I believe this is a useful feature that must to be a parameter of a default tag! (like we said before).

Thx

Offline

#5 2006-04-03 11:36:54

duchamp
Member
From: Patagonia
Registered: 2005-02-03
Posts: 222
Website

Re: Show Daily Content

wet wrote:

Peeking at the code of doArticles, I think you can achieve this with month anyway as month is just used as a selection criterion for the Posted article attribute (it adds "and Posted like " . $month ."%" to the SQL conditional clause).
Just pass in a date like ’2006-02-28’ and it will list all articles of that given date. You will need a small snippet of <txp:php> to read todays date, but basically it will work.

Well, you’re right, if I use <txp:article_custom form="cover" month="2006-04-02" /> in the NewsPaper Homepage, it shows ONLY the articles published in that specific day.
Trying to pass TODAY date to that parameter I used <txp:article_custom form="cover" month="<txp:php>echo date ("Y-m-d");</txp:php>" /> but didn’t work … ummmh

Offline

#6 2006-04-03 11:45:26

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,339
Website GitHub Mastodon

Re: Show Daily Content

O o, you just asked the “Groundhog Day” question of Textpattern: Tags in Tags.

Let me stitch a little piece of code together (with typos you may keep in case you’ll find one ;-)

<txp:php>
$dt = date ("Y-m-d");  # no yesterday news!
$a = array ( "month" => $dt, "form" => "cover" ); # build all desired attributes into an array
echo article_custom ($a);     # and away we go...
</txp:php>

Obviously one could achieve more tight code by sacrifycing legibility.

//w&

Last edited by wet (2006-09-10 06:27:37)

Offline

#7 2006-04-03 12:11:42

duchamp
Member
From: Patagonia
Registered: 2005-02-03
Posts: 222
Website

Re: Show Daily Content

Thanks a ton wet! I couldn’t make it work but I feel the solution is around here.
If the Homepage shows articles in this way:

<code><txp:if_article_list> <txp:php>$dt = date (“Y-m-d”);$a = array ( “month” => $dt, “form” => “cover” );echo article_custom ($a);</txp:php>
<txp:else /> <txp:article />
</txp:if_article_list></code>

… again tags inside tags! or there’s no problem here?

Offline

#8 2006-04-03 12:21:24

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,339
Website GitHub Mastodon

Re: Show Daily Content

“Tags in tags” relates to the situation of “one tag is required as an attribute value to another tag”. Your markup contains no such thing, so I am basically out of advice.

You could try to add some intermittent dmp calls to inspect the value of $dt and other intermediate variables. See this, fig. 18 for a sample of dmp usage.

Offline

#9 2006-04-03 13:12:34

duchamp
Member
From: Patagonia
Registered: 2005-02-03
Posts: 222
Website

Re: Show Daily Content

Allright, this worked very well:

<code><txp:if_article_list> <txp:php>$dt = date (“Y-m-d”);echo article_custom(array(“form”=>“cover”, “month”=>($dt)));</txp:php>
<txp:else /> <txp:article />
</txp:if_article_list></code>

Thanks once more!

PS: The trouble was that on my localhost I didn’t change the articles date to simulate that were published TODAY!

Last edited by duchamp (2006-04-03 13:13:56)

Offline

#10 2006-04-03 16:59:26

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Show Daily Content

Note: don’t forget about timezone differences; use date('Y-m-d', time() + tz_offset()) rather than date('Y-m-d').

Obviously you’re close enough of a timezone to your server so it works for you, but thought I’d mention this for others.

Offline

#11 2006-04-03 17:10:29

duchamp
Member
From: Patagonia
Registered: 2005-02-03
Posts: 222
Website

Re: Show Daily Content

Thanks about that detail Mary!

Offline

#12 2006-05-13 16:43:27

szac
Member
From: Detroit-ish
Registered: 2004-09-18
Posts: 50

Re: Show Daily Content

Thanks a lot for this little nugget. It’s almost working for me. What’s happenign is that I’m creating articles with future post dates and when those articles dates become today, they do not auto publish under the conditions of the script until I choose to update the time stamp to today.

I’m using it for a sports schedule, so it would be nice to enter all of the dates ahead of time, then have them publish as “Today’s Game” or something of the like. Check it out here

Any ideas?

Offline

Board footer

Powered by FluxBB