Textpattern Forum

You are not logged in. Register | Login | Help

#21 2010-06-21 08:16:11

Gocom
Developer
Registered: 2006-07-14
Posts: 4,471
Website

Re: rah_function // Every PHP function is a tag

Darkliam wrote:

(I test that : <txp:variable name="test" value='<txp:rah_function call="safe_count" table="textpattern" where='Category="peintres" ' />' /> but this not right.)

Yep, it’s not. TXP.com weblog / Tag parser – par 1: new features

The parser stops because there are ' single quotes inside single quotes. Let me give some options.

Using variable as container:

<txp:variable name="test"><txp:rah_function call="safe_count" table="textpattern" where='Category="peintres"' /></txp:variable>

Escaping the single quotes by using double single quotes:

<txp:variable name="test" value='<txp:rah_function call="safe_count" table="textpattern" where=''Category="peintres"'' />' />

Or because the inner one doesn’t have tags used as values:

<txp:variable name="test" value='<txp:rah_function call="safe_count" table="textpattern" where="Category=''peintres''" />' />

Or:

<txp:variable name="test" value='<txp:rah_function call="safe_count" table="textpattern" where="Category=""peintres""" />' />

Hope it helps :-)


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#22 2010-06-21 09:51:08

Darkliam
New Member
Registered: 2010-06-20
Posts: 9

Re: rah_function // Every PHP function is a tag

And that can be used with rss_unlimited_category? can we used the name of the other categories create ? This plugins use always category 1 and category 2 or it accept the other categories created by rss_unlimited_category?

Offline

#23 2010-06-21 10:25:05

Gocom
Developer
Registered: 2006-07-14
Posts: 4,471
Website

Re: rah_function // Every PHP function is a tag

Darkliam wrote:

And that can be used with rss_unlimited_category? can we used the name of the other categories create ? This plugins use always category 1 and category 2 or it accept the other categories created by rss_unlimited_category?

I can’t comment on that. I have no idea where or how rss_unlimited_categories stores the categories. I just basically corrected your markup, as that was what I thought you were asking.

What comes to the limits of rah_function, from the plugins pov there are none. The plugin just calls PHP functions, which means that it works as long as the returned output is a string. The actual limit comes from the function that is used.

The safe_count() you used in your example, runs a query that counts matching rows, and the limits of safe_count() are same as normal count query’s.


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#24 2010-06-21 10:40:22

Gocom
Developer
Registered: 2006-07-14
Posts: 4,471
Website

Re: rah_function // Every PHP function is a tag

Darkliam, I took bit of look at rss_unlimited_categories and it stores the infomation about the categories in textpattern_category table.

<txp:rah_function call="safe_count" table="textpattern_category" where="category_id=13" />

Something like that should get the count. The category_id is what you want to macth. Instead the name of the category, it uses the ID number of the category.

You can dynamically fetch the category’s ID from txp_category table too, if you required:

<txp:rah_function call="fetch" what="id" table="txp_category" where="name" is="peintres" />

Which can then be feeded to the count. Best solution tho, would be use the ID without the extra step.


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#25 2010-06-21 10:58:56

Darkliam
New Member
Registered: 2010-06-20
Posts: 9

Re: rah_function // Every PHP function is a tag

I have understand what you would arrive but what I put after where=“category_id=13”? (I take the id with <txp:rah_function call=“fetch” what=“id” table=“txp_category” where=“name” is=“peintres” /> but I must put this lignes in this code?)

I test that <txp:rah_function call=“safe_count” table=“textpattern_category” where=“category_id=<txp:rah_function call=‘fetch’ what=‘id’ table=‘txp_category’ where=‘name’ is=‘peintres’ />” /> ?

Or I must use a txp:variable to put the ID?

Last edited by Darkliam (2010-06-21 11:03:30)

Offline

#26 2010-06-21 12:11:51

Gocom
Developer
Registered: 2006-07-14
Posts: 4,471
Website

Re: rah_function // Every PHP function is a tag

Darkliam wrote:

I test that <txp:rah_function call="safe_count" table="textpattern_category" where="category_id=<txp:rah_function call='fetch' what='id' table='txp_category' where='name' is='peintres' />" />?

Remember the quotes ;-). If you want to use tags inside tags with rah_function you have couple of options. Like <txp:variable />, also rah_function supports containers:

<txp:rah_function call="safe_count" table="textpattern_category" thing="here">
	category_id='<txp:rah_function call="fetch" what="id" table="txp_category" where="name" is="peintres" />'
</txp:rah_function>

Or correct use of quotes:

<txp:rah_function call="safe_count" table="textpattern_category" where='category_id="<txp:rah_function call="fetch" what="id" table="txp_category" where="name" is="peintres" />"' />

Remember that only contents surrounded with single quotes will be parsed.


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#27 2010-06-21 12:40:10

Darkliam
New Member
Registered: 2010-06-20
Posts: 9

Re: rah_function // Every PHP function is a tag

Ok tanks you for your help

Offline

#28 2010-06-28 12:23:56

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: rah_function // Every PHP function is a tag

jukka thanks for this plugin first.
As explained in the plugin doc I’m using it to count the number of articles in a category, such as:

<txp:rah_function call="safe_count" table="textpattern" where='Category1="<txp:category1 />"' />

I would like to count articles this way but only count those articles with live status and exclude others. So I tryed this:

<txp:rah_function call="safe_count" table="textpattern" where='Category1="<txp:category1 />" &&  status="live"' />

But doesn’t work, returns for every category “0”

Any clues ?

Thanks !

Last edited by hablablow (2010-06-28 12:24:22)


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#29 2010-06-28 14:32:38

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,976
Website

Re: rah_function // Every PHP function is a tag

Hi Guillaume:

Have you tried with status="4"? That’s probably how status is stored in TXP database.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#30 2010-06-28 15:00:33

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: rah_function // Every PHP function is a tag

Jaja !

<txp:rah_function call="safe_count" table="textpattern" where='Category1="<txp:category1 />" &&  status="4"' />

Working !
Gracias Julián !


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

Board footer

Powered by FluxBB