Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-10-02 15:39:37

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#2 2009-10-02 16:11:40

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Count article number from section and custom field

Check out jmd_count


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#3 2009-10-02 23:45:10

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#4 2009-10-03 00:04:21

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

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>’);”

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2009-10-03 01:12:28

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#7 2009-10-03 09:29:04

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#8 2009-10-03 11:39:00

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

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

#9 2009-10-03 12:28:51

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#10 2009-10-03 12:52:09

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#11 2009-10-03 14:42:35

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 637
Website

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

#12 2009-10-03 15:13:41

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

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

Board footer

Powered by FluxBB