Extensions and phpBB 3.2: you should probably read this topic

Discussion forum for Extension Writers regarding Extension Development.
rxu
Extensions Development Team
Posts: 2956
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by rxu » Sun Nov 06, 2016 5:09 am

OK, thanks for the explanation.

martec
Registered User
Posts: 209
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec » Sat Jun 17, 2017 11:37 am

i am developer of this extension viewtopic.php?f=456&t=2427126 and i need know more about refractor.

Code: Select all

[quote]test[/quote]

test
code above, one '\n' after quote tag will result without any br tag after blockquote tag. (check image below)
Image

need two '\n' after quote tag to create one br like code below

Code: Select all

[quote]test[/quote]


test
finally one br tag. (check image below)
Image

Is this really normal behavior? Or intentional? Or is it bug?
For me, the correct behavior is a '\ n' will result in a br tag.

User avatar
JoshyPHP
Code Contributor
Posts: 1012
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP » Sat Jun 17, 2017 12:14 pm

It's intentional. Up to 1 blank line (= 2 line feeds) is ignored after BBCodes that are rendered as block elements.

If you CKEditor doesn't have a similar option, you may want to hide the superfluous <br> in CSS with something like that:

Code: Select all

.ClassNameOfTheEditableElement blockquote+br
{
	display: none;
}
I wrote the thing that does BBCodes in 3.2.

martec
Registered User
Posts: 209
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec » Sat Jun 17, 2017 1:57 pm

JoshyPHP wrote:
Sat Jun 17, 2017 12:14 pm
It's intentional. Up to 1 blank line (= 2 line feeds) is ignored after BBCodes that are rendered as block elements.

If you CKEditor doesn't have a similar option, you may want to hide the superfluous <br> in CSS with something like that:

Code: Select all

.ClassNameOfTheEditableElement blockquote+br
{
	display: none;
}
thanks for reply. custom bbcode Is treated as an block elements? like align bbcode.

User avatar
JoshyPHP
Code Contributor
Posts: 1012
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP » Sat Jun 17, 2017 2:04 pm

Anything that is rendered as a block-level element: quotes, code blocks, lists, etc... It doesn't matter whether they are custom or by default, they are all treated the same.
I wrote the thing that does BBCodes in 3.2.

martec
Registered User
Posts: 209
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec » Sat Jun 17, 2017 2:38 pm

thanks the explanation. i will try what i can to do here.

doougl4s
Registered User
Posts: 4
Joined: Fri Feb 12, 2016 8:27 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by doougl4s » Thu Jun 29, 2017 2:34 am

Many of my bbcodes have stopped working, can you tell me how to fix this?

Code: Select all

[col]{TEXT1}|{TEXT2}[/col]

<table width="100%">
	<tr>
		<td style="vertical-align: top; width:50%; padding-right:10px;">{TEXT1}</td>
		<td style="vertical-align: top; width:50%; padding-left:10px;">{TEXT2}</td>
	</tr>
</table>

Code: Select all

[tabela]{TEXT}[/tabela]

<script language="Javascript">
var texto = '{TEXT}';
texto = texto.replace("\r\n","");
texto = texto.replace("<br>","");
texto = texto.replace(" ","");
var linha = new Array();
linha = texto.split('L=');
var table = '<div align="center"><TABLE width=70% cellpadding=1 cellspacing=1 border=0>';
for (var i=1; i<linha.length; i++)
{
  table = table + '<TR>';
  var coluna = new Array();
  coluna = linha[i].split('&');
  for (var j=0; j<coluna.length; j++)
  {
    if (i == 1)
    {
      table = table + '<TD align=center style="background: #FF8904; font-size:11px; color:black; font-family:  Verdana,Arial, Helvetica, sans-serif;"><b>' + coluna[j].replace("amp;","") + '</b></TD>';      
    }
    else
    {
      table = table + '<TD style="background: #878282; font-size:11px; color:white; font-family:  Verdana,Arial, Helvetica, sans-serif;">' + coluna[j].replace("amp;","") + '</TD>';      
    }

  }
  table = table + '<TR>';
}
table = table + '</TABLE></div>';
document.write(table);
</script>

Code: Select all

[thumbnail={NUMBER}]{URL}[/thumbnail]

<a target="_blank" href="{URL}"><img src="{URL}" width="{NUMBER}px" heigth="{NUMBER}px"></a>

User avatar
JoshyPHP
Code Contributor
Posts: 1012
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP » Thu Jun 29, 2017 2:51 am

This topic is for extension authors, not for general support. Please use the general support forums for that.

Off the top of my head, the first BBCode will work differently in 3.2 because of the multiple tokens in the BBCode's content. If you use more than one token in the BBCode's content, the content will be treated as plain text. The second BBCode I don't know about. Using JavaScript seems like a bad idea. Some browsers have deprecated/removed support for document.write too. The last one I don't know either. My guess is it works.
I wrote the thing that does BBCodes in 3.2.

martec
Registered User
Posts: 209
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec » Thu Jul 13, 2017 10:43 am

@JoshyPHP

Why need three '\n' after block element to create one br if next tag too is block element?

Need two '\n' after block element to create one br if next tag is inline element. This ok, but why three '\n' between blocks elements to one br?
This too intentional?

User avatar
JoshyPHP
Code Contributor
Posts: 1012
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP » Thu Jul 13, 2017 1:18 pm

Up to two newlines are ignored after block elements so that you can use the following markup without extra <br> elements appearing in the output:

Code: Select all

[quote=martec post_id=14779661 time=1499942629 user_id=1100965]
Why need three '\n' after block element to create one br if next tag too is block element?
[/quote]

Reply goes here, no br.
Without extra <br> elements, users can leave a blank space between markup for readability without adding superfluous whitespace in the output and style authors margins can better control margins in CSS without having to account for extra <br>s.

Note that you can toggle that behaviour in custom BBCodes in their definition:

Code: Select all

[foo #ignoreSurroundingWhitespace=false]{TEXT}[/foo]
I wrote the thing that does BBCodes in 3.2.

martec
Registered User
Posts: 209
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec » Thu Jul 13, 2017 2:05 pm

@JoshyPHP

That was not quite what I meant.

Code: Select all

[quote]test[/quote]



[quote]test[/quote]
Code above block element (first quote tag) and next element (secound quote tag) also block element. To create one br need three '\n'. Why? Intentional?

If something below

Code: Select all

[quote]test[/quote]


test
Code above block element and next element is inline element. Here need only two '\n' to create one br. Why this difference?

User avatar
JoshyPHP
Code Contributor
Posts: 1012
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP » Thu Jul 13, 2017 2:15 pm

Up to two newlines are ignored before and after block elements. They might add up depending on the context, which is why you need three of them when there are two consecutive blocks.
I wrote the thing that does BBCodes in 3.2.

martec
Registered User
Posts: 209
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec » Thu Jul 13, 2017 9:59 pm

@JoshyPHP

Hi, Is there an event in phpBB where I can change the number of lines that will be ignored before and after blocks elements?

User avatar
JoshyPHP
Code Contributor
Posts: 1012
Joined: Mon Jul 11, 2011 12:28 am

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by JoshyPHP » Thu Jul 13, 2017 10:07 pm

Not the number, no.
I wrote the thing that does BBCodes in 3.2.

martec
Registered User
Posts: 209
Joined: Sat Sep 19, 2009 2:15 pm

Re: Extensions and phpBB 3.2: you should probably read this topic

Post by martec » Thu Jul 13, 2017 10:13 pm

So you have your parser for javascript?

Post Reply

Return to “Extension Writers Discussion”