How to create a custom URL to mark a discussion as a question by default

Document created by mass6 on Feb 20, 2012Last modified by mass6 on Feb 20, 2012
Version 5Show Document
  • View in full screen mode

I've seen a few threads asking for the same thing, and after digging around the boards, I found out that there is no out of the box solution for marking a discussion as question by default. Note, this only pertains to those installations where the global default is not to mark discussions as questions.


Use Case:

Say you want to add a text or image link on a overview page, such as a call to action or something in a formatted text widget that reads "Ask a Question."  The user clicks this link, and then is taken to a new discussion draft page with the "Mark as question" check box already checked. The below is how you can accomplish this by creating a URL with an extra parameter, along with adding a few lines of code into one of the Freemarker templates.



  • This was created on a JIve 5.0.2 instance. However, the same principles should apply to previous versions, but the .ftl files may be a little different.
  • This requires that you will specify the exact "place" (container) where this question will be posted. You can't choose it on the fly using this method.


How it works:

The URL is constructed with an extra parameter on the end, something like &discussionType=question. Then, by adding a little Javascript code to the discussion .ftl template, the URL is read and checks to see if the discussionType parameter was sent with a value equal to "question". If these conditions are met, the script will then set the "mark as question" checkbox = true.


Step 1) Build the custom URL

First, to construct the URL, you will need to know which container "place" you want this link to post questions to, along with its container type and container ID. Easiest way to do this is to simply create a new blank discussion and copy the URL that is created in your browser's address bar. It should look something like the following:!input.jspa?containerType=14&container=2031&contentType=1


All you need is everything after you jive url, so in this case it would be:



Then, you just need to add one parameter on the end of the URL, such as discussionType=question. The final URL should look something similar to the below (remember to add the & before the parameter)



Now you have the URL you'll use to create a link to creating a question.



Step 2) Edit postform.ftl



Add the following code in Head section of the postform.ftl file. I put mine starting on line 82. See attached for ready to go .ftl file (Jive 5.0.2)


Note: Line 18 is where you specify the parameters you chose in step to indicate that this is a question. If these parameters aren't found, then the discussion will not be marked as a question upon opening.


<!-- Script to read URL parameters and mark checkbox as question -->

<script type="text/javascript">
  window.onload = function() {
  url = window.location.href.split("?");
  if(url.length > 1)
  terms = url[1].split("&");
  for(var i = 0; i < terms.length; i++)
  var key = terms[i].split('=')[0];
  var value = terms[i].split('=')[1];
  //Here you can process each key and value. This is where
  //check for the special parameter you added on the end
  //of the custom URL to create discussion as a question.
  //If the parameter is found, then this code will enable
  //the checkbox.
  if (key=="discussionType" && value=="question"){
  document.getElementById("mq01").checked=true; //here is where you mark the checkbox

<!-- End custom script -->


That's it. All you need to do now create a link using the URL in step one and your set. Hope this works for you and that you find it useful.