It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

how to set default category in space list macro

The space list macro provides a list of spaces however the category value changes apparently to whatever was last used.

 

I need to set the value for the category list to a default value whenever the page is refreshed.

 

Tried the following but it had no effect.

<div>
	<script>
		let teamOptions = document.getElementsByName("spacesSelectedTeam")[0].options;
		for (let i = 0; i < teamOptions.length; i++) {
			if (teamOptions[i].value == "ttgkb") {
				// Item is found, set its property and exit
				//teamOptions[i].selected = true;
				break;
			}
		}
	</script>
</div> 

 

1 answer

0 votes
Dominic_Lagger Community Leader Nov 05, 2019

Hi @Stacy Ajouri 

Your approach is not very bad at first sight. But I have some questions.

  • Where did you add your code?
  • Would a user macro be acceptable?

Perhaps my little input helps you already to figure something out.

When I change the category it reloads the whole page with a new URL:

conflueceURL/page/viewpage.action?spaceKey=KEY&title=Space+Category&spacesSelectedTab=category&spacesSelectedTeam=ttgkb

With this URL, you will always get to the page where the team "ttgkb" is selected. 

Hope it helps, Regards,

Dominic

Hi, I just added it inside the page.  

A user macro may be possible.

The URL is okay but the user may go directory to the page from another path.

Dominic_Lagger Community Leader Nov 06, 2019

Hi @Stacy Ajouri 

I think I know why the Javascript directly in the page did'nt work, because the space category macro wasn't loaded at this time. 

I added it in end of the body in the "Custom HTML" section in the administration console. There it worked, but not very user friendly... 
When you go to the page, it sets the category as excpected --> ttgkb. But because a manual change of the dropdown reloads the page, the script is executed again and the category ttgkb is selected again... That means you would never be able to change the category. 

The user macro didn't work out for me either. Because in the settings you cannot change the default dropdown value.

The only really dirty way I can think off would be:

  • Reload the page by javascript with the URL i gave to you
  • That would mean, when a person comes to this page, it would reload automatically and the right space category is set. 
  • Redirect with Javascript

Regards, Dominic

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

How is your team having fun and bonding, remotely, utilizing Confluence?

Thanks everyone for answering last week’s question. The winner of the random drawing from those who commented is: @LarryBrock I’ll contact you separately with your prize details. This wee...

276 views 9 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you