|
|
|
|
![]() ![]() |
Apr 3 2005, 12:12 AM
Post
#1
|
|
|
Techno-Necromancer Group: Members Posts: 1,018 Joined: 13-January 05 From: The Net Member No.: 2,127 |
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"; } |
|
|
|
Apr 3 2005, 01:26 AM
Post
#2
|
|
|
Absolute Newbie Group: Admin Posts: 887 Joined: 20-February 05 From: Indianapolis, Indiana, USA (Midwest) Member No.: 2,714 |
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. Keep up the good work. vujsa |
|
|
|
Apr 4 2005, 11:25 AM
Post
#3
|
|
|
Techno-Necromancer Group: Members Posts: 1,018 Joined: 13-January 05 From: The Net Member No.: 2,127 |
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. |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 30th August 2008 - 05:45 PM |