Module Builder and ID field

Posted by Community Admin on 04-Aug-2018 00:50

Module Builder and ID field

All Replies

Posted by Community Admin on 16-Jan-2013 00:00

Module builder requires to specify ID field. What if I don't need to specify ID value manually? Is there any way to specify ID field as auto-generated GUID of something else?

Maybe Module Builder is not best solution for such modules? Module I'm trying to build does not really represent content items. It is more just for collecting data: users will be entering data (creating new items) and there will be reports generated on top of these items. Everything happens on beck-end, maybe one entry forms for users will be on front end.

Maybe I should better use OpenAccess +  IntasiteModule + Custom Control for such functionality?

Please advice.

Posted by Community Admin on 17-Jan-2013 00:00

Hello,

I am not sure what ID field you refer to. By default every module created with the module builder have a title field and Id is not needed.

Module builder is a way to create customized module when the built in news, vents and blogs modules are not sufficient for certain scenario and yes the module builder don`t allow input on behalf of the user in the frontend except if you create a custom field control to render an input field in the fronted, but for this case maybe the forms module or jobs module will be sufficient.

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

Posted by Community Admin on 17-Jan-2013 00:00

Hi Stanislav,

Thank you for the prompt response, this is very helpful. 

Jobs module is a great example of what I meant about ID field. Jobs module has ID field that is hidden and auto-generated by OpenAccess. Also it doesn't have Title or Urls fields because it doesn't meant to show detailed item information on the front end. Is it correct? I tried to achieve something similar using Module Builder. But, it requires to select some field as ID and manually enter ID value for the each item. Looks like this is how Module Builder works and there is not way to avoid it. That makes Module Builder bad choice for what I need.

Jobs module is too simple for what I need. Is this simple enough to add the following to the Jobs module:

- "Create Item" functionality from the beckend panel (like in Locations or Products modules)
- In admin panel add sidebar panel with widgets (like in Products module). Sidebar widgets would be used to filter items by: categories, tags, custom classification or dates fields. I know how to create custom sidebar widgets for products module. But products module is much more advanced than Jobs and already have side panel with some widgets in it.
- Toolbar with sorting functionality.
- Also, one field will be a link to Sitefinity user. You already replied to me in this post (thanks!) that it is possible to create user selector for beckend functionality. Do you see any problems to to implement similar user selection functionality for the frontend input form?

Thanks again! Denis.

Posted by Community Admin on 18-Jan-2013 00:00

Unless I'm missing something or oversimplifying this but, in your code when you create a new "object" just use Guid.NewGuid() to create the new Id.

Posted by Community Admin on 18-Jan-2013 00:00

Hi Victor, I think you are missing something :)

- You can't generate ID value automatically (for example by Guid.NewGuid())
when Module Builder is used. ID field is always visible in beckend and you have
to specify it manually.
- If you create something similar to Jobs module you don't need Guid.NewGuid(),
because ID field is auto generated by OpenAccess.

Is this correct?

If it is, then Module Builder is not good for what I need. Like I said in my
last post, Jobs module is a good example of what I need (no Title, no URL, ID is auto-generated). Is this simple enough to add the following to the Jobs module:

- "Create Item" functionality from the beckend panel (like in
Locations or Products modules)
- In admin panel add sidebar panel with widgets (like in Products module).
Sidebar widgets would be used to filter items by: categories, tags, custom
classification or dates fields. I know
how to create custom sidebar widgets for products module. But products
module is much more advanced than Jobs and already have side panel with some
widgets in it.
- Toolbar with sorting functionality.
- Also frontend input form should have user selection functionality.

I’m trying to fit what I need into Sitefinity’s modules framework.

Thank you,
Denis.

Posted by Community Admin on 18-Jan-2013 00:00

Now I'm a bit confused.  Module builder doesn't require a field called "ID".  Its done in the database.  Are you referring to the dropdown for "Which field is the identifier of the content?"  This is basically just a text field to allow SF to generate URLs.    The following screenshot shows a complete content type without any sort of "Id".  Does this help?

Posted by Community Admin on 18-Jan-2013 00:00

Yes, when I'm talking about ID field I'm referring to "Which field is the identifier of the content?". On your screenshot question is specified as ID field. So basically there can't be two items with the same questions.

But what if you you have a module where you don't need URLs generated and you can't specify any field as ID? Again, I'm referring to Jobs module as example. It doesn't have URLs and every field can contain duplicates. I have similar requirements. My module will be populated by many different users and they can use same names, messages and even phone numbers (if they share phone, for example home phone).

Posted by Community Admin on 18-Jan-2013 00:00

Where are the users entering this information?  In the Sitefinity "backend" or in a front end control?

Posted by Community Admin on 18-Jan-2013 00:00

I was thinking to provide both ways.

Regular users (registered in Sitefinity) will not be able to browse module items. All they can do it is create new items using entry form (That is probably will be frontend widget). On the other had administrator will be full access to module on beckend side. He should be to create new items also if necessary. As well as: deleting, editing, sorting and filtering.

Also, I don't mind if regular users will use beckend for entering. Only if it possible to restrict module items browsing for them and provide only "create new item" functionality.

Posted by Community Admin on 18-Jan-2013 00:00

The reason I ask is that for front end users, its real simple.  Just create a new short text in the content type and call it "Id" or something and fill it with a guid when saving and use this guid to name the url.

The backend is a little tricky.  What we do is override the view to allow javascript to run on the grid binding.  The using jQuery we would hide the text box for the "id", and fill it with a new Guid.  It would be invisible and users wouldn't know it was there.

Posted by Community Admin on 18-Jan-2013 00:00

Victor, thanks a lot. Now it is much more clear. Maybe you have examples of how to attach this jQuery script to beckend view?

One more quick question: I don't really need publish/draft functionality (just create/delete/update is enough). Is there any way to disable it for modules built with ModuleBuilder?

Do you think that ModuleBuilder would be a better option than building extended version of Jobs module?

Thanks again!
Denis.

Posted by Community Admin on 18-Jan-2013 00:00

There's no way (that I know of) to disable the "lifecycle" apsect of  module builder.

Module builder has its problems, but for rapid development I prefer it to "long way".

The learning curve though is pretty steep as far as manipulating the config files & views and there isn't too much documentation around.  I've been toying with putting some examples together, I just haven't had much time.


Posted by Community Admin on 18-Jan-2013 00:00

Got it. I will try to use ModuleBuilder for my needs.
And will try to find out how to attach jQuery script to beckend view to manipulate with ID field.
Maybe, when you will get a chance you can give me a hint about this :). Thanks again!

Posted by Community Admin on 18-Jan-2013 00:00

A real dirty way to get the jquery on the grid (just to get you started), is to simply go in "Backend Pages" (heed the warning they have here, don't experiment on any production sites, try to use a clean install for playing around) and find the page for the content type you want.

Drag a javascript control onto the page and then link to jquery and to a .js file that you create.

This will allow you to get jscript on the page itself and a good place to begin.

What you eventually want to do is write a custom control based on MasterGridView this way you can hook up the binding events...  But I digress.  






Posted by Community Admin on 02-Mar-2013 00:00

I hooked up custom script to the BackendInsertView:

<scripts>
    <script loadMethodName="insertViewInit" scriptLocation="~/Custom/Scripts/HideID.js" />
</scripts>

right now it contains one function to update ID value:
function insertViewInit(sender, args)
    debugger;                                                         $("label:contains('ID')").parent().find('input[type=text]').filter(':visible:first').text('CD98DE20-00FB-4C08-BBA8-E8D9035FBB17');

I verified that actual input's value text is updated but TextBox value on the page is not changed. I'm I

Posted by Community Admin on 02-Mar-2013 00:00

try .val('CD98DE20-00FB-4C08-BBA8-E8D9035FBB17');

This thread is closed