Custom Module to select pages.

Posted by Community Admin on 03-Aug-2018 18:20

Custom Module to select pages.

All Replies

Posted by Community Admin on 15-Apr-2016 00:00

Hello, I need a little of help, I have several widgets and each of this widgets have to be configured with the same page for example shopping cart page. I want to create a  custom module in where the user could set the shopping cart page and  each of the created widgets take that page as  a default page. I don't know if this can be done with a custom module  or if anyone can give a little idea of how i can do that.

Posted by Community Admin on 15-Apr-2016 00:00

Is use a configuration section to store all my common settings. 

I think you can make one easy with Thunder... Or this... 

docs.sitefinity.com/for-developers-create-a-new-configuration

 

Posted by Community Admin on 18-Apr-2016 00:00

Thanks for yours suggestions Steve. The problem is that we can not use thunder here. And your opinion about use a configuration section i think that doesn't works because we don't know the name of the pages that are created. The first thing that i have to do is that the user create his own pages and then he can use the custom module to select the page where he have the shopping cart widget "for example".

Posted by Community Admin on 18-Apr-2016 00:00

Configuration section is exactly where this should be set, it's the common backend place where all modules store their data... you would store the PageId in it...

Example: /Sitefinity/Administration/Settings/Advanced/Project (Click DefaultSite)
So this is where you can tell the login widgets where the frontend page is (url or ID) if the user needs to be authenticated...

Can you elaborate a bit on what you're doing though?  Custom Module as in custom coded, or Module Builder, etc etc?

Posted by Community Admin on 18-Apr-2016 00:00

To be honest I'don't entirely follow what you are trying to achieve. With that said, what if you created a custom module and used that to store the settings. You could then update the settings in the custom module when a page is created.

Or you could manually create a table in the Sitefinity database for storing the settings. You would than write your own code for querying and updating the settings.

Actually there is no reason the same approach could not be applied to Steve's suggestion of creating a custom configuration. I'm pretty sure that the custom configuration can be saved to using the API. So you could update the custom configration after a page has been saved.

Posted by Community Admin on 20-Apr-2016 00:00

Hello, I finally could do the thing that i want, but now i had a problem, can anyone tell me how i can do a label for put in the main section of the module and also and multiline input for comments? Using a sintax as the below sintax, to this multiline and label appear when the custom module is installed

   var titleField = new TextFieldDefinitionElement(mainSection.Fields)
            
                 ID = "titleFieldControl",
                 DataFieldName = displayMode == FieldDisplayMode.Write ? "Title.PersistedValue" : "Title",
                 DisplayMode = displayMode,
                 Title = "Page Name",
                 CssClass = "sfTitleField",
                 WrapperTag = HtmlTextWriterTag.Li,
             ;

I don't want use the Description property to put "IsRequired", I want put "IsRequired" down the select page field

Posted by Community Admin on 20-Apr-2016 00:00

Hello, I finally could do the thing that i want, but now i had a problem, can anyone tell me how i can do a label for put in the main section of the module and also and multiline input for comments? Using a sintax as the below sintax, to this multiline and label appear when the custom module is installed
   var titleField = new TextFieldDefinitionElement(mainSection.Fields)
            
                 ID = "titleFieldControl",
                 DataFieldName = displayMode == FieldDisplayMode.Write ? "Title.PersistedValue" : "Title",
                 DisplayMode = displayMode,
                 Title = "Page Name",
                 CssClass = "sfTitleField",
                 WrapperTag = HtmlTextWriterTag.Li,
             ;
I don't want use the Description property to put "IsRequired", I want put "IsRequired" down the select page field

Posted by Community Admin on 20-Apr-2016 00:00

Hello, I finally could do the thing that i want, but now i had a problem, can anyone tell me how i can do a label for put in the main section of the module and also and multiline input for comments? Using a sintax as the below sintax, to this multiline and label appear when the custom module is installed
   var titleField = new TextFieldDefinitionElement(mainSection.Fields)
            
                 ID = "titleFieldControl",
                 DataFieldName = displayMode == FieldDisplayMode.Write ? "Title.PersistedValue" : "Title",
                 DisplayMode = displayMode,
                 Title = "Page Name",
                 CssClass = "sfTitleField",
                 WrapperTag = HtmlTextWriterTag.Li,
             ;
I don't want use the Description property to put "IsRequired", I want put "IsRequired" down the select page field

Posted by Community Admin on 21-Apr-2016 00:00

Someone can helpme?

Posted by Community Admin on 21-Apr-2016 00:00

I'm sorry, I have no experience with Custom Modules :/  I do everything I can through the Dynamic Types and the Module builder (safer and easier IMO).

Posted by Community Admin on 28-Apr-2016 00:00

Hello Edwin,

I would have to agree with Steve on this one. Module builder's dynamic modules are safer and easier to create, + they expose many hooks where you can plug in custom logic.

If you decide to continue with the custom static module you can check the following forum thread on how to add comments to a static module:

http://www.sitefinity.com/developer-network/forums/general-discussions-/how-to-add-commets-in-my-custom-module

On the positioning of the "IsRequired" text - You can use the Example property in the constructor of your PageFieldDefinition. The Example's markup is placed below the page selector button. Here is a sample extracted from the Blogs definitions with Example field added:

var defaultPage = new PageFieldElement(mainSection.Fields)
            
                Title = "DefaultPage",              
                ResourceClassId = typeof(BlogResources).Name,
                ID = "defaultPage",
                FieldName = "DefaultPageId",
                DataFieldName = "DefaultPageId",
                DisplayMode = FieldDisplayMode.Write,
                WebServiceUrl = "~/Sitefinity/Services/Pages/PagesService.svc/",
                CssClass = "sfFormSeparator",
                Example = "IsRequired",
            ;
            mainSection.Fields.Add(defaultPage);

Regards,
Pavel Benov
Telerik
 
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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed