Retrieve forum ID inside template
Posted
#4882
(In Topic #1077)

Standard 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
Posted

Standard member

Posted

Standard member

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.

Posted

Site director

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
- 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.
Posted

Standard member

Sorry lol
1 guest and 0 members have just viewed this.