Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Select a list of articles by id..
Hi TXP’ers,
been working for a couple of years with TXP but this is the first time I can’t get around something.
For my site I want to select a list of articles by id and display randomly one of them.
Something like tis: <txp:article_custom form=“formname limit=“1” sortby=“rand()” id=“3,7,10,11,13” />
Is this possible?
Would be really neat and cool if this is possible.
Thanks all.
Offline
Re: Select a list of articles by id..
Yes, it is.
In fact, your code would almost work if you properly close the quotes after “formname” and change “sortby” by just “sort”.
Offline
Re: Select a list of articles by id..
maniqui wrote:
In fact, your code would almost work if you properly close the quotes after “formname” and change “sortby” by just “sort”.
Sorry, made a typo there.
I tried the code I posted but TXP always gives me the content of the first ID from that list of ID’s.
Last edited by karl.dvx (2009-11-10 21:53:01)
Offline
Re: Select a list of articles by id..
<txp:article_custom form="formname" limit="1" sort="rand()" id="3,7,10,11,13" />
works
Last edited by MattD (2009-11-10 23:51:05)
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: Select a list of articles by id..
Yes, it works indeed.
But the problem is I always get the same article on every page, the first one (3).
When I go to another page I want to get the content of another article ID, one of those selected in the list.. But that’s not the case.
Offline
Re: Select a list of articles by id..
Interesting, I put this on a test page and got a different article every time I refreshed the page.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: Select a list of articles by id..
Really strange, I tried the exact code with correct formname from above on two sites but always get the same page. Just don’t get it..
Thanks for your help.
Offline
Re: Select a list of articles by id..
What the…
Tried it on a fresh install in MAMP, all works fine. But it won’t work on my site..
Maybe because of a plugin? I only use two front-end plugins (mem_article_count and zem_link).
THIS IS MADNEEEESS
Offline
Re: Select a list of articles by id..
Is your browser/server cacheing the results somewhere? Try setting the send last modified header in Advanced Prefs to no and see if it makes any difference.
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
Re: Select a list of articles by id..
Bloke wrote:
Is your browser/server cacheing the results somewhere? Try setting the send last modified header in Advanced Prefs to no and see if it makes any difference.
Tried it. But still get the same result on this PC, iPhone and another PC.
I see my host disabled some PHP functions -> proc_get_status, proc_nice, proc_terminate, pcntl_exec are disabled on my hosting.
Maybe this could be the reason?
Offline
Re: Select a list of articles by id..
karl.dvx wrote:
Maybe this could be the reason?
Please post your high diagnostics. (Admin > Diag > High). Likely it’s MySQL version issue (too old).
Alternatively you could use PHP to output an random article.
<txp:article_custom limit="1" id='<txp:php> $id = array(3,7,10,11,13); echo $id[rand(0,4)]; </txp:php>' />
Offline
Re: Select a list of articles by id..
Code sample above doesn’t work either, too bad.
Diagnostics:
MySQL: 5.0.67
PHP versie: 5.2.8
I guess the problem is my hosting. On a local version in MAMP everything works fine.
I now assign an extra category to the articles I want to select.. Not the best solution but it works.
Thanks for your time every one of you.
Offline
Pages: 1