Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-02-04 17:56:24

feragnoli
Member
From: the hague
Registered: 2005-02-10
Posts: 150

Php inside article form..?

can anybody shed light on why something like this <txp:php> parse ('<txp:image id="92" />'); </txp:php> inside an article form is not processed?
thank you very much in advance!


what was that again…?

Offline

#2 2009-02-04 18:11:39

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

Re: Php inside article form..?

What’s the purpose of this?


My Plugins

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

Offline

#3 2009-02-04 18:14:22

feragnoli
Member
From: the hague
Registered: 2005-02-10
Posts: 150

Re: Php inside article form..?

it’s not supposed to parse specifically that image.
it’s generating a gallery from the textpattern article tag, so the id is pulled out of an array.
for some reason, though, the parsing of the ‘final’ tag does not happen.


what was that again…?

Offline

#4 2009-02-04 18:35:37

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: Php inside article form..?

Still not sure exactly what you’re trying to do, but it seems like tags as attributes might be helpful? As of 4.0.7, you can use txp tags as attributes for other txp tags, in single quotes rather than double.

So <txp:image id='<txp:article_id />' /> would do…something.

Offline

#5 2009-02-04 18:40:35

feragnoli
Member
From: the hague
Registered: 2005-02-10
Posts: 150

Re: Php inside article form..?

it’s a script generating a gallery.
of a bit of a different kind than the ones available with plugins.
so, this part of the script should just take a number id and paste it in the txp:image tag and parse the tag.
that seems not to work inside an article form.
you could either parse() or print() the tag, which normally would work. but inside the article form the print() is just printing the tag as written without actually have the parser process it (which happens outside the article form).

By the way, te install is a Txp 4.0.6


what was that again…?

Offline

#6 2009-02-04 18:48:06

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: Php inside article form..?

Hmm, well if you upgraded to the latest version (painless), I think you could do:

<txp:image id=’<txp:php>however you’re generating your id</txp:php>’ />

In fact I just did something similar recently, except I put the php in a separate form, and then I output the form as an attribute value:

http://forum.textpattern.com/viewtopic.php?pid=198642#p198642

Last edited by nabrown78 (2009-02-04 18:50:06)

Offline

#7 2009-02-04 18:50:13

feragnoli
Member
From: the hague
Registered: 2005-02-10
Posts: 150

Re: Php inside article form..?

but is the txp:image tag being parsed inside an article form?


what was that again…?

Offline

#8 2009-02-04 19:03:23

nabrown78
Member
From: Northampton, MA, USA
Registered: 2006-10-04
Posts: 294
Website

Re: Php inside article form..?

Actually I’m not using <txp_image /> at all. I dunno…what you’re doing seems related to what I was up to, so here are the forms I’m using, in case they’re helpful. Both are “misc” forms (note that I only needed to store it in a @<txp:variable /> because I need the same value twice on one page).

<txp:variable name="my_offset" value='<txp:output_form form="random_offset" />' />
<div id="befAftSlides">
<ul id="slides">
<txp:wet_for_each_image category="before-and-after" offset='<txp:variable name="my_offset" />' limit="10" sort="name">
<txp:upm_image form="bef_aft_slide" image_id="{id}" />
</txp:wet_for_each_image>
</ul>
<ul id="thumbs">
<txp:wet_for_each_image category="before-and-after" limit="10" sort="name" offset='<txp:variable name="my_offset" />'>
<txp:upm_image form="bef_aft_thumb" image_id="{id}" />
</txp:wet_for_each_image>
</ul>
</div>

And random_offset looks like:
<txp:php>
$rs = safe_rows('id', 'txp_image', '1=1 and category in ("before-and-after")');
$half_num_images = (count($rs) - 10)/2;
if ($half_num_images>0) {
echo (rand(0, $half_num_images))*2;
}
</txp:php>

Offline

#9 2009-02-04 20:50:42

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

Re: Php inside article form..?

You can call the txp_image function directly. There’s and example of something similar in this other recent post


My Plugins

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

Offline

#10 2009-02-05 00:02:42

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: Php inside article form..?

feragnoli wrote:

can anybody shed light on why something like <snip> is not processed?

Do you need to echo the result of the parse call?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#11 2009-02-06 17:58:44

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

Re: Php inside article form..?

^^ yep, echo is missing, but as some people already mentioned, upgrade to TXP 4.0.8 and you don’t need such PHP code.

Offline

Board footer

Powered by FluxBB