Customizing SMF > SMF Coding Discussion
Automatically link certain words?
MrPhil:
--- Quote from: MrMike on May 29, 2012, 09:29:30 PM ---So, how does one make a mod out of this...is there an online guide or a step-by step tutorial?
--- End quote ---
@Arantor gave a link earlier to a discussion on the subject. I would read that and then pick apart two or three recent mod packages that do similar things, to get the nitty-gritty practical details. Maybe you could write a post in that discussion with interesting things you found. If you want to bounce any ideas or questions off of me, feel free to PM me. I don't have experience in putting together a mod, but I need to learn how myself as soon as I get some time to do it...
I would suggest that your code only link the first word or phrase on the page, rather than on a per-post basis. I know I get tired of seeing the same terms linked over and over on a page. On the other hand, it might be useful if a reader tends to jump directly to the last or to unread posts. I guess it could be argued either way... Would it be useful to be configurable in member profiles? I wonder if there are any legal issues to marking a trademark only way up top of a page, and someone doesn't see that mark because they came in "late" to the discussion? Perhaps there could be a per-word flag to force the processing of that word in each post?
Arantor:
Eh, putting together a mod is pretty straightforward, although using hooks is slightly more exotic.
The main reason why there isn't much of a tutorial is that historically, mods did their work by find/replace on the code itself, and it's kind of hard to provide a tutorial for something that's going to change just about every time.
MrMike:
--- Quote from: MrPhil on May 30, 2012, 11:23:50 AM ---I would suggest that your code only link the first word or phrase on the page, rather than on a per-post basis. I know I get tired of seeing the same terms linked over and over on a page.
--- End quote ---
I specifically want the words linked in each post, partly to make certain that people who come into the middle of a thread see it. Once per page is too easily missed (in my opinion).
At this point I'm only looking at one possible change, and that's a 'replacement type' field, where the replacement action could be to either link the word (as it does now) or replace it entirely with the contents of the replace field.
EDIT: I've added the "link or swap" feature above:
* In "link" mode it'll auto-link the word with the URL you provide.
* In "swap" mode it'll replace the word with whatever you provide (text, HTML, images, etc).Hopefully it'll give the mod a little flexibility and allow it to be used in other ways, as shown on this demo page:
http://deltabravo.net/forum/index.php?topic=39855.msg318677#msg318677
I figure someone may find it useful to style certain words (bold, italic, etc) or perform some sort of arbitrary replacement (an image, a button, whatever). The added flexibility may let people do other stuff with it as well (ad insertion, dynamic help boxes, etc).
--- Quote from: MrPhil on May 30, 2012, 11:23:50 AM ---Would it be useful to be configurable in member profiles?
--- End quote ---
Not for my intended use, but someone may consider that a useful option.
MrPhil:
The "swap this" entries seem need a double click to swap from white on green to black on white, and it only does one word at a time.
Shouldn't the "cake here" be showing and I need to click on it before changing to an image?
MrMike:
1) The "swapthis" entries are just static spans, they're just text. Double-clicking is just like clicking on any other text. What you're seeing is normal, expected behavior.
2) The image of the cake should be visible with no interaction (no clicking required). The tag "cake_here" is replaced with an image of a cake when the post is processed. I see the image of the cake in both Firefox and IE...what browser are you using?
--- Quote from: MrPhil on May 30, 2012, 11:48:02 PM ---The "swap this" entries seem need a double click to swap from white on green to black on white, and it only does one word at a time.
Shouldn't the "cake here" be showing and I need to click on it before changing to an image?
--- End quote ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version