Skip to main content

Hey there!

I’m curious if it’s possible at all to have a subforum prefilled when posting a question from a custom page. 

 

We want to include a question feed on our custom page, but when posting from the custom page, the subforum field defaults to being empty. We’d like to prefill the subforum on the question so that when someone posts a question from our custom page, it will appear in specific question feed that we’ve added to the page.

 

  1. Does this make sense? 😅
  2. Is this possible?

Many thanks to anyone with thoughts on this :)

Good news! This should be possible.

What needs to happen is that the create topic button needs to have ?fid={category id #} appended to the URL link when you’re on the specific custom page. 

I deduced this from looking at what happens when you’re on a category sub-forum and click the create topic button. (Example, when you’re in the CC category, the button links to https://communities.gainsight.com/topic/new?fid=17 )

How do you automate that? There’s likely a way to set it via third party scripts. Essentially an If/then statement based on the URL of the page you’re on. IF you’re on the custom page, THEN change the URL of the Create Topic button to have the appended parameter on it)

I’m not skilled enough with scripting to tell you what that is, but support and others here on the community have solved things like that for me before. 


@Kenneth R and gainsght team. IMO this would be a good best practice for your product-specific custom pages you link to via the quick links on the community home page. 

If you figure it out, then @jwren and the rest of us could use that script too :) 


Hey @DannyPancratz and @jwren - this is a fun one.  🙂 As you say, Danny, the only way to do this is with third-party scripts.  Those types of scripts are a little hacky and we don’t always recommend them… 

BUT I did just manage to do it in a sandbox, so you can try this approach as well.  :)

In the snippet below you’ll need to change the URLs to your community, of course (in my example I’m referencing a custom page called ‘test’) as well as the ID of the category you want to pre-fill (my example is 14).

<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
// Check if the current URL is the target page
if (window.location.href === "https://YOURCOMMUNITY.com/p/test") {
// Find the button using its class or id (adjust this selector to match the actual button)
var button = document.querySelector('.menu-create-topic');
// If the button exists, change its href attribute
if (button) {
button.href = "https://YOURCOMMUNITY.com/topic/new?fid=14";
}
}
});
</script>

 


Amazing @Kenneth R  😮

Thank you!!


Reply