Custom Module to select pages.
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.
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
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".
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?
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.
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
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
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
Someone can helpme?
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).
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);