Custom spoiler bbcode

Get help developing custom BBCodes or request one.
Post Reply
Lebster
Registered User
Posts: 2
Joined: Wed Nov 21, 2018 8:08 pm

Custom spoiler bbcode

Post by Lebster »

I'm trying to create a custom spoiler BBCode, but when I try to create it, I get this message:

Code: Select all

SQL ERROR [ mysql4 ]

Incorrect string value: '\xF0\x9F\x94\xBB H...' for column 'bbcode_tpl' at row 1 [1366]

SQL

INSERT INTO phpbb_bbcodes (bbcode_order, bbcode_group, bbcode_tag, bbcode_match, bbcode_tpl, display_on_posting, bbcode_helpline, first_pass_match, first_pass_replace, second_pass_match, second_pass_replace, bbcode_id) VALUES (20, '5', 'spoiler', '[spoiler]{TEXT}[/spoiler]', '<script src=\"https://code.jquery.com/jquery-3.2.1.min.js\"></script><div id=\"spoiler\"> <b id=\"spoilertext\">▶️ Show Spoiler</b> <div id=\"spoilercontent\"> <p id=\"spoilerinner\">{TEXT}</p></div></div><script>var shown=0; $(\'#spoilertext\').click(function(){if (shown==0){$( this ).next().css(\'display\', \'block\'); $( this ).text(\'🔻 Hide Spoiler\'); shown=1;}else{$( this ).next().css(\'display\', \'none\'); $( this ).text(\'▶️ Show Spoiler\'); shown=0;}});</script><style>#spoiler{background-color: lightgray; border-radius: 05px; padding-left: 5px; padding-bottom: 1px;}#spoilertext{font-family: sans-serif;}#spoilertext::selection{background: transparent;}#spoilertext::-moz-selection{background: transparent;}#spoilertext:hover{color: rgb(230, 0, 0); cursor: pointer;}#spoilercontent{position: relative; bottom: 9px; display: none;}#spoilerinner{font-family:sans-serif;}</style>', 0, '', '!\\[spoiler\\](.*?)\\[/spoiler\\]!ies', '\'[spoiler:$uid]\'.str_replace(array(\"\\r\\n\", \'\\\"\', \'\\\'\', \'(\', \')\'), array(\"\\n\", \'\"\', \'&#39;\', \'&#40;\', \'&#41;\'), trim(\'${1}\')).\'[/spoiler:$uid]\'', '!\\[spoiler:$uid\\](.*?)\\[/spoiler:$uid\\]!s', '<script src=\"https://code.jquery.com/jquery-3.2.1.min.js\"></script><div id=\"spoiler\"> <b id=\"spoilertext\">▶️ Show Spoiler</b> <div id=\"spoilercontent\"> <p id=\"spoilerinner\">${1}</p></div></div><script>var shown=0; $(\'#spoilertext\').click(function(){if (shown==0){$( this ).next().css(\'display\', \'block\'); $( this ).text(\'🔻 Hide Spoiler\'); shown=1;}else{$( this ).next().css(\'display\', \'none\'); $( this ).text(\'▶️ Show Spoiler\'); shown=0;}});</script><style>#spoiler{background-color: lightgray; border-radius: 05px; padding-left: 5px; padding-bottom: 1px;}#spoilertext{font-family: sans-serif;}#spoilertext::selection{background: transparent;}#spoilertext::-moz-selection{background: transparent;}#spoilertext:hover{color: rgb(230, 0, 0); cursor: pointer;}#spoilercontent{position: relative; bottom: 9px; display: none;}#spoilerinner{font-family:sans-serif;}</style>', 32)

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 994
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysql.php
LINE: 191
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 329
CALL: phpbb\db\driver\mysql->sql_query()

FILE: [ROOT]/includes/acp/acp_bbcodes.php
LINE: 276
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/includes/functions_module.php
LINE: 676
CALL: acp_bbcodes->main()

FILE: [ROOT]/adm/index.php
LINE: 82
CALL: p_master->load_active()
HTML:

Code: Select all

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script><div id="spoiler"> <b id="spoilertext">▶️ Show Spoiler</b> <div id="spoilercontent"> <p id="spoilerinner">{TEXT}</p></div></div><script>var shown=0; $('#spoilertext').click(function(){if (shown==0){$( this ).next().css('display', 'block'); $( this ).text('🔻 Hide Spoiler'); shown=1;}else{$( this ).next().css('display', 'none'); $( this ).text('▶️ Show Spoiler'); shown=0;}});</script><style>#spoiler{background-color: lightgray; border-radius: 05px; padding-left: 5px; padding-bottom: 1px;}#spoilertext{font-family: sans-serif;}#spoilertext::selection{background: transparent;}#spoilertext::-moz-selection{background: transparent;}#spoilertext:hover{color: rgb(230, 0, 0); cursor: pointer;}#spoilercontent{position: relative; bottom: 9px; display: none;}#spoilerinner{font-family:sans-serif;}</style>
I'm also trying to convert the HTML from working with IDs to classes to allow for multiple spoilers.
Can anyone help me? Thanks.
User avatar
AlfredoRamos
Recognised Extension Developer
Posts: 1302
Joined: Wed Dec 25, 2013 9:06 pm
Location: /dev/null
Name: Alfredo
Contact:

Re: Custom spoiler bbcode

Post by AlfredoRamos »

The BBCode engine does not allow invalid HTML in the BBCode template.

jQuery is already included, so there' no need for that, and the CSS code can be included in a file of your theme.

Your can use this extension I made:

https://www.phpbb.com/customise/db/exte ... er_bbcode/
Some of my phpBB extensions:
:chart_with_upwards_trend: SEO Metadata | Image Markdown | :shield: hCaptcha
:trophy: Check out all my validated extensions :trophy:

:penguin: Arch Linux user | Linux Boards :penguin:
Post Reply

Return to “Custom BBCode Development and Requests”