Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#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
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.
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
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__
Offline
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.
Offline
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__
Offline
Re: rah_function // Every PHP function is a tag
Hello,
Is there a way to add an attribute inside this snippet to count only articles that have an existing image. By existing, I mean an image that is recorded in the db…
<txp:rah_function call="safe_count" table="textpattern" where='Category1="<txp:category1 />" && status="4"' />
Tried this:
<txp:rah_function call="safe_count" table="textpattern" where='Category1="<txp:category1 />" && status="4" && Image="<txp:image />"' />
Unlucky :P
Thanks !
Last edited by hablablow (2011-03-22 22:33:30)
_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__
Offline
#32 2011-03-22 22:57:25
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,310
Re: rah_function // Every PHP function is a tag
Could this help:
where="image != ''"
?
I better paste my original: <txp:jmd_count table="textpattern" where="image != ''" />
Last edited by uli (2011-03-22 22:58:53)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: rah_function // Every PHP function is a tag
Viel besser ! Danke Uli, neat I like it and very, very close… We have just one case missing:
<txp:rah_function call="safe_count" table="textpattern" where='Category1="<txp:category1 />" && status="4" && Image != ""' />
This snippet will not count articles with an empty image field, which is the first goal…
Aber (but)…
It will still count articles with a wrong image id defined in the article_image field… The id is wrong either because the user has entered a wrong number, more likely he has deleted an image from the image tab without removing first the article…
Any way we can check for the existence of a corresponding image recorded here ? In the txp_image table ?
Vielen dank ! (Thanks !)
Last edited by hablablow (2011-03-22 23:16:16)
_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__
Offline
Re: rah_function // Every PHP function is a tag
Rah_function v0.3 released. Changes:
- Fixed: Now empty, nothing-at-all, string can be used as the container-mode’s wrapped statement.
- Added: Now makes sure that the called function is really defined before executing anything.
Offline
#35 2011-11-10 18:18:49
- lithium002
- Member
- Registered: 2011-04-29
- Posts: 25
Re: rah_function // Every PHP function is a tag
I’m trying to do a preg_match function but I think I’m doing it all wrong. This is the tag I’m using:
<txp:rah_function call="if" thing="preg_match" pattern="/^A/i" subject="AAA">
yes
</txp:rah_function>
This doesn’t generate any errors or warnings but does nothing. Can anyone nudge me in the right direction?
Offline
Re: rah_function // Every PHP function is a tag
Did you look at the second page of this thread? Some examples there.
Offline