Subforum ID on Index

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
Farraday
Registered User
Posts: 14
Joined: Mon Jan 01, 2024 1:08 am

Subforum ID on Index

Post by Farraday »

Hi folks,

I'm trying to style individual subforum links on the index. Is there a way to get the actual subforum ID to print so that I can add it to the class names (eg, subforum-40)? {S_FORUM_ID} prints 0 by default on the index.

Thanks in advance!
Last edited by thecoalman on Fri May 10, 2024 12:56 am, edited 1 time in total.
Reason: Moved to custom coding.
User avatar
Sniper_E
Registered User
Posts: 1189
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey

Re: Subforum ID on Index

Post by Sniper_E »

You are in a subforum within this topic. In the breadcrumb above hover over 'phpBB Custom Coding'

The link should show in the bottom left of your screen on hover. The f=641 is this FORUM_ID number.
Last edited by Sniper_E on Fri May 10, 2024 5:30 am, edited 1 time in total.
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:
Farraday
Registered User
Posts: 14
Joined: Mon Jan 01, 2024 1:08 am

Re: Subforum ID on Index

Post by Farraday »

Sniper_E wrote: Fri May 10, 2024 2:25 am You are in a subforum within this topic. In the breadcrumb above hover over 'phpBB Custom Coding'

The link should show in the bottom left of your screen on hover. The f=641 is this {S_FORUM_ID} number.
Thanks, but I'm not looking for the subforum ID number, I'm wanting to know how to get that individual number to print in the code, on the index. Using {S_FORUM_ID} on the index returns a value of 0 for all subforums, regardless of their actual ID number.
User avatar
Sniper_E
Registered User
Posts: 1189
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey

Re: Subforum ID on Index

Post by Sniper_E »

In the forumlist_body.html template you have to add the FORUM_ID between the BEGIN and END tags using {forumrow.subforum.FORUM_ID} like this.

Code: Select all

<!-- BEGIN subforum -->
	<!-- EVENT forumlist_body_subforum_link_prepend --><a href="{forumrow.subforum.U_SUBFORUM}" class="subforum<!-- IF forumrow.subforum.S_UNREAD --> unread<!-- ELSE --> read<!-- ENDIF -->" title="{% if forumrow.subforum.IS_LINK %}{{ lang('FORUM_LINK') }}{% elseif forumrow.subforum.S_UNREAD %}{{ lang('UNREAD_POSTS') }}{% else %}{{ lang('NO_UNREAD_POSTS') }}{% endif %}">
		<i class="icon <!-- IF forumrow.subforum.IS_LINK -->fa-external-link<!-- ELSE -->fa-file-o<!-- ENDIF --> fa-fw <!-- IF forumrow.subforum.S_UNREAD --> icon-red<!-- ELSE --> icon-blue<!-- ENDIF --> icon-md" aria-hidden="true"></i>{forumrow.subforum.SUBFORUM_NAME}-{forumrow.subforum.FORUM_ID}</a><!-- IF not forumrow.subforum.S_LAST_ROW -->{L_COMMA_SEPARATOR}<!-- ENDIF --><!-- EVENT forumlist_body_subforum_link_append -->
<!-- END subforum -->
To list the FORUM_ID for a forum in that template you would use {forumrow.FORUM_ID} like this.

Code: Select all

<a href="{forumrow.U_VIEWFORUM}" class="forumtitle">{forumrow.FORUM_NAME}-{forumrow.FORUM_ID}</a>
<!-- IF forumrow.FORUM_DESC --><br />{forumrow.FORUM_DESC}<!-- ENDIF -->
In a class (eg, class="subforum-{forumrow.subforum.FORUM_ID}")
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:
User avatar
Mannix_
Registered User
Posts: 2003
Joined: Sun Oct 25, 2015 2:56 pm
Name: Matt

Re: Subforum ID on Index

Post by Mannix_ »

you can also use the href attribute to style them f.e

Code: Select all

.subforum[href*="f=691"] {
    color: blue;
}
each link ends with unique number you can use it to target specific links
Did I helped You? Consider a donation.
New version of phpBB has been released? My styles aren't validated for it yet? Check my page for the latest downloads!
User avatar
Talk19Zehn
Registered User
Posts: 886
Joined: Tue Aug 09, 2011 1:10 pm

Re: Subforum ID on Index - Jumpbox on Index

Post by Talk19Zehn »

Hello, only as a supplement. It is worth a try to use the "Jumpbox on Index" extension. Please test whether this variant of the output of forums and subforums is suitable for you.
https://www.phpbb.com/customise/db/exte ... _on_index/

BTW: I am not sure if I have understood your question correctly. Maybe the extension is a help or a different approach to output forums and subforums on index. Although the extension is more extensive, from my point of view it fulfils its purpose or perhaps the desired requirements in terms of content.

Many regards
Farraday
Registered User
Posts: 14
Joined: Mon Jan 01, 2024 1:08 am

Re: Subforum ID on Index

Post by Farraday »

Sniper_E wrote: Fri May 10, 2024 5:22 am In the forumlist_body.html template you have to add the FORUM_ID between the BEGIN and END tags using {forumrow.subforum.FORUM_ID} like this.

Code: Select all

<!-- BEGIN subforum -->
	<!-- EVENT forumlist_body_subforum_link_prepend --><a href="{forumrow.subforum.U_SUBFORUM}" class="subforum<!-- IF forumrow.subforum.S_UNREAD --> unread<!-- ELSE --> read<!-- ENDIF -->" title="{% if forumrow.subforum.IS_LINK %}{{ lang('FORUM_LINK') }}{% elseif forumrow.subforum.S_UNREAD %}{{ lang('UNREAD_POSTS') }}{% else %}{{ lang('NO_UNREAD_POSTS') }}{% endif %}">
		<i class="icon <!-- IF forumrow.subforum.IS_LINK -->fa-external-link<!-- ELSE -->fa-file-o<!-- ENDIF --> fa-fw <!-- IF forumrow.subforum.S_UNREAD --> icon-red<!-- ELSE --> icon-blue<!-- ENDIF --> icon-md" aria-hidden="true"></i>{forumrow.subforum.SUBFORUM_NAME}-{forumrow.subforum.FORUM_ID}</a><!-- IF not forumrow.subforum.S_LAST_ROW -->{L_COMMA_SEPARATOR}<!-- ENDIF --><!-- EVENT forumlist_body_subforum_link_append -->
<!-- END subforum -->
To list the FORUM_ID for a forum in that template you would use {forumrow.FORUM_ID} like this.

Code: Select all

<a href="{forumrow.U_VIEWFORUM}" class="forumtitle">{forumrow.FORUM_NAME}-{forumrow.FORUM_ID}</a>
<!-- IF forumrow.FORUM_DESC --><br />{forumrow.FORUM_DESC}<!-- ENDIF -->
In a class (eg, class="subforum-{forumrow.subforum.FORUM_ID}")
Yeah, unfortunately, {forumrow.subforum.FORUM_ID} does not print on the index. it ends up as class="subforum-". Thank you for trying, though!
Farraday
Registered User
Posts: 14
Joined: Mon Jan 01, 2024 1:08 am

Re: Subforum ID on Index

Post by Farraday »

Mannix_ wrote: Fri May 10, 2024 6:07 am you can also use the href attribute to style them f.e

Code: Select all

.subforum[href*="f=691"] {
    color: blue;
}
each link ends with unique number you can use it to target specific links
I had a sinking feeling I would need to use the link, because of course that prints just fine!

Thanks!

Return to “phpBB Custom Coding”