Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Plugin support
  3. » smd_slimbox

#265 2007-09-19 19:52:19

Ambitiouslemon
New Member
From: DC
Registered: 2007-09-19
Posts: 6
Website

Re: smd_slimbox

I get the following error when trying to use the thumbsize option

Tag error: <txp:smd_slimbox category=“gallery” thumbsize=“128,” /> -> Warning: preg_split() expects parameter 4 to be long, string given on line 160

textpattern/lib/txplib_misc.php(446) : eval()’d code:160 preg_split()
textpattern/lib/txplib_misc.php(534) : eval()’d code:402 smd_splitRange()
textpattern/publish.php:963 smd_slimbox()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/publish/taghandlers.php:1812 parse()
textpattern/publish.php:963 body()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/lib/txplib_misc.php:1383 parse()

Tag error: <txp:smd_slimbox category=“gallery” thumbsize=“128,” /> -> Warning: Invalid argument supplied for foreach() on line 161

textpattern/lib/txplib_misc.php(534) : eval()’d code:402 smd_splitRange()
textpattern/publish.php:963 smd_slimbox()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/publish/taghandlers.php:1812 parse()
textpattern/publish.php:963 body()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/lib/txplib_misc.php:1383 parse()
textpattern/publish.php:782 parse_form()

Tag error: <txp:smd_slimbox category=“gallery” thumbsize=“128,” /> -> Notice: Undefined offset: 0 on line 408

textpattern/publish.php:963 smd_slimbox()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/publish/taghandlers.php:1812 parse()
textpattern/publish.php:963 body()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/lib/txplib_misc.php:1383 parse()
textpattern/publish.php:782 parse_form()
textpattern/publish.php:808 doArticle()

Tag error: <txp:smd_slimbox category=“gallery” thumbsize=“128,” /> -> Notice: Undefined offset: 1 on line 409

textpattern/publish.php:963 smd_slimbox()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/publish/taghandlers.php:1812 parse()
textpattern/publish.php:963 body()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/lib/txplib_misc.php:1383 parse()
textpattern/publish.php:782 parse_form()
textpattern/publish.php:808 doArticle()

Tag error: <txp:smd_slimbox category=“gallery” thumbsize=“128,” /> -> Notice: Undefined offset: 0 on line 410

textpattern/publish.php:963 smd_slimbox()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/publish/taghandlers.php:1812 parse()
textpattern/publish.php:963 body()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/lib/txplib_misc.php:1383 parse()
textpattern/publish.php:782 parse_form()
textpattern/publish.php:808 doArticle()

Tag error: <txp:smd_slimbox category=“gallery” thumbsize=“128,” /> -> Notice: Undefined offset: 1 on line 412

textpattern/publish.php:963 smd_slimbox()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/publish/taghandlers.php:1812 parse()
textpattern/publish.php:963 body()
processTags()
textpattern/publish.php:922 preg_replace_callback()
textpattern/lib/txplib_misc.php:1383 parse()
textpattern/publish.php:782 parse_form()
textpattern/publish.php:808 doArticle()

Emi’s Bearhugs for Bravery

site: http://emisbearhugs.ambitiouslemon.com/gallery/

Offline

#266 2007-09-19 22:48:10

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,263
Website GitHub

Re: smd_slimbox

Ambitiouslemon wrote:

Warning: preg_split() expects parameter 4 to be long, string given on line 160

Eeeek! I can’t get that error so I guess my version of PHP must be inferior :-( Since I can’t replicate it, can you please try something for me so I can fix it. Go into the smd_slimbox code and scroll down about 3/4 of the way to the bit that starts:

// Handle thumbsize

A few lines further on you’ll find this:

$thumbSizes = smd_splitRange(trim($thumbsize), ",\s", "");

Can you swap the last “” for a 0 (a zero), save and try it again, i.e:

$thumbSizes = smd_splitRange(trim($thumbsize), ",\s", 0);

I’m not convinced that’ll fix it, but it might. If it does, that’s cool.

If it doesn’t, swap it back to the “” version and edit smd_lib instead. Scroll down almost all the way to the bottom to find the function smd_splitRange( ... ) { part. Immediately after the next line [ $retarr = array(); ], replace the line [ $elems = preg_split( ... ) ] with this chunk of code:

if (is_numeric($pregOpt)) {
	$elems = preg_split('/['.$splitat.']+/', $str, -1, $pregOpt);
} else {
	$elems = preg_split('/['.$splitat.']+/', $str, -1);
}

And give that a whirl. It’s not pretty but it should get round my hack for now until I can rethink the function parameters.

Let me know which, if any, of those work and I’ll implement the best one.

The other errors you received were just a cascade from this one, so they should clear up once it’s fixed. I did, however spot one more small (undefined index warning) bug which I’ll also fix tomorrow when I apply this patch. It shouldn’t appear unless you’re in debugging mode and it’s only a warning so shouldn’t bother you too much.

Sorry for the poor code and having to get you to be my test engineer: my version of PHP thinks the code is fine, which is a blatant lie now I just looked at the function parameters more closely! Thanks for pointing out the problem.

Last edited by Bloke (2007-09-19 22:50:49)


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

#267 2007-09-20 03:06:36

DrRogg
New Member
From: Tokyo, Japan
Registered: 2007-09-18
Posts: 4
Website

Re: smd_slimbox

Here’s what I’m using at the moment:

<txp:if_custom_field name="Cover Image ID (Main)">
<txp:php>

$a = custom_field (array ('name' => 'Cover Image ID (Main)'));

echo smd_slimbox (array(
    'imageid' => $a,
    'limit' => '1',
    'showpagelinks' => '0',
));

</txp:php>
<txp:else />
<p>No cover available.</p>
</txp:if_custom_field>

I have moved the css file, to be fair (it shares a folder called “slimbox” with the JS files) but smd_slimbox_inc reflects that, and like you say, you’d expect it not to work at all.

I’ve tried using <txp:smd_slimbox imageid="?Cover Image ID (Main)" limit="1" showpagelinks="0" /> instead, but that doesn’t show anything :S

Last edited by DrRogg (2007-09-20 05:50:06)

Offline

#268 2007-09-20 14:08:32

Ambitiouslemon
New Member
From: DC
Registered: 2007-09-19
Posts: 6
Website

Re: smd_slimbox

Tried both of these fixes and neither worked (although with txp I’m never sure since it seems to like caching pages to make testing difficult).

If it would be helpful I could give you access to the admin pages.

Last edited by Ambitiouslemon (2007-09-20 14:30:18)

Offline

#269 2007-09-20 16:09:36

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,263
Website GitHub

Re: smd_slimbox

DrRogg wrote:

I have moved the css file, to be fair (it shares a folder called “slimbox” with the JS files) but smd_slimbox_inc reflects that, and like you say, you’d expect it not to work at all.

Hmm, can’t think of anything offhand. Let me have a think about it while I make dinner.

I’ve tried using <txp:smd_slimbox imageid="?Cover Image ID (Main)" limit="1" showpagelinks="0" /> instead, but that doesn’t show anything

Ah yes of course. Spaces in name maketh plugin cry. I’ve only ever seen it used with underscores and dashes because my programming background has always made me shy away from spaces in anything; filenames, the lot.

In your case, the tag is looking for imageIDs in a custom field called “Cover” (and finding nothing) and also trying to make sense of ImageIDs numbered: “Image”, “ID” and “(Main)”, none of which are numeric so the tag returns nothing.

I’ve since learnt a better way of splitting strings up so I may be able to allow spaces in the next revision of (probably) smd_lib. I’ll test it out tonight and let you know if it works.


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

#270 2007-09-20 16:19:34

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,263
Website GitHub

Re: smd_slimbox

Ambitiouslemon wrote:

Tried both of these fixes and neither worked (although with txp I’m never sure since it seems to like caching pages to make testing difficult).

Hmmm. Thought one of them would work. Maybe I need to think harder :-(

And yeah, cacheing is a pain when testing. Have you set Admin->Prefs->Advanced->Send “Last-Modified” header (under the Publish section at the bottom) to “no”? That might help.

If it would be helpful I could give you access to the admin pages.

If you’re sure you don’t mind me poking about in the code then yes thank you that would be a big help. I’ll be as quick as I can. Let me know when would be the best time for you and send the details to me directly

Thanks.


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

#271 2007-09-20 18:01:33

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,263
Website GitHub

Re: smd_slimbox

@Ambitiouslemon:

OK, thanks. All done.

For reference, the first trick of putting ‘0’ in smd_slimbox did actually work. It was just that “other error” I mentioned you’d probably not encounter… well, you encountered it! So I’ve fixed that too for now. A new official version of smd_lib and smd_slimbox will be out later tonight to wrap up these little oversights – there are a few other places that might cause problems with “undefined index” errors so I’ll jump on those before they bite.

One thing: I added <txp:smd_slimbox_inc skip=“3” /> to the gallery article so I could see the output. You might want to move that to inside the <head> tag, and put the proper options in when you set it up :-)

Many thanks for letting me do that and also for spotting the bugs. Sorry it didn’t work for you first time.


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

#272 2007-09-20 21:17:52

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,263
Website GitHub

Re: smd_slimbox

OK, v0.29a is the official fix for the warnings encountered in debugging mode that Ambitiouslemon spotted.

Hand-in-hand with that is an update to smd_lib. The new version 0.22 has some internal enhancements so spaces are now allowed in custom field names. This should enable DrRogg to use imageid="?Cover Image ID (Main)". Just make sure your custom field names don’t contain commas and you’ll be ok! Anyone previously relying on the fact that category/ID lists could (unofficially) be supplied as comma- or space-separated lists will now have to use commas. But you can still use spaces around the commas: they get stripped off by the plugin.

It doesn’t address DrRogg’s weird extra blank space appearing and I’m at a bit of a loss to explain it. Your code is fine, and you seem to have covered all the bases. Do you have you a web link I could take a look at with the problem on it? I might be able to spot something. If the site’s not for public consumption yet, send me it privately

Hope this version helps anybody having issues with the plugin and the new space-aware stuff is of some use. Report any code wrongdoings/breakages/success stories with the latest version here as usual. And for my part I’ll try and remember the mantra: “Test the plugin with site debugging mode on before release…” :-)


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

#273 2007-09-24 10:17:14

fuls
Member
Registered: 2005-11-16
Posts: 117
Website

Re: smd_slimbox

Hi, I’m sorry if this has already been asked.
I have this inside my article form:

<txp:smd_slimbox category=”?id” imageid=”?article_image” imagecaption=”?alt” limit=“1”/>

and what I want to do is to show only one photo per article. When I open the big article photo, below the caption it says image 1of 5, but I only want to show 1 article image (it automatically starts previewing images form other articles).
Also, you’ve put MLP support which is really great, but how can we preview big photos with navigational images in different language (previous,next,close)?

Thank you very much!

Last edited by fuls (2007-09-24 10:18:07)

Offline

#274 2007-09-24 11:33:45

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,263
Website GitHub

Re: smd_slimbox

fuls wrote:

what I want to do is to show only one photo per article… it automatically starts previewing images form other articles.

Yes it will, especially on article list pages. It’s a feature/side-effect (you choose) with the way Slimbox works.

To change it, add the groupname option (examples) and use a unique value of either a fixed string per slimbox tag or make it automatically choose unique values by using something like groupname="?id" to limit the output to one photo only.

how can we preview big photos with navigational images in different language (previous,next,close)?

Good question. That bit’s out of my hands because the image URLs are hard-coded into the slimbox.css stylesheet. Two options as far as I can tell:

  1. Have a different style sheet per language that overrides the default slimbox.css and points at different image URLs. Perhaps include slimbox.css as normal but modify it to remove the references to the image URLs, then use some of the built-in MLP tags to include an ‘extension’ style sheet for the current language. Each such style sheet would contain your language-specific rules which in this case would hold the URLs to language-specific images
  2. Change the graphics to just arrows/symbols like ‘—>’ and ‘<—’ and ‘x’ :-)

Hope that helps.


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

#275 2007-09-24 13:42:50

fuls
Member
Registered: 2005-11-16
Posts: 117
Website

Re: smd_slimbox

Thanks Bloke, groupname did it!:)

Offline

#276 2007-09-25 16:20:30

evergreenthompson
New Member
Registered: 2007-09-25
Posts: 4
Website

Re: smd_slimbox

I love this plug-in. It works so much better than the other gallery plug-ins I’ve tried.

The only problem I ran across was with the sample CSS. I found it worked much better for me to rewrite the styles in tag.style form.

And I know it’s a no-no to change the CSS for Slimbox, but I couldn’t resist. :D


Lee
Whatever happens at the campsite stays at the campsite. Most of it anyway.

Offline

  1. Index
  2. » Plugin support
  3. » smd_slimbox

Board footer

Powered by FluxBB