Programmable Layouts: Channel & Microsite Information
Introduction
With Programmable Layouts, you can retrieve information about the current Channel or Microsite that your content is in. This can be useful when you want to set dependencies within the content or retrieve the settings used in the Channel configuration.
Information
This is a list of the common methods used for Channels and Microsites.
get Channel Object
Using publishCache
it is possible to retrieve the current Channel configuration. If the code is placed inside a Microsite, it will return the Channel configuration of the Microsite.
The result of the above code is:
Channel [id=38, name=Knowledge Base : https://docs.terminalfour.com/, description=Channel for our support, community and knowledge base site, type=text/kb, default_language=en]
get Channel ID
It is possible retrieve the Channel ID using the following method:
(Integer) channel.getID()Examplechannel = publishCache.getChannel() var myChannelID = channel.getID(); document.write('Channel ID: ' + myChannelID + '<br/>');The result of the above code is:
Channel ID: 38
get Channel Name
If you want the Channel name the following function will get it for you:
channel.getName()Examplechannel = publishCache.getChannel() var myChannelName= channel.getName(); document.write('Channel Name: ' + myChannelName + '<br/>');The result of the above code is:
Channel Name: Knowledge Base : https://docs.terminalfour.com/
get Channel Publish URL
Requires ver 8.2.7+
When using Open Graph meta tags it can be useful to retrieve the Channel Publish URL for use in the og:url
property:
The result of the above code is:
Channel Publish URL: https://docs.terminalfour.com/
get Channel Default Content Layout
The Channel Content Layout is useful when interacting with Content Layout information.
(string) channel.getType()Examplechannel = publishCache.getChannel() var myChannelType = channel.getType(); document.write('Channel Default Content Layout: ' + myChannelType + '<br/>');The result of the above code is:
Channel Default Content Layout: text/kb
get Channel Default Fulltext Content Layout
Similar to the Channel Default Content Layout, the fulltext default layout will be useful when working with content and Content Layout information:
(string) channel.getFullTextType();Examplechannel = publishCache.getChannel() var myChannelType = channel.getFullTextType(); document.write('Channel Default Fulltext Content Layout: ' + myChannelType + '<br/>');The result of the above code is:
Channel Default Fulltext Content Layout: text/kb/fulltext
get Microsite Channel
This method requires a CachedSection
Object. See Section Information for more details.
In TERMINALFOUR, Microsites are simplified Channel. When retrieving the Microsite information a Channel Object will be returned. It is then possible to retrieve the specific information using the functions already seen in this page.
Name
|
Type
|
Global Variable
|
Description
|
---|---|---|---|
Section | CachedSection | section |
It is the information of the Section that needs to check if is a Microsite |
The result of the above code is:
The section 10441 is not in a microsite