Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#76 2007-07-20 18:43:34

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,428
Website GitHub

Re: smd_random_banner: Random banner image for advertising

jstubbs wrote:

place these images into an image category, then display all of the images in the page.

It’s kind of possible but you’d have to cheat a bit and artificially increase the limit attribute to something bigger than the number of ads you’re likely to encounter in that category, e.g. 100, to make sure it didn’t miss any.

The images should open in a new window, too, if possible.

OK. First of all thanks to cdtavijit for hacking the code to do it. Nice one.

Secondly, I didn’t put an option to do that in the plugin because (as you probably know) from a usability perspective the consensus from designers is it’s a very bad thing. Plus, the W3C have deprecated the target= tag with the advent of XHTML and the default installation of TXP (if I recall correctly) uses XHTML as its default DOCTYPE. Might be wrong there, I forget.

The upshot is I probably shouldn’t support it from a purity point of view with all the media-rich devices out there, but if you aren’t able to convince your client otherwise or there’s some other overwhelming need to do it on a tag-by-tag basis (i.e. not just hack the code globally for one site as cdtavijit suggested) then I can certainly add an option to override the default behaviour.

Let me know your thoughts.


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#77 2007-07-20 19:04:58

cdtavijit
Member
From: Malaysia
Registered: 2007-07-20
Posts: 14
Website

Re: smd_random_banner: Random banner image for advertising

Hi Stef,
Thanks a lot =D
Well, I was working for one of my clients as well, and they wanted to have hundreds of images in random but linked. So, I had to find a solution. And they dont want people to go out of their website. So, they want people to open it in another place.

And I think this will be a very very common case for most people. So I would say it would be very good if you could use that target= as one of the options. I understand its non compliance and bla bla. But I think people still needs it and will need it for quite some time.

And I think it would be good if we could layout the images in rows and coloumns too. So that if we want to put it in the sidebar we can do that, if we want to put it in a form or a page we can do it too.

Well, thats what I think. =)

Offline

#78 2007-07-21 09:55:57

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,428
Website GitHub

Re: smd_random_banner: Random banner image for advertising

cdtavijit wrote:

I was working for one of my clients… they dont want people to go out of their website. So, they want people to open it in another place.

Yes, clients can be very demanding at times without realising the implications on us developers! I also know that “the customer is always right” but in some cases I’ve managed to change their minds by convincing them there is another way and it improves the website experience for their customers :-)

it would be very good if you could use that target= as one of the options.

OK, no problem. I should be able to add that fairly easily. EDIT: Target option now added in v0.23 (also packaged with the latest v0.21b of smd_lib in case you’re using an old version). Just add target="_blank" as an option to force a new window (or tab in FF/IE7) each time someone clicks a banner, or use some other name to always direct clicks to that specific window (e.g. target="advert_window"). NOTE: if you specify DOCTYPE XHTML 1.1, your page will not validate with this option.

And I think it would be good if we could layout the images in rows and coloumns too.

Unless I misunderstand your requirement, can you not do it like this:

<div class="banners">
  <txp:smd_random_banner category="adverts" link_in="caption" referer="" limit="24" />
</div>

and then, assuming your images are a standard size (say 20px square), use CSS to arrange them in rows of 4:

.banners {
  width: 120px;
}

.banners img {
  float: left;
  padding: 5px;
}

I’ve not tested that CSS, but something along those lines should let your images flow to fill the .banners container. You can then vary the number of rows and columns either by adjusting the overall width of the div or the size of the padding/margin between each image. Does that help or have I missed the point?

Last edited by Bloke (2007-07-27 16:09:02)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#79 2007-08-14 19:57:12

leaded
New Member
Registered: 2007-08-14
Posts: 3

Re: smd_random_banner: Random banner image for advertising

The download link doesn’t work for me. I can’t connect to any page on the server. Where can I download this plugin?

Thanks!

Offline

#80 2007-09-11 22:40:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,428
Website GitHub

Re: smd_random_banner: Random banner image for advertising

The latest major update takes the plugin to v0.3. (* cough * : now v0.3a – see edit below).

The docs have been overhauled (accounting for way over half the plugin’s size!) so might actually verge on useful now. Because of this I’m going to keep this post uncharacteristically short and sweet by asking you to RTFM to find out how to use the new options. The docs are in the plugin and also bundled as a separate html file in the zip.

The key new feature is the ability to switch the plugin between two modes of operation: the default (“classic”) image banner mode and the new (stable yet slightly experimental, but looks promising for upcoming versions) file banner mode.

Yes, that’s right. You can now serve random banners as Flash animations, movies, even audio(!) and it will mostly detect the file type and create the appropriate tags automagically. And if it doesn’t you can tweak it until it does. Put it this way: if there’s a browser plugin available, you can embed it on the page…

… probably.

I’ve not rigorously tested it and it would benefit from people who are more well-versed with the HTML <object> tag to help hone the templates it uses to generate the tags, but it seems to work. If I can get my head round it, upcoming versions in this branch will enable the template system and MIME types to be extended by you via plugin options, so you really will be able to play any type of content that you can upload to TXP’s File tab.

For now, stick to .swf / .flv / .wmv / .mov files and it should run straight out of the box. In addition, .avi and .mpg play in IE if you have the plugin, but Firefox struggles. Haven’t found out why yet… anyone? There isn’t much error checking yet either, so if you upload a file type that it doesn’t understand it’ll probably cry. But I think it validates: can’t be sure with every configuration. Anyone verify?

In theory you can also use link_in="description" to make the object clickable but your mileage may vary since most plugins refuse to allow an HTML anchor around embedded content.

I’ve tried all sorts of trickery including image maps hovering over the object, absolutely positioned divs/anchors, z-index tricks, the works. All to no avail. What’s more infuriating is there aren’t generally available methods to pass a URL into the player via object params (or flashvars in the case of Flash) so the banner becomes clickable. Grrr. If anyone knows otherwise or can help in this regard please please get in touch.

Finally, if you come up with any cool/useful <object> templates that you think should be in the next rev, send them to me or post them here to discuss.

Happy moving-content bannering :-)

EDIT: Bugette squashed that must have been around since the ark: if you supply a single category="?custom_field" option and the chosen field contains nothing, the plugin would erroneously return a random picture from the entire image pool. Now it will not do that; it will only return an image if there is a valid image category supplied in one of the fields.

This also impacts the always_display option because it merely removes any match_text / avoid_text and leaves the category option intact. So if you specify a bogus/empty category it will now return nothing in this case instead of defaulting to the whole image pool.

Let me know if that is backwards logic or if always_display should ditch any category you specify as well.

New version is v0.3a, also bundled with v0.22 of smd_lib.

Last edited by Bloke (2007-10-02 16:12:09)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#81 2007-09-25 16:12:44

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

Re: smd_random_banner: Random banner image for advertising

Exactly what I was looking for! Thank you!

I did run into a problem, though. I noticed I was getting the same image over and over again, same problem as a random text generator plug-in I’m using. I popped in a call to

mt_srand(mktime());

and now everything works as expected.


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

Offline

#82 2007-09-25 17:12:14

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,428
Website GitHub

Re: smd_random_banner: Random banner image for advertising

evergreenthompson wrote:

Exactly what I was looking for! Thank you!

Glad it’s useful. Got a minor update on the way to do with always_display (had an epiphany after my previous post). Watch this space.

I noticed I was getting the same image over and over again

Yeah, damn cacheing/optimasation. More trouble than it’s worth sometimes.

I popped in a call to mt_srand(mktime()); and now everything works as expected.

Cool, where in the code did you put that out of interest?

I remember a while ago discussing the issue of “stuck images” (in this forum I think) and the general consensus back then was that it was better to live with them than to add a random number to the URL to force a new image each time.

While I agree, I can see both sides of the argument so what I might do is add an option to the plugin. Then, if it bothers anyone, they can just have a random number tacked on the end of the URL or something. Unless you have found a better way of doing it, in which case let me know and I’ll build it in!

btw, the effect can be circumvented with the Admin->Prefs->Advanced->Send “Last-Modified” header set to “no”, but of course the downside is increased bandwidth usage and potentially slower pages for visitors.


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#83 2007-09-25 17:59:11

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

Re: smd_random_banner: Random banner image for advertising

Bloke wrote:

Cool, where in the code did you put that out of interest?

Actually, I stuck the call in the random text generator plug-in (simple_random_text by Manuel Ebert), because I call that plug-in before smd_random_banner.

BTW, I also tweaked his code to use mt_rand instead of rand, and that solved my rarely-changing random text problem. I usually saw the same text even when forcing page load from server instead of browser cache.

I remember a while ago discussing the issue of “stuck images” (in this forum I think) and the general consensus back then was that it was better to live with them than to add a random number to the URL to force a new image each time.

The less in the URL the better, IMHO.

While I agree, I can see both sides of the argument so what I might do is add an option to the plugin. Then, if it bothers anyone, they can just have a random number tacked on the end of the URL or something. Unless you have found a better way of doing it, in which case let me know and I’ll build it in!

I’m actually leaning toward moving that seed call to the guts of Textpattern. I’ve already done minimal hacks of the code to move the password file outside the browser accessible directories and “hide” the admin directory. Easy enough to add that to my checklist of mods for when a new version is released. That way, I won’t have to worry that the seeding has been done soon enough in page generation process, and it will be done for all plug-ins.

btw, the effect can be circumvented with the Admin->Prefs->Advanced->Send “Last-Modified” header set to “no”, but of course the downside is increased bandwidth usage and potentially slower pages for visitors.

That one’s a toss up for me. At this point I have very few regular visitors (probably always will be few), but I do like the idea of not needlessly fetching from the server.


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

Offline

#84 2007-09-25 19:15:33

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

Re: smd_random_banner: Random banner image for advertising

I went ahead moved the seed call out of that random text plug-in and into index.php at the root of my site, just before the call to textpattern();.

Not everyone may have to do this, but apparently I do. Seems like something Textpattern should be doing anyway (or PHP for that matter!), but what do I know! LOL


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

Offline

#85 2007-10-01 07:28:44

beno
New Member
From: Hamburg
Registered: 2004-10-31
Posts: 4
Website

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

#86 2007-10-01 08:35:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,428
Website GitHub

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.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#87 2007-10-01 12:34:07

beno
New Member
From: Hamburg
Registered: 2004-10-31
Posts: 4
Website

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

#88 2007-10-10 00:16:12

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,428
Website GitHub

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.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#89 2007-10-15 10:13:13

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,428
Website GitHub

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:

  1. The delimiter between the name and value is governed by the nv_delim option (in this case ::)
  2. 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.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#90 2007-11-07 01:24:58

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,428
Website GitHub

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.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB