BBcodes: all you wanted ask, but...

Discuss features as they are added to the new version. Give us your feedback. Don't post bug reports, feature requests, support questions or suggestions here.
Forum rules
Discuss features as they are added to the new version. Give us your feedback. Don't post bug reports, feature requests, support questions or suggestions here. Feature requests are closed.
User avatar
jumborex
Registered User
Posts: 84
Joined: Wed Nov 08, 2006 12:33 pm
Location: Milano
Contact:

BBcodes: all you wanted ask, but...

Post by jumborex »

I've been really impressed by this simple (apparently) demonstration of Customized BBCodes:
viewtopic.php?p=165135#p165135

But (I admit) cannot understand well what is to do for working with it.
I see the short description in the relate page of ACP --> Posting --> BBCodes
phpBB3 wrote: Tokens are placeholders for user input. The input will be validated only if it matches the corresponding definition. If needed, you can number them by adding a number as the last character between the braces, e.g. {USERNAME1}, {USERNAME2}.

In addition to these tokens you can use any of lang string present in your language/ directory like this: {L_<stringname>} where <stringname> is the name of the translated string you want to add. For example, {L_WROTE} will be displayed as "wrote" or its translation according to user’s locale]

Perhaps because I'm not English speaking, this is not clear enogh for me.
Question is: May I use any word as a Token, or a Token should be a system defined word?

I hope to be more clear with an example.
Imagine I would try to make a BBCode installing images with the word running around it. This means, I think, an HTML as per:

Code: Select all

<div align="left"><p><img src="/whatyouwant/gear.png" alt="" align="left">Try this text!</p></div>
I need al least a couple of tokens (if I understood well the method):
  • An alignment definition
  • The image path
Apparently my BBCode should be defines as here:

Code: Select all

[imagealign={ALIGN}]{PATH}[/imagealign]
Well, this if it is possible define the Custom BBCode in this way:

Code: Select all

<div align="{ALIGN}"><img src="{PATH}" alt="" align="{ALIGN}"></div>
But this, apparently does not work: somebody can suggest to me why? :?
Thanks.
I have not failed. I've just found 10,000 ways that won't work.
(Thomas Alva Edison)
User avatar
Highway of Life
Registered User
Posts: 1399
Joined: Tue Feb 08, 2005 10:18 pm
Location: I'd love to change the World, but they won't give me the Source Code
Contact:

Re: BBcodes: all you wanted ask, but...

Post by Highway of Life »

For that example, you would use:

Code: Select all

[align={TEXT1}]{TEXT2}[/align]
for the HTML replacement, you have several options:

Code: Select all

<div align="{TEXT1}">{TEXT2}</div>
The problem with this code is it's not XHTML Strict compliant, but it will work for Transitional.

Code: Select all

<div style="float:{TEXT1}">{TEXT2}</div>
but you can't use "center" for this one.

Code: Select all

<div style="text-align:{TEXT1}">{TEXT2}</div>
You can also use:

Code: Select all

[left]{TEXT}[/left]

Code: Select all

<div style="text-align:left;">{TEXT}</div>

Code: Select all

[center]{TEXT}[/center]

Code: Select all

<div style="text-align:center;">{TEXT}</div>

Code: Select all

[right]{TEXT}[/right]

Code: Select all

<div style="text-align:right;">{TEXT}</div>
The implementation would be:

Code: Select all

[align=left][img]http://website.tld/path/to/image.jpg[/img][/align]
or

Code: Select all

[left][img]http://website.tld/path/to/image.jpg[/img][/left]
As for those other tokens, such as {USERNAME} I have no idea what they would be used for... I have not really tried to use them. :oops:
Image
Kokuei
Registered User
Posts: 64
Joined: Sun Nov 26, 2006 6:19 pm
Location: On the other end of the cable.
Contact:

Re: BBcodes: all you wanted ask, but...

Post by Kokuei »

First of all, I hope you are using the beta5 of phpBB3. Beta 4 had a bug in it that made some or all BBCodes unable to take paramaters.

Second, i think you learn best by example. Here is a list of custom BBCodes from the beta support forum.
http://www.phpbb.com/phpBB/viewtopic.php?t=405994


Edit: What Highway is talking about (XHTML strict) is located on page 12-13 i think.
User avatar
jumborex
Registered User
Posts: 84
Joined: Wed Nov 08, 2006 12:33 pm
Location: Milano
Contact:

Re: BBcodes: all you wanted ask, but...

Post by jumborex »

Highway of Life wrote: For that example, you would use:
[...]
As for those other tokens, such as {USERNAME} I have no idea what they would be used for... I have not really tried to use them. :oops:

Thanks Highway. Really! :P This was exactly what I was looking for: some exchange of experiences. So thanks a lot also to Kokuei, for indicating the page and to patrikstar for producing that page.
Kokuei wrote: [...]i think you learn best by example. Here is a list of custom BBCodes from the beta support forum.
http://www.phpbb.com/phpBB/viewtopic.php?t=405994
[...]

Now, for making another step in the problem, the effect I was looking for was the following:
jumborex wrote: [...]
Imagine I would try to make a BBCode installing an image with the words running around it. [...].

This means an effect like this:This is a trouble I cannot solve at the moment! :(
I have not failed. I've just found 10,000 ways that won't work.
(Thomas Alva Edison)
code reader
Registered User
Posts: 653
Joined: Wed Sep 21, 2005 3:01 pm

Re: BBcodes: all you wanted ask, but...

Post by code reader »

jumborex wrote: Perhaps because I'm not English speaking, this is not clear enogh for me.
Question is: May I use any word as a Token, or a Token should be a system defined word?
i am afraid you are wrong.
as clearly stated here: http://www.phpbb.com/bugs/viewreport.php?b=5660 , the explanation is as clear as humanly possible.



(hint: only the tokens listed below this message, optionally appended by numbers, are considered to be tokens)
Kokuei
Registered User
Posts: 64
Joined: Sun Nov 26, 2006 6:19 pm
Location: On the other end of the cable.
Contact:

Re: BBcodes: all you wanted ask, but...

Post by Kokuei »

On page 12 of my link you can find this:

Code: Select all

[wrap={TEXT1}]{TEXT2}[/wrap]

<div  style="float: {TEXT1}; padding-left: 10px; padding-right: 10px; padding-top: 2px; padding-bottom: 2px;">{TEXT2}</div> 
It's a custom BBCode I created to wrap text around images (it might work on other objects too), use either left or right as TEXT1 when used to align the image to the side you wish.
User avatar
Highway of Life
Registered User
Posts: 1399
Joined: Tue Feb 08, 2005 10:18 pm
Location: I'd love to change the World, but they won't give me the Source Code
Contact:

Re: BBcodes: all you wanted ask, but...

Post by Highway of Life »

jumborex wrote: This means an effect like this:This is a trouble I cannot solve at the moment! :(

The way to do that is to use the align BBCode, but put the image BEFORE the paragraph.

Example:

Code: Select all

[align=right][img]http://website.tld/path/to/image.jpg[/img][/align] Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi. Nulla libero. Vivamus pharetra posuere sapien. Nam consectetuer. Sed aliquam, nunc eget euismod ullamcorper, lectus nunc ullamcorper orci, fermentum bibendum enim nibh eget ipsum. Donec porttitor ligula eu dolor. Maecenas vitae nulla consequat libero cursus venenatis. Nam magna enim, accumsan eu, blandit sed, blandit a, eros.
This will achieve your desired outcome.
We've actually implemented this sort of thing on STG with a thumbnail and a lightbox... it's quite fancy.
Image
Kokuei
Registered User
Posts: 64
Joined: Sun Nov 26, 2006 6:19 pm
Location: On the other end of the cable.
Contact:

Re: BBcodes: all you wanted ask, but...

Post by Kokuei »

Sorry Highway, but you a wrong. ;)

This code do nothing to achive the "wrap", "float" or "around" effect asked for (not even on your own site).
User avatar
Highway of Life
Registered User
Posts: 1399
Joined: Tue Feb 08, 2005 10:18 pm
Location: I'd love to change the World, but they won't give me the Source Code
Contact:

Re: BBcodes: all you wanted ask, but...

Post by Highway of Life »

As long as you use float as your "align" then it will work. ;) (as you demonstrated in your example)
div align, or div style text-align won't do it.

But putting the image after the paragraph (for example) won't achieve the desired effect, that is why my demonstration shows the image appearing before the paragraph.
Image
User avatar
jumborex
Registered User
Posts: 84
Joined: Wed Nov 08, 2006 12:33 pm
Location: Milano
Contact:

Re: BBcodes: all you wanted ask, but...

Post by jumborex »

Highway of Life wrote: As long as you use float as your "align" then it will work. ;) [...]

Really! :lol: using the suggested couple of instructions:

Code: Select all

[align={TEXT1}]{TEXT2}[/align]

<div style="float:{TEXT1}">{TEXT2}</div>
it worked fine:
I have not failed. I've just found 10,000 ways that won't work.
(Thomas Alva Edison)
Post Reply