Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2006-09-19 12:11:19

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_random_banner: Random banner image for advertising

I decided to do it in two stages. First adding the options use_alt and match_text as recommended by Luke and next (probably after a healthy chocolate bar or three) I’ll tackle the subcats.

So, shuffling past the unreleased v0.13, here’s v0.14 for you to try out. I’ll fix all the help and links at the start of this thread in a mo.

Hope it does what you want. Any probs, wibbles or enhancements, just shout and I’ll see what I can do.

Last edited by Bloke (2006-09-19 13:17:18)


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

#14 2006-09-19 13:43:03

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

Re: smd_random_banner: Random banner image for advertising

Wow. you the man!

Unfortunately the download linky is not working right now (can’t find server?)

I await with bated breath…


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

#15 2006-09-19 13:52:25

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_random_banner: Random banner image for advertising

lukepermsn wrote:

Unfortunately the download linky is not working right now (can’t find server?)

Curious, works from here… I have had issues in the past where my hoster just denies existence of my site(s) to seemingly random IP addresses because of spamming by someone else who had the IP before you. As a random stab-in-da-dark, it could be that.

Tell you what, I’ll temporarily host it on my works’ server (shhhh!) I’ll probably take it off before the end of the day so grab it quick.

Download v0.14 alternate location

Last edited by Bloke (2006-09-19 13:53:44)


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

#16 2006-09-19 14:01:42

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

Re: smd_random_banner: Random banner image for advertising

ahhh. could be the corp firewall i’m behind here. can be a tricky fella…

that URL worked fine though – off to test now!

L.


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

#17 2006-09-19 14:22:40

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

Re: smd_random_banner: Random banner image for advertising

hmm. no dice!

i get an error msg:

<code>tag_error <txp:notice message=“malformed random_banner tag” /> -> Textpattern Warning: unknown_tag</code>

i’m using:

<code><txp:smd_random_banner use_alt=“1” match_text=”?” look_in=“title,category” /></code>

which, by all accounts, should display any image from the library that match words in the alt text with words in the title or category?

however, if i take ‘match_text’ out and replace with ‘avoid_text’ images start to appear – which i assume are now avoiding words in the title or category that also appear in the alt text…

or did i miss something? :-)

L.


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

#18 2006-09-19 14:25:51

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

Re: smd_random_banner: Random banner image for advertising

One quick question: does ‘avoid’ or ‘match’ text look at whole words only, and is it case sensitive?


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

#19 2006-09-19 15:09:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_random_banner: Random banner image for advertising

lukepermsn wrote:

hmm. no dice! i get an error msg:

Bugger. That was me being stupid and not testing what happens if no images match. It shouldn’t return an error it should just return, well, nothing. So now it does just that.

<code><txp:smd_random_banner use_alt=“1” match_text=”?” look_in=“title,category” /></code>
which, by all accounts, should display any image from the library that match words in the alt text with words in the title or category?

Not quite. It will display any image from the library that match words in the alt text with the whole of the title or the whole of the category (or section). At the moment it doesn’t split the title, category or section into its discrete words. This is for two reasons right now:

1) What would I split the words at? Maybe 80% of the TXP world might use hyphen-as-the-separator but not all will.

2) Once I’ve split the words I need to tell the database to match against each word and I haven’t figured out how to do that efficiently yet. It’d turn into spaghetti-code, which annoys me when I come back to it three months later.

Having said that I just found another bugette which, for some reason, didn’t show itself when I tested it earlier because I was only testing it at the section/category level. When I view an actual article within a category it tries to match “title?c=category_name” as the title instead of giving each part to me separately. Didn’t realise that was the way TXP hands the “title” to me, so I have to process it one more step.

Just done that. Let’s pretend the old version of 0.14 never existed eh? ;-)

Try the link again. If the fact it doesn’t split the URL title into its component parts is a show-stopper for you I can try and figure out how to split them up without making the database cry. It’s probably not tricky for someone who speaks fluent SQL. I’m not that someone :-(

Sorry about the false start…

Last edited by Bloke (2006-09-19 15:20:29)


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

#20 2006-09-19 15:11:08

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_random_banner: Random banner image for advertising

lukepermsn wrote:

One quick question: does ‘avoid’ or ‘match’ text look at whole words only, and is it case sensitive?

part 1: See above post.
part 2: yes, because TXP is


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

#21 2006-09-19 15:31:58

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

Re: smd_random_banner: Random banner image for advertising

Bloke wrote:

Sorry about the false start…

haha, no problem. i apreciate this is all work in progress ;-)

i guessed that might have been the problem you described above.

actually, matching whole, case-sensitive words is perfect – i just realised that some images are labeled ‘Antarctica’ – whereas the article in question says ‘Antarctic’ – so I potentially have a problem there – but that can be easily solved by adding ‘Antarctic’ to the alt text.

it could however be a problem if the article title is ‘Antarctic-Peninsula’ – does this mean that I need to have ‘Antarctic-Peninsula’ in the alt text? (hyphen included…)

this is all fine. just a bit of grunt work adding the keywords!

i’m back to my day job now (bore) so i’ll try testing the plug-in a bit more this evening!

cheers :-)
Luke

Last edited by lukepermsn (2006-09-19 15:32:43)


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

#22 2006-09-19 15:53:20

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: smd_random_banner: Random banner image for advertising

lukepermsn wrote:

it could however be a problem if the article title is ‘Antarctic-Peninsula’ – does this mean that I need to have ‘Antarctic-Peninsula’ in the alt text? (hyphen included…)

At the moment, unfortunately yes. You’re right though, the more I think about it, the more it makes sense to split the category/section/title up and look for individual words. I really only based it on section when I designed it and just threw ‘title’ and ‘category’ in because they were easy two-liners. Some adage involving the words ‘piss-poor’ and ‘planning’ is coming to mind :-D

Right, this is what I’ll try and do:

1) Find out if TXP can give me the title-format information in a form I can use. I don’t anticipate it will, but there may be a cool function hidden in the API somewhere that might return me a ‘-’ if that’s the character used, or something else if someone’s elected to use a different character. For people using CamelCase I’m pretty much stuffed.

2) Based on that I can split the category/section/title into its constituent words. Failing that I’ll assume a hyphen and fix it later if that’s not to taste.

3) Next, I can find some efficient way of querying the database looking for images that have any of those words in them. Easier said than done with my (lack of) SQL skills, but there must be a way using IN( list, of, words ) or something.

4) I’ll make this the default behaviour and add an option to override it, e.g. whole_urls=“1” (or something better if you have any ideas – I’m rubbish at naming options)

Sound like a plan?


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

#23 2006-09-19 16:09:30

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

Re: smd_random_banner: Random banner image for advertising

Sounds great – it’s nice to be part of the process of building creating this plug-in!

I reckon that if anyone is using CamelCase, they wouldn’t find this plug-in very useful, as the word searching would be completely negated by that form of title / section / category…

I wish I knew more about SQL to help with your querying – I’m looking forward to doing some thorough testing tonight and will certainly report back all my findings!

Cheers. L.

Last edited by lukepermsn (2006-09-19 18:31:53)


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

#24 2006-09-19 19:34:00

lukepermsn
Member
From: london
Registered: 2004-07-15
Posts: 57
Website

Re: smd_random_banner: Random banner image for advertising

Hi mate,

Have been playing with this a bit now, and it appears to work completely as expected! Very cool indeed.

What’s really nice is that it seems that it doesn’t matter how words are formatted in the ‘alt text’ – as the plug-in picks out individual words whether they are separated by hyphens or spaces? It might be worth clarifying that one.

Now I’m playing with this, the tag I think I will most likely use is:

<code><txp:smd_random_banner use_alt=“1” match_text=”?” avoid_text=“Schools,School,Project,landscape” look_in=“title,category” /></code>

Which essentially (if I understand correctly) displays any image from the library that contains words in the alt text that match the title or category text, but avoid displaying any images with the words ‘Schools’, ‘School’, ‘Project’ or ‘landscape’ in the alt text.

However, what happens if a word in ‘match_text’ is also found in ‘avoid_text’?

i.e. some images have alt text: “Kenya School Project” – which I still don’t want to appear on the Kenya page, so essentially it would seem that ‘avoid_text’ should be used as a conditional negator for ‘match_text’ – does that make sense?? ;-) i.e. anything in ‘avoid_text’ should overrule words found in ‘match_text’ if the ? operator is used.

For some ultimate grooviness, the ability to negate categories / subcats would be genius – as I could then use:

<code><txp:smd_random_banner category=”!header, !detail” use_alt=“1” match_text=”?” avoid_text=“Schools,School,Project,landscape” look_in=“title,category” /></code>

Which essentially would prevent any images showing from the ‘header’ or ‘detail’ categories in the library!

Brain bending indeed – but becoming a quite powerful random / related / contextual image plug-in!

L.

Last edited by lukepermsn (2006-09-19 19:35:30)


“Absorb what is useful, Discard what is not, Add what is uniquely your own” – Bruce Lee

Offline

Board footer

Powered by FluxBB