Jump to content
xisto Community
vizskywalker

How To #4: Custom BBCodes For This Board (Pptions) More than one of them

Recommended Posts

So far m^e has made us aware of two variables for custom BBcodes: {option} and {content}. But what if you want to have multiple options for a tag, like, maybe foreground color and background color?

To do this all it takes is a simple php script.

If you remember parameters from DOS, it is jsut one list of words or symbols separated by spaces. Contrary to popular belief, this parameter list is one large variable in a program that gets parsed into smaller variables. That is exactly what we do for multiple options.

As an example, I'm going to use a simple highlight command (I don't know if this is the one m^e uses, but it is close enough for our purposes).

The TAG looks like this (angle brackets replace square brackets): <HIGHLIGHT = color>stuff you want highlighted</HIGHLIGHT>

The code for this looks like so:
<span style="background-color: {option}">{content}</span>

But if what if we want to edit the foreground color as well?

First create your single string of parameters separated by a space for the tag:
<HIGHLIGHT = backcolor forecolor>content</HIGHLIGHT>

Now for the code, simply use a php script and split the parameter list:

<?php$param = {option}; //place the options in paramlist($fore, $back) = split(" ", $param); //split the parametersecho "<span style="color: $back; background-color: $fore;">{content}</span>?>"; //send the style to the browser

It's that simple! If you want to allow the second parameter to have a default value then insert this code before echoing the span
if (!$back) { $back = "black";}

Share this post


Link to post
Share on other sites

Nice explaination of how to do a BBC highlight tag with more than one option.

 

I don't actually use IPB, so I don't need the specific code but the idea works for many needs.

 

Just one question:

<span style="color: $back; background-color: $fore;">

Seems off to me.

 

Shouldn't it read:

<span style="color: $fore; background-color: $back;">

 

A few more posts on Custom BBC codes for IPB, and we'll have to add a subforum. :P

 

Keep up the good work.

 

vujsa

Share this post


Link to post
Share on other sites

Um, yes, you are absolutely right, it should be

<span style="color: $fore; background-color: $back;">
And I wouldn't mind a subforum on this as long as people used the information to create custom BBcodes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.