How to enable "Expand code" on 3.3.14 ?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Antonio Linares
Registered User
Posts: 17
Joined: Mon Feb 26, 2024 6:56 am

How to enable "Expand code" on 3.3.14 ?

Post by Antonio Linares »

We have properly ugraded from 3.0.4 to 3.3.14 and now in the code sections there is no a "Expand code" option

How to have it again ?

many thanks
User avatar
warmweer
Jr. Extension Validator
Posts: 12007
Joined: Fri Jul 04, 2003 6:34 am
Location: somewhere in the space-time continuum

Re: How to enable "Expand code" on 3.3.14 ?

Post by warmweer »

Antonio Linares wrote: Tue Jan 07, 2025 7:52 pm We have properly ugraded from 3.0.4 to 3.3.14 and now in the code sections there is no a "Expand code" option
What do you mean with "code sections"

Perhaps that was a 3.0 mod you used?
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53601
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: How to enable "Expand code" on 3.3.14 ?

Post by Brf »

warmweer wrote: Tue Jan 07, 2025 8:47 pm Perhaps that was a 3.0 mod you used?
The board linked in this post viewtopic.php?p=12348855#p12348855 has it. Maybe it is part of the style used.
User avatar
warmweer
Jr. Extension Validator
Posts: 12007
Joined: Fri Jul 04, 2003 6:34 am
Location: somewhere in the space-time continuum

Re: How to enable "Expand code" on 3.3.14 ?

Post by warmweer »

Brf wrote: Tue Jan 07, 2025 9:17 pm
warmweer wrote: Tue Jan 07, 2025 8:47 pm Perhaps that was a 3.0 mod you used?
The board linked in this post viewtopic.php?p=12348855#p12348855 has it. Maybe it is part of the style used.
Just had a look: prosilver style version = 3.0.14

Added:
I think that there was a code folding BBcode present in the (3.2)(3.3)(BETA) Rin Editor for phpBB (WYSIWYG Editor) (Powerd by CKEditor) extension.
It's been abandoned though as it had a multitude of issues.
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53601
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: How to enable "Expand code" on 3.3.14 ?

Post by Brf »

warmweer wrote: Tue Jan 07, 2025 9:29 pm Just had a look: prosilver style version = 3.0.14
Hmm? It's stylesheet says it is "Rin" style with the functions from subsilver2.
You do not have the required permissions to view the files attached to this post.
User avatar
warmweer
Jr. Extension Validator
Posts: 12007
Joined: Fri Jul 04, 2003 6:34 am
Location: somewhere in the space-time continuum

Re: How to enable "Expand code" on 3.3.14 ?

Post by warmweer »

Brf wrote: Wed Jan 08, 2025 1:10 pm Hmm? It's stylesheet says it is "Rin" style with the functions from subsilver2.
I know: but rinDark has no phpbb version mentioned so I checked prosilver

Code: Select all

General Information about this style
name = rinDark
copyright = by RessourectoR for cs.rin.ru
version = 1.1

Code: Select all

# General Information about this style
name = subsilver2
copyright = © 2005 phpBB Group
version = 3.0.14
I think it's safe to assume the board version = 3.0.14

Extra: I just assumed that cs.rin.ru is the OP's board. But that may not be the case as the OP mentioned having upgraded to 3.3.14
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53601
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: How to enable "Expand code" on 3.3.14 ?

Post by Brf »

No. That board is not the op's board, just one I found that had the expand-code button. I am assuming it is part of the style, rather than a mod.
User avatar
warmweer
Jr. Extension Validator
Posts: 12007
Joined: Fri Jul 04, 2003 6:34 am
Location: somewhere in the space-time continuum

Re: How to enable "Expand code" on 3.3.14 ?

Post by warmweer »

I had a feeling I had seen code or an extension for phpBB allowing collapsing/expanding code somewhere so I looked through my archive of saved code tidbits and extensions .
and found: phpBB Collapse Quote v1.3.2 (see https://github.com/IMC-GER/phpBB-Collap ... e/releases)

It's quote, not code collapsing but could be an alternative or a starting point for a specific code collapse extension.

and also came across Scroll Quoted Text which could be another alternative.

These extensions are not all that recent so make sure you have a database backup before installing them so that you can restore your board should mayhem occur ;)
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 4002
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Re: How to enable "Expand code" on 3.3.14 ?

Post by Kailey »

Note: Moved to phpBB Custom Coding

OK, it's not that hard. Both of these files are in the /styles/prosilver/template/ directory.

OPEN: overall_footer.html

FIND:

Code: Select all

<!-- IF S_PLUPLOAD --><!-- INCLUDE plupload.html --><!-- ENDIF -->
BEFORE, ADD:

Code: Select all

<script type="text/javascript">
function expandcollapse(a) {
	var ee = a.parentNode.parentNode.getElementsByTagName('code')[0];

	if (ee.style.maxHeight == '200px') {
		ee.style.maxHeight = '2000px';
		a.innerHTML = 'collapse';
	}
	else {
		ee.style.maxHeight = '200px';
		a.innerHTML = 'expand';
	};
}
</script>
OPEN: bbcode.html

FIND:

Code: Select all

<!-- BEGIN code_open --><div class="codebox"><p>{L_CODE}{L_COLON} <a href="#" onclick="selectCode(this); return false;">{L_SELECT_ALL_CODE}</a></p><pre><code><!-- END code_open -->
REPLACE WITH:

Code: Select all

<!-- BEGIN code_open --><div class="codebox"><p>{L_CODE}{L_COLON} <a href="#" onclick="selectCode(this); return false;">{L_SELECT_ALL_CODE}</a> | <a href="#" onclick="expandcollapse(this); return false;">Expand</a></p><pre><code><!-- END code_open -->
You could get more fancy and replace the hard-coded language with language vars, config vars for the maxHeight var, etc.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders
Antonio Linares
Registered User
Posts: 17
Joined: Mon Feb 26, 2024 6:56 am

Re: How to enable "Expand code" on 3.3.14 ?

Post by Antonio Linares »

Thank you!

Why was it removed ? :roll:
Antonio Linares
Registered User
Posts: 17
Joined: Mon Feb 26, 2024 6:56 am

Re: How to enable "Expand code" on 3.3.14 ?

Post by Antonio Linares »

There is a bug in your proposed code. It forces double click on expand for the first time and also it does not behaves as old phpbb 3.0.4 code.

This is the right fix:

Code: Select all

<script type="text/javascript">
	function expandcollapse(a) {
		var ee = a.parentNode.parentNode.getElementsByTagName('code')[0];

		if (ee.style.maxHeight != 'none') {
			ee.style.maxHeight = 'none';
			a.innerHTML = 'collapse';
		}
		else {
			ee.style.maxHeight = '200px';
			a.innerHTML = 'expand';
		}; 
	}
</script>
Working fine now. Original code in phpbb 3.0.4 was:

Code: Select all

function expandCode( aTag )
  {
  	 var code = aTag.parentNode.nextSibling.childNodes[0];
  	 
  	 if( code.style.maxHeight != "none" )
  	 {
	      aTag.innerHTML = "Collapse view";
  	    code.style.maxHeight = "none";
  	 }   
  	 else   
  	 {	
	      aTag.innerHTML = "Expand view";
  	    code.style.maxHeight = "200px";
  	 }   
	}
Antonio Linares
Registered User
Posts: 17
Joined: Mon Feb 26, 2024 6:56 am

Re: How to enable "Expand code" on 3.3.14 ?

Post by Antonio Linares »

BTW, we used to have syntax coloring in the posted code sections. I guess we used an extension for that but I can't remember which one it was.

Is there a similar extension for phpbb 3.3.14 ?

How can I look for it in our old forums ?

many thanks!
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6533
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Re: How to enable "Expand code" on 3.3.14 ?

Post by thecoalman »

That wasn't an extension, it was part of core features. That's actually a built in php function but it produces a massive amount of HTML. I would presume it was canned with new text formatting used for DB storage introduced with 3.2.

There is extension here:

https://github.com/s9e/phpbb-ext-highlighter

Appears the only thing it does is load is highlight.js which you can easily do with a template edit.

https://highlightjs.org/

Between the head tags in overall_header.html (HTML is from highlight.js example):

Code: Select all

<!-- IF S_VIEWTOPIC -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>

<!-- and it's easy to individually load additional languages -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/go.min.js"></script>

<script>hljs.highlightAll();</script>
<!-- ENDIF -->
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 4002
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Re: How to enable "Expand code" on 3.3.14 ?

Post by Kailey »

Antonio Linares wrote: Thu Jan 09, 2025 8:40 am Why was it removed ? :roll:
It was never part of the phpBB core package. I can only assume you had a MOD installed that provided this functionality.
Antonio Linares wrote: Thu Jan 09, 2025 9:11 am There is a bug in your proposed code. It forces double click on expand for the first time and also it does not behaves as old phpbb 3.0.4 code.
It worked fine on my test forum. Glad you were able to get it working though.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders
Antonio Linares
Registered User
Posts: 17
Joined: Mon Feb 26, 2024 6:56 am

Re: How to enable "Expand code" on 3.3.14 ?

Post by Antonio Linares »

thecoalman wrote: Thu Jan 09, 2025 10:04 am That wasn't an extension, it was part of core features. That's actually a built in php function but it produces a massive amount of HTML. I would presume it was canned with new text formatting used for DB storage introduced with 3.2.

There is extension here:

https://github.com/s9e/phpbb-ext-highlighter

Appears the only thing it does is load is highlight.js which you can easily do with a template edit.

https://highlightjs.org/

Between the head tags in overall_header.html (HTML is from highlight.js example):

Code: Select all

<!-- IF S_VIEWTOPIC -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>

<!-- and it's easy to individually load additional languages -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/go.min.js"></script>

<script>hljs.highlightAll();</script>
<!-- ENDIF -->
Working great, thank you so much!

Return to “phpBB Custom Coding”