UCP menu logic issue.

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
User avatar
Gumboots
Registered User
Posts: 800
Joined: Fri Oct 11, 2019 1:59 am

UCP menu logic issue.

Post by Gumboots »

I'm in the process of revamping the default MCP and UCP menus (ie: #tabs and #navigation) into a more cohesive whole. IMO a simple sidebar is cleaner and more versatile than the default setup: easier to find things at a glance, and can easily be turned into a flyout/overlay/accordion/whatever on smaller screens.

So, this is no issue for the MCP. I already have that working. Code is this:

Code: Select all

		<div id="cp-menu" class="cp-menu">
			<div id="navigation" class="navigation" role="navigation">
				<ul>
				<!-- BEGIN l_block1 -->
					<li<!-- IF l_block1.S_SELECTED -->  class="activetab"<!-- ENDIF -->>
						<a href="{l_block1.U_TITLE}" class="button">
							{l_block1.L_TITLE}
						</a>
						<ul>
							<!-- BEGIN l_block2 -->
							<li<!-- IF l_block1.l_block2.S_SELECTED --> id="active-subsection" class="active-subsection"<!-- ENDIF -->>
								<a href="{l_block1.l_block2.U_TITLE}">
									<span>{l_block1.l_block2.L_TITLE}<!-- IF l_block1.l_block2.ADD_ITEM --> ({l_block1.l_block2.ADD_ITEM})<!-- ENDIF --></span>
								</a>
							</li>
							<!-- END l_block2 -->
						</ul>
					</li>
				<!-- END l_block1 -->
				</ul>
			</div>
		</div>

And it looks like this:
Menu_MCP_working.jpg

The UCP menu is not being so co-operative, and I have not been able to figure out why. Code is this (taking the simplest case of not S_PRIVMSGS):

Code: Select all

		<div id="cp-menu" class="cp-menu">
			<div id="navigation" class="navigation" role="navigation">
				<ul id="t_block1">
					<!-- BEGIN t_block1 -->
					<li<!-- IF t_block1.S_SELECTED --> class="activetab"<!-- ENDIF -->>
						<a href="{t_block1.U_TITLE}" class="button">
							{t_block1.L_TITLE}
						</a>
				<!-- IF S_PRIVMSGS -->
				<!-- ENDIF -->
						<ul class="t_block2">
					<!-- BEGIN t_block2 -->
						<!-- IF (S_PRIVMSGS and t_block2.S_LAST_ROW) or not S_PRIVMSGS -->
							<!-- IF t_block2.S_SELECTED -->
							<li id="active-subsection" class="active-subsection">
								<a href="{t_block2.U_TITLE}">
									{t_block2.L_TITLE}
								</a>
							</li>
							<!-- ELSE -->
							<li>
								<a href="{t_block2.U_TITLE}">
									{t_block2.L_TITLE}
								</a>
							</li>
							<!-- ENDIF -->
						<!-- ENDIF -->
					<!-- END t_block2 -->
						</ul>

					</li>
					<!-- END t_block1 -->
				</ul>
			</div>

The result looks like this:
Menu_UCP_borked.jpg

Essentially what is happening is that anything within <!-- BEGIN t_block2 --> <!-- END t_block2 --> is not being echoed to the browser (this also applies within the PM sections). Do note that the logic there is exactly the same as default. I have changed the indentation to make things clearer, but nothing else. It's all default code.

This currently has me stumped, because the whole kaboodle is set up the same way as the revamped MCP menu, which works perfectly. <!-- BEGIN l_block2 --> <!-- END l_block2 --> causes no issues for the MCP menu, but for some reason <!-- BEGIN t_block2 --> <!-- END t_block2 --> is not working in the UCP menu.

Any ideas?
You do not have the required permissions to view the files attached to this post.
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦
User avatar
Gumboots
Registered User
Posts: 800
Joined: Fri Oct 11, 2019 1:59 am

Re: UCP menu logic issue.

Post by Gumboots »

Ok let's start with a simpler question.

In template/context.php the variables 'S_FIRST_ROW', 'S_LAST_ROW', 'S_BLOCK_NAME', 'S_NUM_ROWS', 'S_ROW_COUNT', 'S_ROW_NUM' are defined.

In ucp_header.html S_FIRST_ROW and S_LAST_ROW are used like this.

Code: Select all

<!-- IF S_PRIVMSGS and not t_block2.S_LAST_ROW -->

<!-- IF (S_PRIVMSGS and t_block2.S_LAST_ROW) or not S_PRIVMSGS -->
And there is also this:

Code: Select all

<!-- IF folder.UNREAD_MESSAGES > 0 -->
That all implies that S_ROW_COUNT and S_ROW_NUM should be able to be used like this (test case only):

Code: Select all

<!-- IF (t_block1.S_ROW_COUNT = 4) --> style="background:red;"<!-- ENDIF -->
But that causes a white page (no body tag content). Does anyone know why?
Also, does anyone know if or how S_ROW_COUNT and/or S_ROW_NUM being equal to a defined integer could be used in a template?

ETA: Where is S_BLOCK_NAME recorded?
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6313
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Re: UCP menu logic issue.

Post by thecoalman »

Gumboots wrote: Tue Sep 17, 2024 5:38 am ETA: Where is S_BLOCK_NAME recorded?
I'd assume any good editor has this feature but in Notepad++ click the find icon, switch to the find in files tab. Point it at you phpbb directory and make sure "in all sub folders" is selected.

I didn't look to see what the issue might be but I know for the attachments placeholder It's already HTML and can't be manipulated in the template. The attachments template is called in the script and set as template variable. The template file is not included by another template like most other template files. You can't use the common template variables in attachment.html and the variables used in attachment.html can't be used in other templates.

This might be the same or similar issue.
“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
Gumboots
Registered User
Posts: 800
Joined: Fri Oct 11, 2019 1:59 am

Re: UCP menu logic issue.

Post by Gumboots »

thecoalman wrote: Tue Sep 17, 2024 6:06 am I'd assume any good editor has this feature but in Notepad++ click the find icon, switch to the find in files tab. Point it at you phpbb directory and make sure "in all sub folders" is selected.
Lol. Mate, a full recursive search is the first thing I tried. No joy. That's why I'm asking.

I didn't look to see what the issue might be but I know for the attachments placeholder It's already HTML and can't be manipulated in the template. The attachments template is called in the script and set as template variable. The template file is not included by another template like most other template files. You can't use the common template variables in attachment.html and the variables used in attachment.html can't be used in other templates.

This might be the same or similar issue.
Ok, might be that. Will see if anyone else chimes in.
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6313
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Re: UCP menu logic issue.

Post by thecoalman »

Gumboots wrote: Tue Sep 17, 2024 6:47 am Lol. Mate, a full recursive search is the first thing I tried. No joy. That's why I'm asking.
Try just the name without the t_, or whatever it is prefixed with.

.
“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
Gumboots
Registered User
Posts: 800
Joined: Fri Oct 11, 2019 1:59 am

Re: UCP menu logic issue.

Post by Gumboots »

Searching for BLOCK_NAME returns the same results as for S_BLOCK_NAME. Leaving the S_ prefix off makes no difference.

I did manage to find definitions for l_block1 and t_block2 in functions_module.php, but the comments don't make sense.

Code: Select all

		$current_depth = 0;
		$linear_offset 	= 'l_block1';
		$tabular_offset = 't_block2';

		// Generate the list of modules, we'll do this in two ways ...
		// 1) In a linear fashion
		// 2) In a combined tabbed + linear fashion ... tabs for the categories
In the case of the MCP menu, both sets of blocks are prefixed l_ (for linear). Even the tabs. And, in the case of the UCP menu, both sets of blocks are prefixed t_, even the linear ones. :D So ok, whatever. Skip that for now.

The S_ROW_NUM (or S_ROW_COUNT) variables are odd ones. I can call those up to set ID's and/or classes on li's and anchor's. No problem there. As as example, this works:

Code: Select all

id="block1_{l_block1.S_ROW_NUM}"
That will spit out id="block1_0", id="block1_1", etc. Obviously that can be extended to the *_block2 level easily enough, if necessary.

But, if I try to do a match with an integer it still gives me a white page. This is despite the syntax I'm using matching what is given in docs/coding-guidelines.html under "Extended syntax for Blocks/Loops", AFAICT, so that's another weird one that has me stumped. Probably don't really need to match an integer though. Just being able to set custom ID's and classes should be sufficient.

TBH that docs section is not all that clear. I don't doubt there is coherent logic behind the UCP menu templating, but it is certainly not a normal menu by any stretch of the imagination. I can bodgy it up for now, but getting it done the way I really want it is obviously going to require picking the entire template logic apart and rebuilding it. I might put that on the back burner, since nobody seems to know much about it.

OTOH, the MCP menu is a piece of cake to revamp (although its layout is slightly eccentric in some ways).
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦
User avatar
NeoDev
Registered User
Posts: 24
Joined: Mon Oct 18, 2021 9:52 pm
Name: Neo

Re: UCP menu logic issue.

Post by NeoDev »

Gumboots wrote: Tue Sep 17, 2024 5:38 am That all implies that S_ROW_COUNT and S_ROW_NUM should be able to be used like this (test case only):

Code: Select all

<!-- IF (t_block1.S_ROW_COUNT = 4) --> style="background:red;"<!-- ENDIF -->
But that causes a white page (no body tag content). Does anyone know why?
= vs ==

As used in prosilver/template/faq_body.html

Code: Select all

<!-- IF faq_block.SWITCH_COLUMN or (SWITCH_COLUMN_MANUALLY and faq_block.S_ROW_COUNT == 4) -->
				</div>

				<div class="column2">
			<!-- ENDIF -->
Come for the comics, stay for the bad fish puns.
— The Cross Time Cafe
User avatar
Gumboots
Registered User
Posts: 800
Joined: Fri Oct 11, 2019 1:59 am

Re: UCP menu logic issue.

Post by Gumboots »

Serves me right for looking at the docs. :P
And for looking at how other things are set in the templates, like <!-- DEFINE $CAPTCHA_TAB_INDEX = 0 -->.
Ok, will do it with == and see how I go.

TBH it would be handy if, instead of just giving a white page, phpBB would give the sort of error messages some apps give when you screw a PHP file. If you see "Syntax error; Line 346 - unexpected stupidity - expected X, found Y" you can usually sort it in a few seconds.
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6313
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Re: UCP menu logic issue.

Post by thecoalman »

Gumboots wrote: Tue Sep 17, 2024 10:15 pm And for looking at how other things are set in the templates, like <!-- DEFINE $CAPTCHA_TAB_INDEX = 0 -->.
That's setting the variable, wasn't even aware you could do that.

Generally speaking in many programming languages a single equals sign sets a value, the double equals sign is for comparison.
TBH it would be handy if, instead of just giving a white page
You might be able to get some information by enabling debug mod.

https://www.phpbb.com/support/docs/en/3 ... ebug-mode/

I'm assuming you are on local machine. You can also open the php.ini, turn on display errors and set the error logging level to E_ALL
“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
Gumboots
Registered User
Posts: 800
Joined: Fri Oct 11, 2019 1:59 am

Re: UCP menu logic issue.

Post by Gumboots »

Ah, cool. Might try enabling that. I'm not on local. I've just been doing this live online in a locked directory. Means I can check it on my phone too. ;)

I have used == before in PHP and javascript, but hadn't noticed it in phpBB's unique syntax before now.
🇺🇦 Слава Україні! 🇺🇦 Героям слава! 🇺🇦
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6313
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Re: UCP menu logic issue.

Post by thecoalman »

You can set those php values at run time in the script. Just put them in config.php

Code: Select all

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
Display errors should not be used on public site.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison

Return to “phpBB Custom Coding”