Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: smd_random_banner: Random banner image for advertising
Thanks for the great plugin. Feels like I have found a bug.
The plugin acts on category names made up from numbers and math symbols as if they were mathematical expressions.
Case description: In a cat called “wolken” I have subcats on a monthly basis, i.e. “2007-01” and “2007-02” (January and February 2007) and the like.
Result: The plugin works fine on my article list, where I call for pictures from the main cat, but no image is shown for individual articles, where I call for pictures from the subcats.
Workaround: Putting the cat names between quotes did not work. After renaming the cats to “wolken-2007-02, “wolken-2007-01” and the like everything works as expected.
beno.de
Offline
Re: smd_random_banner: Random banner image for advertising
beno wrote:
Feels like I have found a bug. The plugin acts on category names made up from numbers and math symbols as if they were mathematical expressions.
Hi beno, you’re right it’s almost a bug; well, more a “feature” (as Micro$oft would call it) with an unfortunate side-effect, as you found.
See this smd_slimbox post about it: in a nutshell any two numeric-only values with a hyphen between them are treated as a range of numbers.
It’s a feature of smd_lib that allows a shorthand when specifying ranges of image IDs like 12-25
(used in smd_slimbox). Unfortunately it’s not yet intelligent enough to distinguish the problem you mentioned with ‘year-month’ categories (though ‘year-month-day’ is fine); nor is it clever enough to figure out that category names cannot ever be ranges of values but must always be treated as text instead.
I’m trying to find the best way round it for a future release without compromising functionality or making ugly code exceptions, but for now you’ve figured out the only known workaround: include any non-numeric character(s) – just one will do – in any year-month category names. I should have highlighted it in the help file actually, but forgot. Oops.
Sorry for the semi-bug. It’s the one problem I knew would catch someone out one day, but hoped I’d have a fix in place before it did! You beat me to it :-)
Last edited by Bloke (2007-10-01 08:38:20)
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
Re: smd_random_banner: Random banner image for advertising
Hi Bloke, thank you for your kind response.
I had visited the code of smd_random_banner to see how the magic is done, and as far as I could follow you put the given values into appropriate arrays. So it seems to me your plugin is in a way “aware” of where the vars do come from.
It’s good to know that you are aware of the problem and that I took the right way around.
beno.de
Offline
Re: smd_random_banner: Random banner image for advertising
Another update. This one extends always_display
so you really can make it always display an image if you poke the right values in. It now accepts increasingly harsh “levels” of 0, 1 or 2.
0 or omitted = off (no match, no display)
1 = the same as before (ignore match/avoid text)
2 = the same as 1, but if that produces no images it tries again ignoring category as well, thus going back to the whole image database. It’s probably unlikely you’ll need to go that far back, but some might.
One other addition is the nv_delim
option. For those (anyone apart from me?) using the cool new file mode for video banners, you can now override the default =
sign delimiter for name-value pairs. Very useful (actually, mandatory) when passing FlashVars into your banners. The docs have plenty of examples.
Oh, and I also fixed a naughty warning I hadn’t spotted when you used more than one random_banner on a page.
Here’s v0.31. Enjoy and report anything back here.
(btw, beno, I have now found a solution to the hyphens-in-category problem as well. It’ll be in the next major revision of smd_lib because it has some biiig changes in there and I need to be sure they don’t break any of my plugins)
Last edited by Bloke (2007-10-10 00:17:53)
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
Re: smd_random_banner: Random banner image for advertising
Two new features.
Added no_plug_text
for file mode so you can specify what to display within the object tag in the eventuality that the required plugin isn’t installed in the user’s browser.
Either put text or html in there, or give the name of an existing textpattern form to read instead. To use a form, specify it like this: no_plug_text="txpform:my_form_name"
. I did it that way because a) it saves you having to use asy_wondertag for a no_plug_text="<txp:output_form..>"
, and b) ‘txpform:’ is unlikely to occur in the text. I started out with ‘form:’ but realised the word was too generic.
Secondly, global_params
has been added. Name-value parameters have traditionally been specified in the description field of each file but this can become tedious for things like codebase
or values that don’t change often. Using global_params can help. For example:
global_params="codebase::http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,16,0;width::400;height::300;"
would apply those three attributes (codebase, width and height) to every file served up by the tag. If you were to override any of these values in the description field of a particular file, the file’s values would take precedence.
Two things to note about global_params:
- The delimiter between the name and value is governed by the
nv_delim
option (in this case::
) - The very last item in the list MUST end with a semicolon
Have fun with smd_random_banner v0.32 and as always shout if anything goes sideways.
Last edited by Bloke (2007-10-15 12:37:43)
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
Re: smd_random_banner: Random banner image for advertising
Another feature added: file mode support for swfobject.js.
The mime type of any file can be overridden such that we can “cheat” and offer a template to handle the javascript format of swfobject. This is done by adding mime_type="swo"
to either the description field of your target file, or as a global_param
which will affect all files chosen by the plugin. It supports most of swfobject but the express install feature is not yet implemented.
A few new attribute descriptors come along with it to give you control over the swfobject; all these are detailed in the online docs and in the plugin help. Note that the plugin now uses smd_lib v0.3.
So here’s v0.33 of the plugin. Usual rules apply: play hard, and if it breaks let me know.
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
Re: smd_random_banner: Random banner image for advertising
Apologies if I missed this earlier in the thread, but since there is a limit value (which means you can have a list of say 5 banners below each other), shouldn’t there be a setting for the ordering of them? I understand if “random” is all you want (hence the name ;) but people paying extra money to get the topmost placement won’t, you know, be so glad :)
cheers,
Last edited by Anton (2007-12-05 14:41:33)
Offline
Re: smd_random_banner: Random banner image for advertising
Another question (bear with me :): Is it possible to send an empty alt text to the banner? I’ve tried all I could but the alt value (a URL in my case) keeps showing up, thus invalidating my site.. :/
Offline
Re: smd_random_banner: Random banner image for advertising
Anton wrote:
since there is a limit value… shouldn’t there be a setting for the ordering of them?
I did kind of half consider this ages ago, then decided it was against the spirit of being random :-)
If you are trying to use it for paid-for adverts you’re probably out of luck anyway since it can only be told to grab images randomly from a list of categories that match (or don’t match) certain words. There is no ID support and I don’t think there is any way you could guarantee that a particular advert appeared in the rotation unless you have only one category set up with five banners in it and told the plugin to display five. The order will still always be random. Adding the ability to specify the order would be quite messy and involve code hacks; I assume you’re thinking of doing it by ID value? I could probably add a sort
option but how would it help you? Could you explain how you intended to use the plugin to guarantee placement to your banner clients? I might be able to do something if it’s not a major hack.
However — and I don’t often say this — perhaps this plugin is not the tool for the job if you are using it in this way. It’s more designed for offering “something else” or “something related” (or just “something”!) to visitors that could advertise (and link to) another local or remote URL.
In your case, you’re probably just as well uploading your client banners to a specific image category and using the built-in <txp:image>
tag to display them in a particular order. Or use 5 random_banner calls, and give each one a category holding one image :-s Alternatively there are probably plugins out there that allow multiple images to be displayed in order and can be given a limit
attribute.
Is it possible to send an empty alt text to the banner?
Yes, don’t specify one in the Image tab for the image in question. You’ll get alt=""
on the page ;-)
…the alt value (a URL in my case) keeps showing up, thus invalidating my site.
The plugin just uses the built-in image tag to display pictures so I’m at the mercy of that. It always displays the alt text and I can’t see a way of switching it off. If your URL is for banner-click purposes, I suggest using the caption field if possible, setting link_in="caption"
and clearing out the alt field (or using it for an image definition to maintain a valid page).
Quite why the page does not validate with a URL in your alt tag is a mystery though. Does it contain odd quote characters?
This really isn’t your day is it! Sorry.
Last edited by Bloke (2007-12-05 19:46:57)
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
Re: smd_random_banner: Random banner image for advertising
Thanx for your thorough reply, I understand the limitations of both the plugin and the image function better now.
In my case the banner solution is all the client paid for – they opted out a OpenAds variant and found the all-Textpattern solution better for them.
FYI, I made a slight modification for when the alt text contains a <script>
tag, refering to banners hosted elsewhere, and also using the caption field to keep track of impressions (a URL to an empty image is stored there). These kinds of URLs seldom validate though (&
are most always coded wrong), hence my other question.
Your last suggestion sounds like reversing what I’ve instructed the client to do – this would benefit the validation I guess, but at the cost of confusing the client with changing directions.. I might consider it for a future client/project though so thanks for the idea!
cheers,
Offline
Re: smd_random_banner: Random banner image for advertising
Anton wrote:
I made a slight modification for when the alt text contains a
<script>
tag, refering to banners hosted elsewhere, and also using the caption field to keep track of impressions (a URL to an empty image is stored there).
Cool, I never thought of that, having not really considered it for this kind of “pro” application. I suppose it does make sense to be able to offer paid-for banners. I’ll give it some thought. Might even spawn a spin-off plugin if this one can’t manage it neatly.
Would you please email me the code changes. I’ll have a look and see if it’s the sort of thing that could be expanded and built into the next official release. And if you have any links about how this sort of thing is traditionally used and how referer tracking and stuff like this happens in the real world, it’d be most appreciated. Affiliate tracking and the like is a dark art to me :-)
Many 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
Re: smd_random_banner: Random banner image for advertising
Oh, the hacks I made aren’t nearly as sofisticated as I would’ve liked, I’m not a PHP wizard ;)
But in essence: On line 460, check or if the field contains a <script>
tag, e.g. using if (preg_match("/<script/i", $linkurl))
or similar, and just output the field value if there’s a match. (I also made a str_replace("&","&",$refertxt);
here for validations sake, feel free to do this elsewhere.)
Right after that, check similarly for a URL in the caption, e.g. if (preg_match("/http:/i", $row['caption']))
and add a minimalistic image right after the banner: $outStr .= '<img src="' .$referimg. '" border="0" width="1" height="1" />
.
There’s no more black art than that, I’m afraid :) Fact is, the whole “adosphere” (is there a word for that?) is scaringly hacky, with document.write()
, validation errors, browser sniffing and other obtrusive scripting dating back to last century all over the place..
Offline