BBcode with =

Get help developing custom BBCodes or request one.
Post Reply
Zanzazaar
Registered User
Posts: 31
Joined: Fri Jan 15, 2016 2:14 pm

BBcode with =

Post by Zanzazaar » Sun Apr 22, 2018 12:12 am

On earlier versions of phpbb3 (phpbb3.1 and phpbb3.0) I was able to create two bbcodes with almost the same name

Code: Select all

[name]{text}[/name]

Code: Select all

[name=]{text}[/name]
On phpbb3.2 those codes works with the same name, so I cant create both. Is this some kind of bug? Or should I create it in some other way now?

User avatar
JoshyPHP
Code Contributor
Posts: 963
Joined: Mon Jul 11, 2011 12:28 am

Re: BBcode with =

Post by JoshyPHP » Sun Apr 22, 2018 1:12 am

In 3.2 you'd only create one BBCode with any number of optional attributes, then you can use XSL elements such as xsl:if or xsl:choose to change the way it's displayed depending on the attributes. For example, a spoiler BBCode with an optional title:

Code: Select all

[spoiler title={TEXT?}]{TEXT}[/spoiler]

Code: Select all

<div class="spoiler">
	<xsl:if test="@title">
		<div class="title">
			<xsl:value-of select="@title"/>
		</div>
	</xsl:if>
	<div class="content">
		<xsl:apply-templates/>
	</div>
</div>
You could use it like this:

Code: Select all

[spoiler]...[/spoiler]
[spoiler=Title goes here]...[/spoiler]
https://area51.phpbb.com/docs/dev/3.2.x ... codes.html
http://s9etextformatter.readthedocs.io/ ... de_syntax/
I wrote the thing that does BBCodes in 3.2.

Zanzazaar
Registered User
Posts: 31
Joined: Fri Jan 15, 2016 2:14 pm

Re: BBcode with =

Post by Zanzazaar » Thu May 17, 2018 11:12 pm

Ok, I have problem with that... To this point I able to do whatever I want with html and JS. This is something that I never used before. Can I use XML:if for title but when title is equal to some text? Like title="box" one thing, and other when I put title="box2".


Are there any examples for new bbcodes? I also try to create autoclose bbcode hr but it did not work

Code: Select all

[hr $tag->rules->autoClose(true);][/hr]
- when I do that bbcode does not parse

Code: Select all

[hr $tag->rules->autoClose(true);]
- and I cant save this.

Code: Select all

[hr][/hr]
And this works as

Code: Select all

[hr]
but if user use button while posting that will input also closing tag.

User avatar
JoshyPHP
Code Contributor
Posts: 963
Joined: Mon Jul 11, 2011 12:28 am

Re: BBcode with =

Post by JoshyPHP » Fri May 18, 2018 12:19 am

You'd have to use something like that:

Code: Select all

[spoiler title={TEXT?}]{TEXT}[/spoiler]

Code: Select all

<div class="spoiler">
    <xsl:choose>
        <xsl:when test="@title = 'abc'">
            <div>ABC</div>
        </xsl:when>
        <xsl:when test="@title = 'xyz'">
            <div>XYZ</div>
        </xsl:when>
        <xsl:when test="@title">
            <div><xsl:value-of select="@title"/></div>
        </xsl:when>
        <xsl:otherwise>
            <div>No title</div>
        </xsl:otherwise>
    </xsl:choose>
    <div class="content">
        <xsl:apply-templates/>
    </div>
</div>
I wrote the thing that does BBCodes in 3.2.

Post Reply

Return to “Custom BBCode Development and Requests”

Who is online

Users browsing this forum: No registered users and 6 guests