Couple of Custom Module issues
Hello, I have one question and one issue. First the question:
In our Definitions file we have this:
// The Main Bio
var contentField = new HtmlFieldElement(mainSection.Fields)
ID = "contentFieldControl",
DataFieldName = (displayMode == FieldDisplayMode.Write) ? "Content.PersistedValue" : "Content",
DisplayMode = displayMode,
CssClass = "sfFormSeparator sfContentField",
ResourceClassId = typeof(PeopleResources).Name,
WrapperTag = HtmlTextWriterTag.Li,
EditorContentFilters = Telerik.Web.UI.EditorFilters.DefaultFilters,
EditorStripFormattingOptions = (Telerik.Web.UI.EditorStripFormattingOptions?)(Telerik.Web.UI.EditorStripFormattingOptions.MSWord | Telerik.Web.UI.EditorStripFormattingOptions.Css | Telerik.Web.UI.EditorStripFormattingOptions.Font | Telerik.Web.UI.EditorStripFormattingOptions.Span | Telerik.Web.UI.EditorStripFormattingOptions.ConvertWordLists)
;
mainSection.Fields.Add(contentField);
var testLinksField = DefinitionTemplates.CategoriesFieldWriteMode(keyLinkagesSection.Fields);
testLinksField.DisplayMode = displayMode;
testLinksField.TaxonomyId = myModule.testTaxonomyId;
testLinksField.ShowCreateNewTaxonButton = false;
testLinksField.ResourceClassId = typeof(PeopleResources).Name;
testLinksField.Title = "PositionCategoryTitle";
keyLinkagesSection.Fields.Add(testLinksField);
detailView.Sections.Add(keyLinkagesSection);
Hello Kmac,
The size of the Html field: it is not defined from the definition, the size is controlled from the backend theme.
You can get a copy of Sitefinity default backend theme and use it as your theme add styles or modify the existing ones.
You can add height to these classes using !important or modify Window.css from the backend theme.
.RadEditor table, .RadEditor.reWrapper table td
var categories = DefinitionTemplates.CategoriesFieldWriteMode(taxonSection.Fields);
categories.DisplayMode = displayMode;
categories.FieldName =
"cat1"
;
categories.ID =
"someId"
;
taxonSection.Fields.Add(categories);
var selection = DefinitionTemplates.CategoriesFieldWriteMode(taxonSection.Fields);
selection.DisplayMode = displayMode;
selection.FieldName =
"sec1"
;
selection.ID =
"otherId"
;
taxonSection.Fields.Add(selection);
Thanks. I tried what you said and now have the following code:
//AssistantLinks
var assistantLinksField = DefinitionTemplates.CategoriesFieldWriteMode(assistantSection.Fields);
assistantLinksField.DisplayMode = displayMode;
assistantLinksField.FieldName = "People";
assistantLinksField.ID = "CFPeople";
assistantLinksField.TaxonomyId = PeopleModule.PersonTaxonomyId;
assistantLinksField.ShowCreateNewTaxonButton = false;
assistantLinksField.ResourceClassId = typeof(PeopleResources).Name;
assistantLinksField.Title = "AssistantCategoryTitle";
assistantSection.Fields.Add(assistantLinksField);
//PracticeAreaLinks
var practiceAreaLinksField = DefinitionTemplates.CategoriesFieldWriteMode(practiceAreasDetailsSection.Fields);
practiceAreaLinksField.DisplayMode = displayMode;
practiceAreaLinksField.FieldName = "PracticeAreas";
practiceAreaLinksField.ID = "CFPracticeAreas";
practiceAreaLinksField.TaxonomyId = practiceAreaTaxonomyID;
practiceAreaLinksField.ShowCreateNewTaxonButton = false;
practiceAreaLinksField.ResourceClassId = typeof(PeopleResources).Name;
practiceAreaLinksField.Title = "PracticeAreasCategoryTitle";
practiceAreasDetailsSection.Fields.Add(practiceAreaLinksField);
Hello Kmac,
The fields display the same categories because they use helper method CategoriesFieldWriteMode.
This helper method creates a definition for a field named "Category" and all field created use the same database field. The helper method is:
publicstaticHierarchicalTaxonFieldDefinitionElement CategoriesFieldWriteMode(ConfigElement section)
HierarchicalTaxonFieldDefinitionElement element = newHierarchicalTaxonFieldDefinitionElement(section);
element.ID =
"categoriesFieldControl"
;
element.DataFieldName =
"Category"
;
element.DisplayMode = 1;
element.ResourceClassId =
typeof
(TaxonomyResources).Name;
element.TaxonomyId = TaxonomyManager.CategoriesTaxonomyId;
element.WebServiceUrl =
"~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc"
;
element.AllowMultipleSelection =
true
;
element.WrapperTag = HtmlTextWriterTag.Li;
element.Title =
"Categories"
;
element.ExpandableDefinitionConfig.Expanded =
false
;
element.ExpandableDefinitionConfig.ExpandText =
"ClickToAddCategories"
;
element.ExpandableDefinitionConfig.ResourceClassId =
typeof
(TaxonomyResources).Name;
returnelement;