Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Count article number from section and custom field
Ok.
I got my music-player that read an XML file of playlist,
I faked XML page with textpattern and forms,
so now the xml is full with “articles” that are from a specific section and that use custom4 field.
now I want to send an event from the real articles to play the song they includes.
and for that I need to let them send an ID number of the ITEM (song) like: play item#5.
and I can’t fake the items numbers to use the <txp:article_id />,
it will always be item#1 item#2 item#3…
so if I can’t fake the item number,
I want the article to search himself with the section & custom4 field,
and see where it is and write the number.
so I will be able to send that number to my music-player and it will know what item/song to play from the playlist.
so in the end, article #96324 will see where it is in the section and if it the most new article it will write number one (1)
and I will take this result and add it to the event i’m sending to my music player.
for example:
onclick=“play(‘ITEM’,’<txp:blabla_count section=“music” customfield=“song” />’);”
will give me:
onclick=“play(‘ITEM’,‘1’);”
Is there a way of doing this please?
Last edited by THE BLUE DRAGON (2009-10-02 15:40:11)
Offline
Re: Count article number from section and custom field
Check out jmd_count
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: Count article number from section and custom field
How do I use it please?
I don’t now how to work with database
I went to phpmyadmin and I see this: textpattern,Section,custom_4
where and how I use each please?
<txp:jmd_count table=“?” where=”?”/>
my section name is “music”, and my custom field #4 name is “song”.
Offline
Re: Count article number from section and custom field
Install adi_calc and try something like this:
<txp:variable name="counter" value="0" />
onclick=“play(‘ITEM’,’<txp:article_custom section=“music” song=“_%”><txp:adi_calc add="1" name="counter" display="1" /></txp:article_custom>’);”
Offline
Re: Count article number from section and custom field
maniqui wrote:
Install adi_calc and try something like this
I’m geting the same result (1) in every article :(
Last edited by THE BLUE DRAGON (2009-10-03 01:12:59)
Offline
#6 2009-10-03 01:35:26
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Count article number from section and custom field
THE BLUE DRAGON wrote:
I’m geting the same result (1) in every article :(
<txp:variable name="counter" value="0" />
needs to sit in your page so it gets called just once.
And probably(!) <txp:adi_calc add="1" name="counter" display="1" />
inside the song(c_f)-attribute’s apostrophes.
[Edit: Another “probably”: Probably article_custom needs a limit="1"
]
Sorry to chime in Julian. I was intensively thinking about your approach, trying to learn exotic applications of tag combos.
Last edited by uli (2009-10-03 02:01:52)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Count article number from section and custom field
still same result.
(number #1 in every article)
I want to make sure you understand that the articles are by them own,
and it’s not a page with an articles list,
every article got is own page with all the info inside and a link to play the song from custom_4 field in the player.
Offline
Re: Count article number from section and custom field
Tricky problem. Here’s an untested variation on maniqui’s idea:
<txp:variable name="counter" value="0" />
<txp:variable name="this_id" value='<txp:article_id />' />
onclick="play('ITEM',
'<txp:article_custom section="music" song="_%" limit="999">
<txp:adi_calc add="1" name="counter" />
<txp:if_article_id id='<txp:variable name="this_id" />'>
<txp:variable name="counter" />
</txp:if_article_id>
</txp:article_custom>'
);"
Whitespace added for clarity, but you might need to remove some of it for the js to work.
Edit: quotes straightened; thanks Ruud.
Last edited by jsoo (2009-10-03 12:54:52)
Code is topiary
Offline
Re: Count article number from section and custom field
jsoo wrote:
Tricky problem. Here’s an untested variation on maniqui’s idea:
wow working great! thank you!
that is so cool
can’t wait to finish this website and post a link to it :)
thank you all :)
Offline
Re: Count article number from section and custom field
For future readers, replace the textiled quotes with normal quotes in the example code.
Last edited by ruud (2009-10-03 12:53:33)
Offline
Re: Count article number from section and custom field
Ohh I need more help please.
It seems that the items numbers starting from zaro (0) and not from 1
O_o
so I need that the result will always be minus one, so if it’s song#5 the result will be item#4
can please?
Offline
Re: Count article number from section and custom field
Just move the adi_calc
tag to the end, so that the contents of article_custom
are:
<txp:if_article_id id='<txp:variable name="this_id" />'>
<txp:variable name="counter" />
</txp:if_article_id>
<txp:adi_calc add="1" name="counter" />
Code is topiary
Offline