Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2011-05-18 12:14:18
- newnoise
- Member
- Registered: 2011-02-24
- Posts: 35
Use Javascript to determine how many articles shall be displayed.
Hi,
I’m trying to use some javascript to calculate how much articles fit into a div-container with variable width.
The Textpattern part is:
<txp:article_custom limit=“3” section=“releases” sort=“Posted desc” form=“latest_releases” />
What I want to do is reset the limit value with the output of an js-function.
Thanks a lot!
noise
Offline
Re: Use Javascript to determine how many articles shall be displayed.
I am not sure, but i think it s not possible to do that!
php is parsed by the server ans javascript is parsed by the browser!! then php is parsed before javascript!!
Cheers
but may be what you can do is hiding articles that are outnumbered!!
Last edited by Dragondz (2011-05-18 12:56:02)
Offline
Re: Use Javascript to determine how many articles shall be displayed.
You could use ajax to update the div by passing the number of articles to a “hidden” page or rah_external_output and use adi_gpsto pull out the variable and pass it into your article tag.
For example:
Create a rah_external_output called variableArticleList with the Content Type of “text/html” with something like this
<txp:article_custom limit='<txp:adi_gps name="article_limit" />' form="article_listing"/>
Then you could use some jQuery like this to fill a div
$("#output").load('/?rah_external_output=variableArticleList&article_limit='+varLimit);
where “output” is the name of the div and “varLimit” is the javascript variable of the number of articles to display.
edit: thought about it more and threw an example together.
Last edited by MattD (2011-05-18 17:38:31)
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline