|Printable Version of Topic
Click here to view this topic in its original format
|Jcink.com Forums > General Support > BBCode in topic titles?|
|Posted by: spike May 16 2018, 12:49 AM|
|Is there a simple code that can be added to allow this? Have one on my Zetaboards and our members like to color, bold, italics, their topic titles etc|
|Posted by: John May 16 2018, 09:38 AM|
|Posted by: kjrod98 May 16 2018, 10:39 AM|
You know, I hacked this together a few years ago and I've been intending to throw this at the resource sites. Thanks for reminding me!
Okay so, this goes just above the end body tag in your board wrappers. You'd have to replace the classes with wherever your topic titles/descriptions are contained. I've included the classes where topic titles/descriptions appear for the default skins, so it'll display everywhere - search, topic listing/inside topics, board index and recent topics. If you're using HTML templates, all you have to do is add in the extra classes or IDs.
.replace(/\[o]/gi, '<span class="open">[OPEN]</span>')
The piece in red is what the user enters into the topic title or description. The piece in blue is what it's replaced by. Can be an image or whatever else so long as you watch your quotation marks.
Since you're wanting bbcode tags, you could do this. though you'd have to have two lines for a single tag so it may get messy depending on how much you're going for. You also have to escape each "/" for the closing tags or it won't work.
And some quick screengrabs of it in action, works nicely with custom HTML templates.
|Posted by: John May 16 2018, 10:40 AM|
|That's totally awesome kjrod98 thank you so much for the contribution!|
|Posted by: Gaomon274 May 16 2018, 10:41 AM|
| I'm not entirely sure which one he's using, but I know this one by Cory is one I've seen others use so it's probably this.
Edit - Or hey that works too.
|Posted by: spike May 16 2018, 02:58 PM|
| Yes Gaomon that's the one we used, it's great. Cory has been a tremendous contributor over the years, I hope he comes over to Jcink too! Got it working, thanks a lot kjrod98! If anyone is interested in the full code to use for bbcode in the topic titles I'm using (bold, italics, underline, color, bgcolor) here it is:
The only issue I see at the moment is (not sure about other browsers) in Chrome on the tab it shows the raw BBCode for the tab name it didn't do this in ZB, wonder what's missing?
Just a note though, I tried setting my topic title length to 0 for disabled max. length but it wasn't working?
|Posted by: spike May 16 2018, 11:44 PM|
I figured this out and updated the code accordingly. Another issue though:
For some reason the full title isn't showing and cutting off like that no matter what theme I use, even default. Seems if it's past a certain character length its doing that as below you can see with a short one it looks fine:
I seem to remember Cory's code having this problem too and he fixed it but I'm not sure what he added to his original code to do that.
|Posted by: John May 18 2018, 03:18 PM|
| Yeah that's a system core functionality and happens regardless of any skin. The topic title on the board index is clipped with '...', I am going to have to look at adding an option to disable it for your needs since I don't see any way around it.
Also, topic title lengths themselves are limited to 250char even if you set it to "0", that just disables the range, but the max still applies.
|Posted by: kjrod98 May 18 2018, 05:18 PM|
How did you manage to work around that? I'd never even thought about it being an annoyance until you pointed it out.
|Posted by: Dusty May 20 2018, 02:52 PM|
You can set the title attribute to the cleaned string by running the .text() method on itself after parsing the BB code into HTML.
For what it's worth, I wrote this script a little while ago to also utilize whitelisted single parameter tags (gotta filter out dem <script> and redirect injections). Not pretty but AH WELL
|Posted by: spike May 21 2018, 01:51 PM|
This is the line that does that, I just tried to teach myself what all the components of Cory's code did to achieve it and John if you could do that, it'd be a great help I'll PM you my test board. And nice Dusty!