ASPX templates
Version 4.x > ASPX templates > Is there a way to do this easier? View modes: 
User avatar
Member
Member
random0xff - 5/31/2009 4:15:19 PM
   
Is there a way to do this easier?
<title><%= CMSContext.CurrentDocument.DocumentName == String.Empty ? CMS.SettingsProvider.SettingsKeyProvider.GetValue(String.Format("{0}.CMSPageTitlePrefix", CMSContext.CurrentSiteName)) : CMSContext.CurrentTitle%></title>

Does that code make you dizzy? I know! On the homepage I don't want to have "site - title", just "site", but on all the other pages I want "site - title". I want to set the title on ONE masterpage, like above. It checks to see if document name is empty, then it takes a loooong way to get the setting. Otherwise it uses the quick way to get the title with the macro already resolved (nice!).

But that code is quite dense, isn't there a simple macro for this?

PS. For the root node, I can't set the "Document name" property. Why not? Also, I can't set the Page title, unless I first create a 'tag group', why?! It has nothing to do with tag groups... :-(

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 6/7/2009 4:32:07 AM
   
RE:Is there a way to do this easier?
Hello,

Well, Kentico CMS API contains many classes and methods so there are many namespaces to keep the clarity. You can use 'using namespace;' statement in beginning of the page (e.g. using CMS.SettingsProvider;) so you don't need to specify it multiple times in code.

You can't specify name for root node as it is not actual page - it just represent root of site's tree structure (that contains master template and settings that other documents can inherit).

Regarding the 'tag group', this is unfortunately bug in version 4.0. It will be fixed in version 4.1. In a meantime please create some tag group to be able to save changes in 'Metadata' section.

Best Regards,

Martin Dobsicek



User avatar
Member
Member
random0xff - 6/11/2009 4:13:01 PM
   
RE:Is there a way to do this easier?
"You can't specify name for root node as it is not actual page - it just represent root of site's tree structure (that contains master template and settings that other documents can inherit)."

Oh ok, I didn't know that.