Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#73 2007-07-20 16:57:15

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: smd_random_banner: Random banner image for advertising

Hi Stef, I have a site with a bunch of image ads representing sponsors. What I would like to do is place these images into an image category, then display all of the images in the page. Currently, I don’t see that this can be done with your plugin?

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

Edit: Someone posted in the thread I created for my issue – let me check this out…

Last edited by jstubbs (2007-07-20 17:00:07)

Offline

#74 2007-07-20 17:05:30

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

Re: smd_random_banner: Random banner image for advertising

Hi,
Although I personally want to know about this, I did something like this in a very manual way.
I created few categories where i uploaded different files. Then, I displayed them via this


<div id = "sideGallery">
<table width="100%"  border="0">
  <tr>
    <td>
<txp:smd_random_banner category="links_1" link_in="caption" referer="" limit="3" imgclass="randomBanner"/>
</td>
  </tr>
  <tr>
    <td>
<txp:smd_random_banner category="links_2" link_in="caption" referer="" limit="3" imgclass="randomBanner"/>
</td>
  </tr>
</table>
</div>

and in my css i used this

.randomBanner { margin: 3px 2px 3px 2px; }

I am not sure if this can help or not. I am currently trying out how to open link in new page. If I get it I will inform you.

Last edited by cdtavijit (2007-07-20 17:15:26)

Offline

#75 2007-07-20 18:03:52

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

Re: smd_random_banner: Random banner image for advertising

Hi Lamda,
Now you can open the links in new window too. Here is what you need to do. GO to the plugin, click edit and then Find out $outStr variable almost at the end. Then replace the following code. You actually only need to replace the <a href="' .$refertxt. '" > with this one <a href="' .$refertxt. '" target="_blank"> and that will do. But I am still pasting the are for your reference.

$outStr .= '<a href="' .$refertxt. '" target="_blank">' . (($thumb) ? thumbnail($imgOptions) : image($imgOptions)). '</a>';
				} else {
					$outStr .= (($thumb) ? thumbnail($imgOptions) : image($imgOptions));

Offline

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,447
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.

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: 11,447
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.

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: 11,447
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.

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: 11,447
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.

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

Board footer

Powered by FluxBB