[Request] BBCode alignment style MyCodes
#1
Hello.

You see, my forum used to be hosted in a another site with phpBB forum software. That means that the alignment code was [center] [left] [right], unlike MyCode defaults that are [align=center] [align=left] [align=right].

Now we are moving to a MyBB platform, and we are also moving our valuable topics.

My users tend to simply copy & paste the content of such topics, and most of them are unaware of the alignment difference.

I would like to request for custom MyCode to accept alignment like
[center] [/center]
[right] [/right]
[left] [/left]

I am still keeping the [align=center] style too. Basically I want my board to support both styles.

I know this sounds pretty simple, but I fear to write the wrong code and screw everything, for I'm not very experienced on this.

Thanks.
Reply
#2
On the AdminCP, go to Configuration, then MyCode (on the left side).

Add this MyCode.
Regular expresion:
\[(left|center|right)\](.*?)\[/\1\]

Replacement:
<div style="text-align: $1;">$2</div>
Microsoft is like Umbrela Co., they create the virus and the vaccine, the zombie infestation is just a collateral effect.
Reply
#3
It doesn't seem to be working =/
Reply
#4
Oops, there was an additional '\'.

Try again with the ones on my first post. Working for me.
Microsoft is like Umbrela Co., they create the virus and the vaccine, the zombie infestation is just a collateral effect.
Reply
#5
Thanks! Seems to be working.

Though it seems I can't stack them, like
[right][center]should be center[/center][/right]
Which outputs exactly this:

[center]should be center[/center]

Now you might be wondering why the heck would someone want to stack two alignment BBCodes. Well, it isn't something we want, but it does happen often. For example, someone's post is centered. So the whole post is inside [center] tags. BUT! This guy wants the title to be left aligned. So I will put [left] tags around the title. The [left] tags take priority since they are deeper than the [center] tags.

Can this be fixed? Since these are regular expressions I'm not sure...
Reply
#6
In that case, the code will need to be migrated to a plugin, because there's an additional line of code that need's to be applied to the replacement.

I'll adapt the code to a plugin, however can't at this same moment, probably somebody else can do it, but I don't have time.

Be back in about 3 hours.
Microsoft is like Umbrela Co., they create the virus and the vaccine, the zombie infestation is just a collateral effect.
Reply
#7
Regular Expression:
\[(.*?)\](.*?)\[/(.*?)\]

Replacement:
<div align="$1">$2</div>
Reply
#8
Try this:


Attached Files
.php   altalign.php (Size: 652 bytes / Downloads: 157)
Microsoft is like Umbrela Co., they create the virus and the vaccine, the zombie infestation is just a collateral effect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)