0

I have a certain item which uses a sublayout sub1. The item created with this sublayout has a field "Switch Columns" which i want to remove or hide (or hide/remove the section "Columned Grid" if possible) . Note that i do not want every item of that template to hide the field; just the items using sub1 (since the template is being used by different sublayouts).

enter image description here

Is there a way to do this via code in the ascx file of the sublayout ?

4 Answers4

3

You can solve by using an extra layer inherit.

Create 2 set of template fields: Template field minimal set Template fields with addition fields.

sub1 Inheritance from the Template field minimal set other layouts use a template with Inheritance from the minimal set and the addition field.

maybe this is also usable: For Hide in the Content editor. You can deny "Field Read" for a role/user on your Template Field or Section item.

See https://community.sitecore.net/developers/f/8/t/2113

Jan Bluemink
  • 3,467
  • 1
  • 21
  • 35
  • I guess I do not understand the question. Answer changed I think you can use Inheritance to solve your issue. – Jan Bluemink Dec 04 '15 at 09:01
  • By inheritence you mean Template Inheritence? which would mean creating another template which inherits from base and make changes to the new template ? As I said earlier, I dont want to make any changes to templates as that would change many existing items. – Prathamesh dhanawade Dec 04 '15 at 09:08
1

You can hide fields in the Content Editor with a custom processor in the getContentEditorFields, see this post:

http://ctor.io/hide-fields-in-the-sitecore-content-editor/

But as other answers suggested, I would overthink your approach. Personally I would either use two separate Sublayouts (with different number of columns where you can easily swap them later without loosing it's datsource) or use this as a rendering parameter.

Kevin Brechbühl
  • 4,717
  • 3
  • 24
  • 47
0

No, that is not possible. When viewing an item in content editor, your sublayout is not loaded. I would recommend that you rethink your architecture. This sort of field should probably be a rendering parameter. Alternatively, you could create a separate template to act as the data source for those sublayouts.

Ben Golden
  • 1,580
  • 9
  • 16
  • That was [already suggested](http://stackoverflow.com/questions/34060128/sitecore-8-get-sublayout-item-when-ascx-file-is-shared) to the OP. – jammykam Dec 04 '15 at 15:51
-1

Maybe a custom pipeline for the content editor? If you tap into the <renderContentEditor> pipeline, you may be able to inspect the item's presentation, sniff out the sublayout, and inject some JavaScript to hide the panel.

Jim Noellsch
  • 714
  • 4
  • 7