Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Don Nehc 69 posts 222 karma points
    Aug 24, 2016 @ 04:14
    Don Nehc
    0

    Umbraco.ServerVariables.js source

    Hello,

    Is there a umbraco.servervariables.js file under umbraco.web.ui.client\src tree?

    Only two showed up after I search:

    /belle/js/umbraco.servervariables.js /common/mocks/umbraco.servervariables.js

    Usually, you have corresponding files in the src that I can modify and grunt to belle, but it doesn't appear to be the case with servervariables.js. I just want to verify.

    Best, -Don

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 24, 2016 @ 06:48
    David Brendel
    0

    Hi Don,

    why do you want to modify the js file in the first place?

    If you want to add some custom server variables that can be done by c# during the application startup.

    Regards David

  • Don Nehc 69 posts 222 karma points
    Aug 24, 2016 @ 13:19
    Don Nehc
    0

    Hello David,

    Thanks for your reply. I don't have to if there is no need. I customized the sources directly, and added additional type, like school type. I am in the process of creating school type editor to save the information. I can't use document/media type, and the logic one seemed to be data type. In data type, it is calling the postsave to save the data, and I want to do the same thing with school type. There probably better ways to do it, I am still learning. Appreciate your help.

    Best, -Don

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 24, 2016 @ 15:35
    David Brendel
    0

    Hi Don,

    DataTypes in Umbraco are used for defining editors that the user can use on DocumentTypes or MediaTypes.

    So if you want to edit some type which is called "School" you could create a new DoucmentType with that name and make them editable in the content tree. Or you implement a custom section to edit these types. Which need of course more developer work.

    Manually changing files which are provided from umbraco isn't a good idea as they get propably overwritten during an upgrade.

    For adding custom stuff to the server variables you could do this:

    ServerVariablesParser.Parsing += Parsing;
    private void Parsing(object sender, Dictionary<string, object> e)
            {
                if (HttpContext.Current == null) throw new InvalidOperationException("HttpContext is null");
                var urlHelper = new UrlHelper(new RequestContext(new HttpContextWrapper(HttpContext.Current), new RouteData()));            
    
                var mainDictionary = new Dictionary<string, object>();
                mainDictionary.Add("calendarBaseUrl", urlHelper.GetUmbracoApiServiceBaseUrl<CalendarApiController>(controller => controller.PostSave(null)));
    
    
                if (!e.Keys.Contains("eventCalendar"))
                {
                    e.Add("eventCalendar", mainDictionary);
                }
            }
    

    Regards David

  • Don Nehc 69 posts 222 karma points
    Aug 25, 2016 @ 12:31
    Don Nehc
    0

    Thank you, David. I understand that I need to create a new type like Document or Media type. However both types are too complex for the school type I need. For school type, I only need couple of input boxes, and save them into a new table. Would it possible to do just that?

    Best, -Don

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Aug 25, 2016 @ 12:46
    David Brendel
    0

    Hi Don,

    not quite sure what you mean with to complex.

    Maybe have a look at the UI-O-Matic package AS it provides CRUD features for objects defined by POCOs.

    So you could create a School class with your properties, add some data annotqtions and then they can be created and stuff in umbraco.

    Regards David

  • Don Nehc 69 posts 222 karma points
    Aug 25, 2016 @ 12:53
    Don Nehc
    0

    Hello David,

    When I look at document/media types, I see there are too many options that you can customize. For the school type, it is fixed with few input boxes. I don't need options to customize. I want a simple form when users create a new school type.

    I will look at the package you suggested.

    Best, -Don

Please Sign in or register to post replies

Write your reply to:

Draft