core icon indicating copy to clipboard operation
core copied to clipboard

Unable to use Templates across Multiple Sites

Open patrick-schweiger opened this issue 2 years ago • 11 comments

Parent Issue

No response

Problem Statement

This was discovered in a meeting with VOXX when trying to show them how to share templates across multiple sites. However, this would also impact other multi-tenant clients. Looking both at demo and Voxx’s instances (both on 24.11.11) we noticed we no longer have the “all sites” dropdown option when trying to select templates living on other sites.

Steps to Reproduce

For example, on demo we created a site “Pagecopycreatetest” and a “test” template If we go to the “demo” host and try to create a page, we do not have an option to select “all sites” and are restricted to using only templates on my current site.

Acceptance Criteria

There should be the ability to drop down and select templates across sites.

dotCMS Version

The ability to select templates across sites exists in the 24.04 LTS so this must be a recent issue.

Proposed Objective

Core Features

Proposed Priority

Priority 2 - Important

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

https://dotcms.slack.com/archives/C028Z3R2D/p1731608383050379

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

patrick-schweiger avatar Nov 14 '24 18:11 patrick-schweiger

https://dotcms.freshdesk.com/a/tickets/28692 -> problem reported by another customer

m27iu4 avatar Dec 11 '24 10:12 m27iu4

@patrick-schweiger I'm not clear where you're expecting to see the selection.

Can you please give us clear steps to reproduce? Meaning:

  1. Open screen X.
  2. Click field Y and select option Z
  3. etc.

john-thomas-dotcms avatar Dec 11 '24 20:12 john-thomas-dotcms

I have confirmed this issue, steps to reproduce

  1. Create a new site
  2. Select the new site and create a template into this new site
  3. Get back to the initial site (default for instance)
  4. try to create a page
  5. when selecting the template for the page you are able to see the system template and only the templates for the current host, the template created for the new site is not available.

jdotcms avatar Dec 11 '24 22:12 jdotcms

I think we are going to need a quick UI mockup to fix this properly

wezell avatar Dec 11 '24 22:12 wezell

the issue is here: https://github.com/dotCMS/core/blob/main/dotCMS/src/main/java/com/dotcms/rest/api/v1/template/TemplateResource.java#L140

Basically there is a fallback when the hostid is null, blank or 404, the fallback in these situations will retrieve always the current host.

Probably we can do two things:

  1. send a by pass such as hostId=all that retrieves all of the hosts
  2. if the host is null, means retrieves everything instead of retrieve the current host templates

For references the call may by the UI looks such as

https://demo.dotcms.com/api/v1/templates/?filter=&page=0&per_page=1000&orderby=&host=3ba99f0e8ab5778b6139c9c6a6b742b9

jdotcms avatar Dec 11 '24 23:12 jdotcms

@wezell @john-thomas-dotcms @jdotcms we use to have the selector options like this

CleanShot 2024-12-13 at 07 31 52@2x

Which included the "All Sites" functionality.

fmontes avatar Dec 13 '24 13:12 fmontes

What is happening?

We lost this feature/functionality in this PR: Issue 28563 - Removing template AJAX and JS dependencies (#28618).

The relevant code where this functionality was implemented can be found here: TemplateAjax.java (Deleted).

Class: TemplateAjax Function: fetchTemplates Code Snippet:

//...
Template t = new Template();
t.setOwner(user.getUserId());
t.setModUser(user.getUserId());
t.setInode("0");
t.setTitle("--- " + LanguageUtil.get(user, "All-Hosts") + " ---");
t.setIdentifier("0");
fullListTemplates.add(t);
totalTemplates.add(t);
countF = count - 1;
//...

Possible Steps fix:

  • [ ] check if the /api/v1/templates endpoint can retrieve all templates regardless of the host
  • [ ] Update the templateFetchParams with the necessary params to achieve that.
  • [ ] Add an All Sites label to the dropdown as @fmontes show here. (It was deleted with the file)

How the dropdown currently work

We now use the /api/v1/templates endpoint to fetch templates. However, I'm not sure if this endpoint can retrieve all templates regardless of the host.

File: template_custom_field.vtl#L183-L195 Code Snippet:

//...
const templateFetchParams = {
    query: {
        fullTitle: '*'
    },
    queryOptions: {},
    start: 0,
    count: 1000,
    sort: [],
    onComplete: onTemplateFetchComplete
};

templateStore.fetch(templateFetchParams);
//...

rjvelazco avatar Jan 07 '25 18:01 rjvelazco

PRs:

  • https://github.com/dotCMS/core/pull/31086

github-actions[bot] avatar Jan 08 '25 19:01 github-actions[bot]

Note to QA

This video includes the expected behavior we lost:

https://github.com/user-attachments/assets/fecde4f0-9589-4b84-872d-f48b9e2a83ac

rjvelazco avatar Jan 15 '25 14:01 rjvelazco

Passed IQA

Tested in dotcms/dotcms:trunk https://github.com/user-attachments/assets/d8d73364-4f4e-4c4d-8fa7-10b737420bfa

KevinDavilaDotCMS avatar Jan 15 '25 18:01 KevinDavilaDotCMS

Only for 24.12 LTS

erickgonzalez avatar Jan 16 '25 17:01 erickgonzalez