coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: escoces on February 23, 2007, 12:16:53 AM

Title: Add Custom BBCode?!
Post by: escoces on February 23, 2007, 12:16:53 AM
Hi.. I'm new with coppermine but I was needing to add a custom BBCode.

For example, I am using it on my personal website where on some photos, I link it to a stockphoto website. So, instead of typing the whole thing, I'd like to do "[stock1]12345678[/stock1]" and it would appear "Buy this image from Stock1", with the link "www.stocksite.com/12345678.php"..

Something like this..

Is that possible (please say yes)??

Thanks in advance for your help, and I hope I posted this in the right section! :)
Title: Re: Add Custom BBCode?!
Post by: Nibbler on February 23, 2007, 02:09:09 AM
Yes.

Bump this thread tomorrow night if nobody else answers you before then.
Title: Re: Add Custom BBCode?!
Post by: escoces on February 23, 2007, 02:59:13 AM
Thanks...

I'm glad to hear (or read) it's possible. I'll check back tomorrow! :)

Thanks
Title: Re: Add Custom BBCode?!
Post by: escoces on February 23, 2007, 08:47:36 PM
*bump*

Anyone? Please!!!
Title: Re: Add Custom BBCode?!
Post by: Nibbler on February 23, 2007, 10:03:22 PM
include/functions.inc.php

function bb_decode()

find


                $patterns[6] = "#\[img\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/img\]#si";
                $replacements[6] = $bbcode_tpl['img'];


after that, add a new block


                $patterns[7] = "#\[stock1\](\d+)\[/stock1\]#si";
                $replacements[7] = '<span class="bblink"><a href="http://www.stocksite.com/$1.php" rel="external">Buy this image from Stock1</a></span>';

Title: Re: Add Custom BBCode?!
Post by: escoces on February 24, 2007, 01:31:12 AM
Thanks Nibbler..

Almost there.. it worked for 4 out of the 5 websites.

I'm getting some trouble in this one:

//[dt]dreamstime[/dt]
$patterns[11] = "#\[dt\](\d+)\[/dt\]#si";
                $replacements[11] = '<span class="bblink"><b><a href="http://www.dreamstime.com/$1-resi277789" rel="external" target="_blank">Buy this image from Dreamstime</a></b></span>';

(thats the code I used)...

On all other sites, the "$1" was just a number sequence. For this site, it's different. I took a example photo (http://www.dreamstime.com/computerizedapple-image1937604).

On the page, it tells me the File ID, but when I tried it ([dt]1937604[/dt]) I got a "page not found" message. When I try the whole thing (computerizedapple-image1937604), the link doesnt work.
On the page I get "[dt]computerizedapple-image1937604[/dt]" typed out.

PS: The "-resi277789" is a referal link and is supposed to be there, I checked.

I dont know if it's because of the hifen or what, can anyone help me out with this?
Title: Re: Add Custom BBCode?!
Post by: Nibbler on February 24, 2007, 01:45:47 AM
OK, you'll need to adjust it to accept things other than numbers, eg.

$patterns[11] = "#\[dt\]([a-z0-9-])\[/dt\]#si";
Title: Re: Add Custom BBCode?!
Post by: escoces on February 24, 2007, 07:17:41 PM
Quote from: Nibbler on February 24, 2007, 01:45:47 AM
OK, you'll need to adjust it to accept things other than numbers, eg.

$patterns[11] = "#\[dt\]([a-z0-9-])\[/dt\]#si";

Ok... tried that and still happens the same thing.. Might not be the hifen then..

See, this should be the final link:

http://www.dreamstime.com/computerizedapple-image1937604-resi277789 (just an example image, it's not even mine)

And is now set as:
//[dt]dreamstime[/dt]
$patterns[11] = "#\[dt\]([a-z0-9-])\[/dt\]#si";
                $replacements[11] = '<span class="bblink"><b><a href="http://www.dreamstime.com/$1-resi277789" rel="external" target="_blank">Buy this image from Dreamstime</a></b></span>';


And on the gallery I typed:

[dt]computerizedapple-image1937604[/dt]

What am I doing wrong???  :-\
Title: Re: Add Custom BBCode?!
Post by: escoces on February 26, 2007, 07:04:25 PM
Please... someone has got to know the answer!  :-[
Title: Re: Add Custom BBCode?!
Post by: Nibbler on February 26, 2007, 07:11:19 PM
Typo.

patterns[11] = "#\[dt\]([a-z0-9-])\[/dt\]#si";

should be

patterns[11] = "#\[dt\]([a-z0-9-]+)\[/dt\]#si";

The plus was missing.
Title: Re: Add Custom BBCode?!
Post by: escoces on February 27, 2007, 03:03:11 PM
Thanks Nibbler...

Worked fine just now! :)

I'll be adding 3 more websites soon so if I have any doubts, I'll just *bump* this same topic with the problem..

If not, thanks again! You are an angel!  :D
Title: Re: Add Custom BBCode?!
Post by: QT on May 11, 2007, 06:03:40 PM
Hi!
Tell me please, how add the [size ] [/size] BBcode?

Thanks)
Title: Re: Add Custom BBCode?!
Post by: QT on May 11, 2007, 06:27:16 PM
[update] and [align ]  [/align] too!
Title: Re: Add Custom BBCode?!
Post by: Nibbler on May 11, 2007, 07:49:33 PM
Don't hijack solved threads.