Specifying page template for content:// URLs

Hi, is there a way to specify the page template to use in content://xxx URLs when a content type is assigned to more than one page template? I know you can specify the page template when publishing content to a site, but these will be “unpublished” articles linked to from a list which needs different portlets elsewhere on the page than the site’s default page template for the content type.

The way we have done it so far is to create specific menu items for the content elements, and set those there with the “correct” page template. Another approach would be to have a custom content type that copies most of the elements from the “original” but which then will use its own page template.

(Typically I would expect it to be something like _template=yyy or the like, but cannot find a reference to any, like there is for the parameters for attachment:// or image:// URLs.)

There is no way of manipulating which template is used on the url (the content:// is transformed to a regular url after being processed).

We have plans to move content-type - page-template mapping from the _templates/ folder and into the page structure. This way you can for instance specify to use template “B” for articles under /structure/b and template “A” for articles under structure/a - however, this is a breaking change and cannot be done until 7.0.

If you are producing many of these articles I propose you create two (almost identical) content types for now, otherwise just stick with the current solution and wait for the feature above :slight_smile:

Also, remember that the order of the templates in the _templates/ folder controls what template is used by default!

Ah, but this is under CMS 4.7.13 - not XP. :slight_smile:

It’s possible the customer wants to have more than one type of content show on these so we may end up with menu items for them anyway.

Ah… Missed that :slight_smile:
As you probably know, in CMS the page templates are autoselected based on name, so templates named a are automatically used before the ones named b!

Hope this works out for you anyways then!

One possible solution to force a specific page template is to create a pseudo content link that is generated within the XSLT template files on the following format:


In other words, it is a link that leads to a menuitem (typically of type “section page”) that uses a specific page template with the portlets that you desire. The portlet that shows your content should then have a datasource that retrieves the content based on the content key provided as a URL parameter (typically use getContent which does this by default).

The drawback is that you get worse SEO because you don’t get the content name in the URL and instead have to rely on using a URL parameter, and several content will point to the same page only with different parameter values.

Some historical trivia: This was how one used to create content URLs back in the days of Enonic Vertical Site (nearly 10 years ago), when all pages were simply on the format /page?id=123&key=1234

1 Like

SEO is not too important in this case as the information will be “local” to the pages in question. So we will probably go for this approach. Thanks!