XF 2.0 Any way to remove "Spoiler" from spoiler bbcode button?

tourmeister

Active member
So I really like the spoiler BBcode tag, as do my users. The problem is, I am finding useful for other things that aren't really spoiler related. It is great just for keeping things from loading until users want to see the hidden content. For instance, I use it with embedded Google maps like this,

[spoiler="Click here to see the map"][GMAP]!1m42!1m8!1m3!1d438983.5813412688!2d-97.7278369!3d30.7307894!3m2!1i1024!2i768!4f13.1!4m31!3e0!4m5!1s0x8644d6ba3d7bbd5d%3A0x9d86338f7c3da107!2sCelebration+Church%2C+601+Westinghouse+Rd%2C+Georgetown%2C+TX+78626!3m2!1d30.5850057!2d-97.6862048!4m3!3m2!1d30.639070699999998!2d-97.58088889999999!4m3!3m2!1d30.6751899!2d-97.4731218!4m3!3m2!1d30.7425452!2d-97.4768905!4m3!3m2!1d30.7968661!2d-97.4334683!4m3!3m2!1d30.964863299999998!2d-97.0941217!4m3!3m2!1d31.0449739!2d-97.16507759999999!5e0!3m2!1sen!2sus!4v1547090798759[/GMAP][/spoiler]

(The GMAP is a custom BBCode for embedding Google maps. I found the info on how to do that here on the site)

This way users can load the page to read the message without necessarily loading the map every single time they come back to the thread.

I would basically like to have a second BBcode tag that works exactly like the spoiler tag, but without the word "spoiler" on it. I still want to be able to add my own text to it.

Is there a way to copy the spoiler tag and then edit it via custom BBcode editing?
 
To half answer your question, take a look at the bb_code_tag_spoiler template :). Perhaps you could modify it so that "Spoiler" phrase will only show if the option parameter $title is empty? E.g. [spoiler] = "Spoiler" button, [spoiler=Directions] = "Directions" button & not "Spoiler: Directions". I haven't tried this, though!
 
I did this in XF1 with a simple template modification - this should give you some pointers: https://xenforo.com/community/resources/cta-spoiler-title.2824/

HTML:
<find><![CDATA[<span>{xen:phrase spoiler}{xen:if $titleHtml, ': <span class="SpoilerTitle">{xen:raw $titleHtml}</span>'}</span>]]></find>

<replace><![CDATA[<span>{xen:if $titleHtml, '<span class="SpoilerTitle">{xen:raw $titleHtml}</span>', '{xen:phrase spoiler}'}</span>]]></replace>
 
I did this in XF1 with a simple template modification - this should give you some pointers: https://xenforo.com/community/resources/cta-spoiler-title.2824/

HTML:
<find><![CDATA[<span>{xen:phrase spoiler}{xen:if $titleHtml, ': <span class="SpoilerTitle">{xen:raw $titleHtml}</span>'}</span>]]></find>

<replace><![CDATA[<span>{xen:if $titleHtml, '<span class="SpoilerTitle">{xen:raw $titleHtml}</span>', '{xen:phrase spoiler}'}</span>]]></replace>

So would I download the XML file then import it in the Custom BBcode section of the Admin CP? Will it work in XF2.0?
 
No, it won't work in XF2.

The point was to show that it is possible with a simple template modification, which you can adapt for XF2.
 
or you can use this add-on from @BassMan
 
or you can use this add-on from @BassMan

Thanks! I always favor an add-on versus me trying to mess with any code. I have no idea what I am doing in the code and am likely to break things without even realizing it :oops:
 
Top Bottom