Retrieve forum ID inside template

Post

Posted
Rating:
#4882 (In Topic #1077)
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’

CNS_FORUM_IN_GROUPING.tpl

I'm working on a forum mod but I need to be able to grab the ID of the current forum in CNS_FORUM_IN_GROUPING.tpl.

Unfortunately no existing parameters capable of grabbing this info are passed into the template that I can see, so is there a way to do this?

EDIT: I just created a new symbol, to pull the ID from the database. This seems to be doing what I need it to!

Last edit: by Joe

Online now: No Back to the top

Post

Posted
Rating:
#4883
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
I thought I'd get lucky with something like {FORUM_ID*}, but this didn't return anything.
Online now: No Back to the top

Post

Posted
Rating:
#4884
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Alright, so the only thing I could find that is slightly usable is {EDIT_URL}

I can use the following to extract the ID from the URL:

Code

{$REPLACE,id=,,{$SUBSTR,{EDIT_URL},{$STRPOS,{EDIT_URL},id=},6}}

(this supports up to a 3 digit forum ID #)

But, {EDIT_URL} isn't passed into the template if the current user is not allowed to edit the forum. So, this won't work as the user viewing the forums would need access to the ID. Also, the above solution can get buggy if there's additional variables in the URL, such as keep_su.

{FORUM_NAME} just returns the name of the forum and not the ID.

I also tried using {$FORUM_CONTEXT} by including the name of the forum as a parameter (hoping it would convert into an ID), but this identifier doesn't support parameters. :(
Online now: No Back to the top

Post

Posted
Rating:
#4888
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
It's {ID}.

You can always find available parameters by putting in this temporary code {+START,PARAM_INFO}{+END}


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#4889
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
The easiest and most common solution is never sought at first. At least not for me!

Sorry lol
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Forum statistics:
  • 2,052 topics, 7,195 posts, 10,827 members
  • Our newest member is LowfareMart
Back to Top