1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Module Builder and ID field

Module Builder and ID field

16 posts, 0 answered
  1. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    16 Jan 2013
    Link to this post

    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.

  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    17 Aug 2017
    17 Jan 2013
    Link to this post
    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
  3. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    17 Jan 2013 in reply to Stanislav Velikov
    Link to this post

    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.

  4. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    18 Jan 2013 in reply to Denis
    Link to this post

    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.

  5. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    18 Jan 2013 in reply to Victor
    Link to this post
    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.
  6. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    18 Jan 2013 in reply to Denis
    Link to this post
    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?
  7. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    18 Jan 2013 in reply to Victor
    Link to this post

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

  8. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    18 Jan 2013 in reply to Denis
    Link to this post
    Where are the users entering this information?  In the Sitefinity "backend" or in a front end control?
  9. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    18 Jan 2013 in reply to Victor
    Link to this post

    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.

  10. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    18 Jan 2013 in reply to Denis
    Link to this post
    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.
  11. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    18 Jan 2013 in reply to Victor
    Link to this post

    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.

  12. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    18 Jan 2013 in reply to Denis
    Link to this post

    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.


  13. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    18 Jan 2013 in reply to Victor
    Link to this post

    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!

  14. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    18 Jan 2013 in reply to Denis
    Link to this post

    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.  






  15. Denis
    Denis avatar
    105 posts
    Registered:
    27 Feb 2009
    02 Mar 2013 in reply to Victor
    Link to this post
    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
  16. Victor
    Victor avatar
    94 posts
    Registered:
    15 Jun 2011
    02 Mar 2013 in reply to Denis
    Link to this post

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

16 posts, 0 answered