Help Requested: Making a tag for Gradient; I sorta got it working BUT it'd be much better if the # sign could be read

Get help developing custom BBCodes or request one.
Post Reply
Cryptozoid
Registered User
Posts: 38
Joined: Fri Feb 24, 2017 8:51 pm

Help Requested: Making a tag for Gradient; I sorta got it working BUT it'd be much better if the # sign could be read

Post by Cryptozoid »

The idea is, to make a gradient tag that allows a background gradient to use more than two colors. I wrote the following tag; it requires at least for parameters to be filled in, separated by semicolons, not commas (unless specified otherwise):

NB field 3 is where the problem is (specified below the code).
  1. left | right| center| justified
  2. starting color
  3. ending color (OR: second color to ending color; these should be separated by a comma, not a semicolon!)
  4. text color
oh,and some text of course as well.

Code: Select all

[grad={IDENTIFIER};{COLOR1};{SIMPLETEXT};{COLOR2}]{TEXT}[/grad]

Code: Select all

<div align="{IDENTIFIER}" style="background-color: {COLOR1}; background-image: -webkit-linear-gradient(top, {COLOR1},{SIMPLETEXT}); background-image: linear-gradient(to bottom, {COLOR1},{SIMPLETEXT}); background-repeat: repeat-x; border: 0px; margin: 0px; padding: 2px"><span style="font-family: 'Russo One'; color: {COLOR2}; font-size: 200%; line-height: 200%">{TEXT}</span></div>
I got this working, but only if for the ending color (OR: second color to ending color) color names like 'red', 'yellow' and 'blue' are used. Color codes like '#FF6600' don't work, most probably because the # sign is not recognized within the SIMPLETEXT token. I realize I could use TEXT (it'd be TEXT1, and the actual text would become TEXT2) but then there is a security risk (the software warns me of that, and it is obvious as well: a user could then 'end' this tag in the TEXT1 field, and then include some java script or other undesirable stuff).

If only SIMPLETEXT would be able to read the # sign, it would most probably have worked fine this way :|

Is there a way to work around this?
User avatar
JoshyPHP
Code Contributor
Posts: 1288
Joined: Mon Jul 11, 2011 12:28 am

Re: Help Requested: Making a tag for Gradient; I sorta got it working BUT it'd be much better if the # sign could be rea

Post by JoshyPHP »

Try using multiple attributes instead of cramming them all together, e.g.

Code: Select all

[grad align={IDENTIFIER} color={COLOR1}]{TEXT}[/grad]
I wrote the library that handles markup in phpBB 3.2+.
Cryptozoid
Registered User
Posts: 38
Joined: Fri Feb 24, 2017 8:51 pm

Re: Help Requested: Making a tag for Gradient; I sorta got it working BUT it'd be much better if the # sign could be rea

Post by Cryptozoid »

EDIT thanks; I now realize your post wasn't so much an answer to my question but to the way that I wrote the tag, and I see why you are right.
JoshyPHP wrote: Wed Apr 05, 2017 11:45 am Try using multiple attributes instead of cramming them all together, e.g.

Code: Select all

[grad align={IDENTIFIER} color={COLOR1}]{TEXT}[/grad]
As for my question, however, it wouldn't be helpful. The idea is that the tag can be used to make a simple color1 to color2 gradient, but also a gradient of, say, seven colors. So, that's essentially my question: how to allow for a user to just pick one, but also pick three or eight colors by using the same token.

The user should be able to pick as many colors as desired (with a minimum of two).
Post Reply

Return to “Custom BBCode Development and Requests”