Settings Tab - Published and Created

Vote:
 

Hi,

Does anyone know if it's possible to hook into the built in properties Published and Created on the settings tab at all? I'm interested in either removing, disabling editing of these or changing the value of the labels.

so far I've not found if this is possible so any pointers would be much appreciated.

Thanks,

Mark

#115253
Jan 12, 2015 15:47
Vote:
 

I do not know it there are any way to say that the editor should not be able to update this, but still be able to publish the page.

What you can do is to hide them with css, just add this to a css that are included in the edit mode

a[name="ichangetrackable_created"] {
    display: none;
}
a[name="iversionable_startpublish"] {
    display: none;
}

Read more here on how to create such a css-file (you do not need the things Alf puts in his, just the code I wrote, but the things Alf do in this blog post is great)

http://talk.alfnilsson.se/2014/12/18/display-help-text-in-on-page-editing/

God luck!

#115255
Jan 12, 2015 16:09
Vote:
 

Hi Mark, 

maybe this class can help?

 var tabDefinitionRepository = ServiceLocator.Current.GetInstance<ITabDefinitionRepository>();

We have used this initialization module to add this piece of code: 

 private static void AddTabToList(ITabDefinitionRepository tabDefinitionRepository, TabDefinition definition)
        {
            var existingTab = GetExistingTabDefinition(tabDefinitionRepository, definition);
            if (existingTab != null)
            {
                definition.ID = existingTab.ID;
            }
            tabDefinitionRepository.Save(definition);
        }

        private static TabDefinition GetExistingTabDefinition(ITabDefinitionRepository tabDefinitionRepository, TabDefinition definition)
        {
            return tabDefinitionRepository
                .List()
                .FirstOrDefault(t => t.Name.Equals(definition.Name, StringComparison.InvariantCultureIgnoreCase));
        }


And than call this by:

 AddTabToList(tabDefinitionRepository,
                new TabDefinition { Name = SystemTabNames.Content, RequiredAccess = AccessLevel.Edit, SortIndex = 1 });

I hope it helps! :)

#115262
Jan 12, 2015 17:03
Vote:
 

Thanks Henrik/Simona,

I'm not sure that either approach works for me. I would like to change the label of the Published field to "To be published on" while leaving it editable. For the Created field I have been able to make this read only by overriding the Created Property and adding an Editable(false) attribute. Strangely, for Created, if I set a name and description in the Display attribute these get ignored and the default values are used.

Mark

#115264
Jan 12, 2015 17:15
Vote:
 

A third way that should be possible is to implement an IMetadataExtender.

See Kalle Ljungs blog for some sample code, http://world.episerver.com/blogs/Kalle-Ljung/Dates/2013/10/Moving-built-in-properties-to-the-settings-header-in-EPiServer-7-CMS/.

Regards

Per Gunsarfs

#115266
Jan 12, 2015 17:18
Vote:
 

If you just need to change the label, you could add this to one of your languages files:

<languages>
  <language name="English" id="en">
    <contenttypes>
      <icontentdata>
        <properties>
          <iversionable_startpublish>
            <caption>Published or whatever</caption>
          </iversionable_startpublish>
        </properties>
      </icontentdata>

...

#115267
Jan 12, 2015 17:29
Vote:
 

For the "Created" property, I think you can use:

         <ichangetrackable_created>
            <caption>Created</caption>
            <help>Description goes here </help>
          </ichangetrackable_created>
#115268
Jan 12, 2015 17:32
Vote:
 

To change the description etc the method described by Per works great.  To hide a property from the editor, or make it readonly then an EditorDescriptor can be used e.g.

[EditorDescriptorRegistration(TargetType = typeof(DateTime?))]
public class EPiServerDateFieldEditorDescriptor : EditorDescriptor
{
    public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
    {               
        if (metadata.PropertyName == "ichangetrackable_created")
        {
            metadata.IsReadOnly = true;                
            //metadata.ShowForEdit = false;
        }
        base.ModifyMetadata(metadata, attributes);
    }
}
#115379
Jan 14, 2015 11:09
Vote:
 

Thanks everyone!

#115380
Jan 14, 2015 11:12
Vote:
 

If you are working with EPiServer 7.5, there is a simplified version on how to move built in properties as part of this sample project on GitHub:

https://github.com/episerver/cms-ui-extension-samples/blob/master/EditorDescriptors/SiteMetadataExtender.cs

#115384
Jan 14, 2015 11:52
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.