Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: soo_image: simple yet powerful image tags
Thanks! Here is the output from _soo_echo($image,$anchor);:
Tag error: <txp:soo_image id="33" /> -> Notice: Undefined variable: anchor on line 236
textpattern/publish.php:1090 soo_image()
textpattern/publish.php:1012 processTags()
textpattern/publish/taghandlers.php:2024 parse()
textpattern/publish.php:1090 body()
textpattern/publish.php:1012 processTags()
textpattern/lib/txplib_misc.php:1540 parse()
textpattern/publish.php:770 parse_form()
textpattern/publish.php:887 doArticles()
textpattern/publish.php:550 parseArticles()
textpattern/publish.php:1090 article()
Soo_Html_Img object:
alt: My alt text for image 33!
src: /images/33.png
width: 305
height: 299
element_name: img
is_empty: 1
can_contain: Array: 0 item:
contents: Array: 0 item:
title: My caption for image 33!
Last edited by johnstephens (2009-05-13 14:18:23)
Offline
Re: soo_image: simple yet powerful image tags
Right, if using _soo_echo() instead of var_dump(), you’ll need to do each var separately
_soo_echo($anchor);
_soo_echo($image);
Sorry for being unclear!
Code is topiary
Offline
Re: soo_image: simple yet powerful image tags
Right— Here’s the output of making each one separate:
Tag error: <txp:soo_image id="33" /> -> Notice: Undefined variable: anchor on line 236
textpattern/publish.php:1090 soo_image()
textpattern/publish.php:1012 processTags()
textpattern/publish/taghandlers.php:2024 parse()
textpattern/publish.php:1090 body()
textpattern/publish.php:1012 processTags()
textpattern/lib/txplib_misc.php:1540 parse()
textpattern/publish.php:770 parse_form()
textpattern/publish.php:887 doArticles()
textpattern/publish.php:550 parseArticles()
textpattern/publish.php:1090 article()
Soo_Html_Img object:
alt: My alt text for image 33!
src: /images/33.png
width: 305
height: 299
element_name: img
is_empty: 1
can_contain: Array: 0 item:
contents: Array: 0 item:
title: My caption for image 33!
Offline
Re: soo_image: simple yet powerful image tags
OK, next step requires editing the soo_txp_obj plugin. (You can restore soo_image to its original state.) In the Soo_Html class, tag() function, find this block:
foreach ( $this->html_attributes() as $property => $value )
if ( $value or $property == 'alt')
$out .= " $property=\"$value\"";
and comment out the second line, to get this:
foreach ( $this->html_attributes() as $property => $value )
// if ( $value or $property == 'alt')
$out .= " $property=\"$value\"";
Now what kind of output do you get from <txp:soo_image id="33" />?
Code is topiary
Offline
Re: soo_image: simple yet powerful image tags
I commented out the line indicated, and there’s no discernible difference. Here’s the HTML output:
<img alt="My alt text for image 33!" />
And here’s the tag-trace:
<txp:soo_image id="33" />
[SQL (0.00054407119751): select * from txp_image where id = '33']
Offline
Re: soo_image: simple yet powerful image tags
Well, I think we’re getting closer. Add this line directly above the foreach block shown above:
_soo_echo($this->html_attributes());
and show me the resulting echo.
Code is topiary
Offline
Re: soo_image: simple yet powerful image tags
Array: 1 item:
alt: My alt text for image 33!
This is with the if ( $value or $property == 'alt') still commented out.
Last edited by johnstephens (2009-05-13 17:43:59)
Offline
Re: soo_image: simple yet powerful image tags
OK, my guess is that this is a known bug that was fixed in PHP 5.2.4. Could be tricky to work around. What happens if you replace that last _soo_echo() call with _soo_echo($this->properties());
Edit: better make that a var_dump() instead — _soo_echo() is going to be prone to the same PHP bug.
Last edited by jsoo (2009-05-13 18:02:06)
Code is topiary
Offline
Re: soo_image: simple yet powerful image tags
With if ( $value or $property == 'alt') still commented out, _soo_echo($this->properties())); gives me this:
Array: 25 items:
alt: My alt text for image 33!
src: /images/33.png
width: 305
height: 299
element_name: img
is_empty: 1
is_block:
Array: 0 item:
Array: 0 item:
class:
dir:
id:
lang:
onclick:
ondblclick:
onkeydown:
onkeypress:
onkeyup:
onmousedown:
onmousemove:
onmouseout:
onmouseover:
onmouseup:
style:
title: My caption for image 33!
Offline
Re: soo_image: simple yet powerful image tags
Ugly, but:
Replace the first foreach block in tag() (the one we’ve been working on) with this:
$hidden = array('element_name', 'is_empty', 'is_block', 'contents', 'can_contain');
foreach ( $this->properties() as $property => $value )
if ( ( $value or $property == 'alt' ) and !in_array($property, $hidden) )
$out .= " $property=\"$value\"";
Code is topiary
Offline
Re: soo_image: simple yet powerful image tags
It worked like magic— on both the <soo_image id="33" /> tag and on the select tag that pulls in images from Article Image field through my image-display form. The only idiosyncrasy I found was that it no longer displays the images in the order entered in the Article Image field— I entered “27,29,30,33,31,32”, and soo_image_select is showing them “27,32,33,30,29,31”.
Thank you again!
Last edited by johnstephens (2009-05-13 18:43:17)
Offline
Re: soo_image: simple yet powerful image tags
Glad we’re getting somewhere. As to the images not appearing in sequence, that is a bug in soo_image_select(). Find this block in that function:
if ( isset($ids) )
$query->where_in('id', $ids);
and replace with
if ( isset($ids) ) {
$sort = '';
$query->where_in('id', $ids)->order_by_field($ids);
}
Let me know if that preserves the sequence of article-images, and I’ll put it in the next release.
Code is topiary
Offline
Re: soo_image: simple yet powerful image tags
Looks like it sorted them into numeric order.
Article Image order: 27,29,30,33,31,32
Display order: 27,29,30,31,32,33
Offline
Re: soo_image: simple yet powerful image tags
My mistake; I did not have the ORDER BY FIELD syntax correct. Try this instead:
if ( isset($ids) ) {
$sort = '';
$query->where_in('id', $ids)->order_by_field('id', $ids);
}
Edit: Oops, need to edit soo_txp_obj also. Soo_Txp_Data class, order_by_field() function, replace with:
function order_by_field( $field, $list ) { // for preserving arbitrary order
if ( is_string($list) ) $list = do_list($list);
if ( count($list) > 1 )
$this->order_by[] = 'field(' . $field . ', ' .
implode(', ', quote_list(doSlash($list))) . ')';
}
Last edited by jsoo (2009-05-13 19:57:08)
Code is topiary
Offline
Re: soo_image: simple yet powerful image tags
Thanks— $query->where_in('id', $ids)->order_by_field('id', $ids); produces the same sort order as $query->where_in('id', $ids)->order_by_field($ids);.
Offline