Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Resources
  • Code Requests
  • Completed Requests
  • [Completed] [zb]PHP BBcode request
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
[Completed] [zb]PHP BBcode request; It's not for ZB, have to choose one...
Tweet Topic Started: Nov 26 2009, 05:09 AM (844 Views)
PD.Phoenix Nov 26 2009, 05:09 AM Post #1
Member Avatar
Kokuhyou no Tentei

Posts:
326
Group:
Member
Member
#602
Joined:
Aug 15, 2008
Coding language
HTML/CSS
I've tried posting just asking for assitance but I've gotten no where... now I'd like to know if someone who knows PHP could help me.

http://zbcode.com/topic/2544299/1/#new

The link to my help thread. I'm trying to make a bbcode for vBulletin. One for a rotating signature.

bbcode for a text rotator might look something like this:

[rotator]{text}[/rotator]

You can make the bbcode tag delimited. So the tag in application could look like:

[rotator]siglink1 siglink2 siglink3 siglink4[/rotator]

Then you would only need to update your php code to take the {text} field, then use the explode(" ", {text}, limit) to populate the string array.

Of course it also follows that you can use a different delimiter for the text rotator. Perhaps it would make more sense to use explode(";", {text}, limit)

So the final tag, in application, would look like:

[rotator]
Join Division X today!
divisionBannerLink;
Claimed character battles going on now!
claimCharBattleLink
[/rotator]

The text between the tags would be passed to the php block of code, so you could then have:

$sig = explode (";", {text})

In theory, sig[0] would be:
Join Division X today!
divisionBannerLink

and sig[1] would be:
Claimed charater battles going on now!
claimCharBattleLink

I just don't know how to get it to working.. could someone PLEASE help me with this? :(
Edited by PD.Phoenix, Nov 26 2009, 05:10 AM.
Phoenix Designz is now open
Looking for staff and classers PM me here or on PD if interested.

Want to win some easy money? Enter Phoenix Designz tournaments. Learn more here ->> click


Posted Image
| My dA | Vote PD Top 100 |
Offline Profile Goto Top
 
Reid Nov 26 2009, 09:07 AM Post #2
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
A simple JS script could take care of this, could it not? Unless you're interested in generating real random numbers and not pseudorandom, but hey, who cares about all of that nonsense.

1. Loop through all of the posts
2. In each post, use the regexp /\[rotator\](.+?)\[\/rotator\]/gi to check for existence
3. Use a .replace on that regexp and use a callback function
4. In that callback function, generate a random number between 0 and the length of the array
5. Return what needs to go in its spot

For example, here's what I would do in ZB:
Code:
 
$('td.c_post:contains([rotator])').each(function() {
this.innerHTML = this.innerHTML.replace(/\[rotator\](.+?)\[\/rotator\]/gi, function(matched, inner) {
inner = inner.split(';');
var l = inner.length;
while (l--)
inner[l] = inner[l].split(',');
var ind = Math.floor(Math.random() * inner.length);
return "<img src='" + inner[ind][0] + "' alt='' /><br />" + inner[ind][1];
});
});
I went about it in a slightly different way than described. I let jQuery check if their post had the [rotator] tag already in it, then I used a .replace on the innerHTML of the <td> containing the post to replace all of the rotator tags. For each tag, it runs a callback function. In the callback function, the first argument is the entire matched text, the second argument is the first group - that is, the (.+?), notice the parentheses for capturing, which is also known as RegExp.$1; the third argument is the second group, the fourth argument is the third group, and so on into eternity.

The fancy part about callback functions is that the value you return will be the replacement you want. There isn't anything really fancy about callback functions that JS has coded into it, it simply evaluates the argument. If it's a function it passes along some arguments.

Anyways, I hope this helps. Since it's on vBulletin, I'd suspect that you need to find a different way of looping through the posts.

Note that in my code, the format of the code was [rotator]link,title;link,title[/rotator] (and more, if you want.)
The Resource Board
Offline Profile Goto Top
 
PD.Phoenix Nov 27 2009, 07:10 AM Post #3
Member Avatar
Kokuhyou no Tentei

Posts:
326
Group:
Member
Member
#602
Joined:
Aug 15, 2008
Coding language
HTML/CSS
Has to be PHP.

I need it written in PHP that will work on vBulletin. JavaScript is no good as it can be turned off. For ZB or IF, JavaScript is good. But not vBulletin
Phoenix Designz is now open
Looking for staff and classers PM me here or on PD if interested.

Want to win some easy money? Enter Phoenix Designz tournaments. Learn more here ->> click


Posted Image
| My dA | Vote PD Top 100 |
Offline Profile Goto Top
 
Gorgor Nov 27 2009, 07:15 AM Post #4
Hello

Posts:
1,187
Group:
Former Staff
Member
#2,728
Joined:
Apr 2, 2009
Coding language
PHP
Not sure if this will work, but you can try this:
Code:
 
$sig = explode(",",$sig);
$number = rand(1,sizeof($sig))-1;
$sig = $sig[$number];
I'm not really good with random numbers or loops in PHP, but that looks like it would work if you place it right before it echos out the signature. Not sure how that forum system's designed though.
Offline Profile Goto Top
 
PD.Phoenix Nov 27 2009, 08:41 PM Post #5
Member Avatar
Kokuhyou no Tentei

Posts:
326
Group:
Member
Member
#602
Joined:
Aug 15, 2008
Coding language
HTML/CSS
The problem is I don't know how to write this in a vBulletin BBcode format. So, sorry, but a tiny snippet of php isn't going to help me much.
Phoenix Designz is now open
Looking for staff and classers PM me here or on PD if interested.

Want to win some easy money? Enter Phoenix Designz tournaments. Learn more here ->> click


Posted Image
| My dA | Vote PD Top 100 |
Offline Profile Goto Top
 
Reid Nov 27 2009, 09:40 PM Post #6
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Saikou
Nov 27 2009, 08:41 PM
The problem is I don't know how to write this in a vBulletin BBcode format. So, sorry, but a tiny snippet of php isn't going to help me much.
Considering that this entire board is devoted to InvisionFree and ZetaBoards, I doubt you will find what you're looking for.

We don't know how vBulletin works. I'm sure there's a BBCode parser sitting around in the code somewhere, but I don't think anyone here has used vB before to an extent that they could write some PHP to use in the system.

Aren't vBulletin boards supposed to have a menu where admins add BBCode? I have been an admin on a vB board before, although I didn't have access to the mission-critical things such as the file source. That was years ago, though.
The Resource Board
Offline Profile Goto Top
 
PD.Phoenix Nov 27 2009, 10:02 PM Post #7
Member Avatar
Kokuhyou no Tentei

Posts:
326
Group:
Member
Member
#602
Joined:
Aug 15, 2008
Coding language
HTML/CSS
VB ACP allows BBcodes used with HTML replacement.

Either way it doesn't matter. Close this.
Phoenix Designz is now open
Looking for staff and classers PM me here or on PD if interested.

Want to win some easy money? Enter Phoenix Designz tournaments. Learn more here ->> click


Posted Image
| My dA | Vote PD Top 100 |
Offline Profile Goto Top
 
Choco Nov 27 2009, 11:20 PM Post #8
Member Avatar
¡ʎɹoʇɔɐɟ ʎʇıʌɐɹƃ ɐ uı pǝddɐɹʇ ɯ,ı 'dןǝɥ

Posts:
589
Group:
Admins
Member
#3,272
Joined:
Jun 30, 2009
Coding language
Everything
You're welcome.
See? We can read thoughts too. ;)

Your request has been completed, and we're moving it to the correct forum. We hope it works for you; if it doesn't, feel free to post another request topic in the requests forum. Just remember: read the rules first!

Thanks,
The ZBCode Staff
Posted ImageIt's a magical world, Hobbes, ol'd buddy... ...let's go exploring!
In progress: Something Special ;)
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Completed Requests · Next Topic »
Locked Topic

Track Topic · E-mail Topic Time: 2:26 PM Jul 11
Hosted for free by ZetaBoards · Privacy Policy