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

free web hosting
Free Web Hosting > Computers & Tech > How-To's and Tutorials > Programming > HTML, XML and other Markup Languages

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

vizskywalker
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:
CODE
<?php
$param = {option}; //place the options in param
list($fore, $back) = split(" ", $param); //split the parameters
echo "<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
CODE

if (!$back) {
$back = "black";
}

 

 

 


Reply

vujsa
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:
QUOTE(vizskywalker)
<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. laugh.gif

Keep up the good work.

vujsa

Reply

vizskywalker
Um, yes, you are absolutely right, it should be
CODE
<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.

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. bbcodes colors - 99.53 hr back. (2)
  2. bbcodes foreground color - 246.06 hr back. (1)
  3. background color bbcodes - 346.56 hr back. (1)
  4. custom bbcodes - 212.39 hr back. (3)
  5. bbcodes background - 390.10 hr back. (1)
Similar Topics

Keywords : howto, 4, custom, bbcodes, board, options

  1. How To #3: Custom BBCdes For This Board (Note)
    (15)
  2. How To #2: Custom BBCodes For IPB (Marquee)
    (4)
    MARQUEE Tag Hi, I'm back with yet a second tutorial on how I created the MARQUEE tag.
    It's working well - but at first it'll seem that the tag has caused your browser to freeze.
    I guess depending on the different ways that IE and Mozilla Compliant Browsers parse HTML tags - the
    outputs are a little different. While using FireFox, the Marquee wouldn't start scrolling till
    all the page elements & the page itself has FULLY LOADED . Till then, it might seem that the
    browser's on the verge of freezing. On the other hand, in IE the Marquee starts ....
  3. How To #1: Custom BBCodes For IPB (Console)
    (2)
    Custom BBCodes for Forums -------------------------- Hi all, I came up with this article to share
    what I learnt of designing Custom BBCodes for various forum softwares while trying to come up with
    some useful one's for AstaHost. Most of you are by now familiar with the new ones like CONSOLE,
    NOTE, TABL etc. which I introduced a few days back. So how do these BBCodes work ? And how does the
    forum softwares parse them. BBCodes, as you know, usually takes a Text Stuff format. The
    "Text Stuff" in the textual content on which you want your bbcode to work. I....

    1. Looking for howto, 4, custom, bbcodes, board, options

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for howto, 4, custom, bbcodes, board, options
advertisement




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



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE