Customizing SMF > SMF Coding Discussion
Automatically link certain words?
Arantor:
Well, if you're doing it after bbcode is performed, it's being done once per post but applied to HTML.
If you really wanted to get clever and do it based on items not within existing links, you could attach it to the output buffer code and do it once per page. Similar sort of principle, of course.
Going down that particular road is complicated depending on whether you'd prefer to do it cleanly or more simply (the cleaner version uses hooks and never touches any core files but will be 2.0 only)
emanuele:
Well, if you don't care about the 0.5% (or less) of people browsing with javascript disabled, javascript could be another option.
Arantor:
I wouldn't necessarily be inclined to do it in JavaScript on the client side, traversing the DOM is not going to be particularly wonderful, especially as you'd have to do it through full traversal and noting whether at any point the hierarchy you're within is encapsulated by an a tag... doable but going to be messy.
MrMike:
--- Quote from: Arantor on May 28, 2012, 07:31:30 PM ---Well, if you're doing it after bbcode is performed, it's being done once per post but applied to HTML.
--- End quote ---
That's why I'm doing it there- I want the transforms to take place after all the other processing is done so I'm working with the "finished product", so to speak.
However, I don't want to run the query for each post. I'd prefer to save the keywords array and reuse them, but I'm having a little trouble doing this so far.
--- Quote from: Arantor on May 28, 2012, 07:31:30 PM ---If you really wanted to get clever and do it based on items not within existing links, you could attach it to the output buffer code and do it once per page. Similar sort of principle, of course.
--- End quote ---
Yep, but I don't want to do the whole page, just the text in the posts.
--- Quote from: Arantor on May 28, 2012, 07:31:30 PM ---...depending on whether you'd prefer to do it cleanly or more simply
--- End quote ---
I'm a big fan of simple. :) I like clean and elegant, but sometimes it's more trouble than it's worth.
Arantor:
In which case, declare your keywords array as static inside prepareDisplayContext, if it's empty, perform the query. (Since it's static, it'll be preserved between runs)
I get what you mean about running it per post, it was more a suggestion of a possible course of action rather than a recommended course, as it were.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version