Couple of Custom Module issues

Posted by Community Admin on 04-Aug-2018 15:06

Couple of Custom Module issues

All Replies

Posted by Community Admin on 21-Sep-2011 00:00

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);

Straight from the products module for adding a HTML text field. My question is is there a way to adjust the height of the RadEditor on a case by case basis? We are going to have 4 of these fields and we want three of them to be about half of the current size and I just don't see how to change it in the definitions file.

Now to the issue. We are also adding multiple classifications to a specific section in the definitions file. Although not a huge problem, when I try to add a second category picker like so:
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);

It throws an error about an item being missing. If I put this same code into it's own section (i.e. not the keyLinkagesSection) everything works fine. Is it not possible to add two category pickers to the same section?

Thanks,

Kalvin

Posted by Community Admin on 26-Sep-2011 00:00

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

Concerning the issues with several classifications in one section: It is possible to add two categories. Make sure you differentiate them as shown.
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);

Best wishes,
Stanislav Velikov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 26-Sep-2011 00:00

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);

Basically two separate category lists that use two separate hierarchical taxonomies. When I select something for each of them (e.g. assistant1 and practicearea1, respectively), publish and then go back in, both the assistant and the practicearea categories are showing practicearea1 as selected, which technically should be impossible. To make matters more interesting, I removed the practicearea category selector all together and tried again and everything worked fine. Then to make it even more interesting, I switched it so practiceareas was first and assistants was second. When I went back in both category selectors were defaulting to the practiceareas. So what's happening is that whatever the last category selector is last on the form is being used to save information for each category (I even tried it with three different categories and the same thing).

So am I missing something or is this another bug with custom modules? Also, what's the difference between fieldname and datafieldname when it comes to categories. Should I be setting that, and if so, to what, the name of the category?

Thanks

Posted by Community Admin on 29-Sep-2011 00:00

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;

Regards,
Stanislav Velikov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed