Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Confluence theme plugin - extend default theme not basic theme

alexbernotas April 22, 2014

Hi,

I would like to create a plugin that extends the "Default Theme" and not the "BasicTheme".

I'm following the "Create a Theme" tutorial (on atlassian.com) but all the examples are for extending the "BasicTheme" but this theme doesnt have the advance layouts like the "Defaul Theme" does.

Is this possible to achieve or I have to recreate the whole "Default Theme"?

All I want is to include a unique css file to restyle the content editing of theme theme in tinymce and globaly in some areas, the plugin Theme creation tutorial allows us to achieve what we want but we loose the default themes lyout features.

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
discountrobot
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2014

Hey Alex, one way to achive the default layout paring with your own styles would be to use fetch the default layout vmd files here: http://localhost:1990/confluence/admin/listdecorators.action

and add them to your theme like so:

<theme>
...
        <layout key="${project.groupId}.${project.artifactId}:main"/>
        <layout key="${project.groupId}.${project.artifactId}:global"/>
        <layout key="${project.groupId}.${project.artifactId}:page"/>
...
</theme>
<layout key="main" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/main.vmd">
        <resource type="velocity" name="decorator" location="/layouts/main.vmd" />
    </layout>

    <layout key="global" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/global.vmd">
        <resource type="velocity" name="decorator" location="/layouts/global.vmd" />
    </layout>

    <layout key="page" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/page.vmd">
        <resource type="velocity" name="decorator" location="/layouts/page.vmd" />
    </layout>

    <layout key="space" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/space.vmd">
        <resource type="velocity" name="decorator" location="/layouts/space.vmd" />
    </layout>



You will have to override the hasSpaceSideBar() function in several of the layout files.

alexbernotas April 22, 2014

Hi @DiscountrobotI tried adding the layout tags to the theme and looked at the suggested URL but I still get the message "You can not customise the site look and feel while a theme is active. You must first disable the currently configured theme." when I navigate to that URL.

I added the main.vmd file to project/src/main/resources/main.vmd

alexbernotas April 22, 2014

@DiscountrobotI didnt notice the update you've done let me try that

discountrobot
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2014

You have to disable the current theme to see the default layout files.

What you're trying to do could essentially be achived by adding styles in the Look & Feel section and customising the default layout files

alexbernotas April 22, 2014

@DiscountrobotI tried out the layout attributes that you just recently posted and now the theme is not appearing in the Themes section. i tried the exact example you posted (but just using main.vmd) and changed to BasicTheme as well which gives the same result:

<theme key="simpletheme" name="Simple Theme" class="com.atlassian.confluence.themes.BasicTheme">
        <description>A simple custom theme</description>
        <param name="includeClassicStyles" value="false"/>
        <resource type="download" name="default-theme.css" location="/includes/css/default-theme.css">
            <param name="source" value="webContext"/>
        </resource>

        <resource type="download" name="theme-tutorial.css" location="/css/theme-tutorial.css"/>

        <layout key="main" name="Main Decorator" class="com.atlassian.confluence.themes.BasicTheme" overrides="/decorators/main.vmd">
            <resource type="simpletheme" name="decorator" location="/layouts/main.vmd" />
        </layout>

    </theme>

discountrobot
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2014

My mistake, the tinyMCE editor is crap here.

You have to define the overrides outside of the theme declaration and then reference them by the key

<theme>
    ...
    <layout key="${project.groupId}.${project.artifactId}:main"/>
    <layout key="${project.groupId}.${project.artifactId}:global"/>
    <layout key="${project.groupId}.${project.artifactId}:page"/>
    ...
</theme>

...

<layout key="main" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/main.vmd">
    <resource type="velocity" name="decorator" location="/layouts/main.vmd" />
</layout>

<layout key="global" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/global.vmd">
    <resource type="velocity" name="decorator" location="/layouts/global.vmd" />
</layout>

<layout key="page" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/page.vmd">
    <resource type="velocity" name="decorator" location="/layouts/page.vmd" />
</layout>

<layout key="space" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/space.vmd">
    <resource type="velocity" name="decorator" location="/layouts/space.vmd" />
</layout>

alexbernotas April 22, 2014

Ok I'll try that

alexbernotas April 22, 2014

@Discountrobotthanks man I was able to make it work. Cheers!

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 22, 2015

Hello, I tried to follow the steps you described:

  1. I created my own theme
  2. then added:

    <theme>
    	...
    	<layout key="${project.groupId}.${project.artifactId}:main"/>
    	<layout key="${project.groupId}.${project.artifactId}:global"/>
    	<layout key="${project.groupId}.${project.artifactId}:page"/>
    	<layout key="${project.groupId}.${project.artifactId}:space"/>
    </theme>
    <layout key="main" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/main.vmd">
    		<resource type="velocity" name="decorator" location="/layouts/main.vmd" />
    	</layout>
    	<layout key="global" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/global.vmd">
    		<resource type="velocity" name="decorator" location="/layouts/global.vmd" />
    	</layout>
    	<layout key="page" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/page.vmd">
    		<resource type="velocity" name="decorator" location="/layouts/page.vmd" />
    	</layout>
    	<layout key="space" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/space.vmd">
    		<resource type="velocity" name="decorator" location="/layouts/space.vmd" />
    	</layout>
  3. I coppied all four layouts files to the "layouts" folder to the project's resources location

 

Did I understand it correctly or do I need to do anything else?

My problem is that I always get following exception when I try to use my theme plugin:

java.lang.RuntimeException: Error rendering template for decorator root
    at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:191)

caused by: java.lang.RuntimeException: Error rendering template for decorator page
    at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:191)

caused by: org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource '/com/atlassian/confluence/plugins/labels/components/labels-editor.vm'
    at com.atlassian.confluence.util.velocity.ConfigurableResourceManager.loadResource(ConfigurableResourceManager.java:406)

TAGS
AUG Leaders

Atlassian Community Events