Copied to clipboard

Flag this post as spam?

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


  • Adriano Fabri 458 posts 1601 karma points
    Aug 23, 2016 @ 10:29
    Adriano Fabri
    1

    Informations about your package

    Hi, I would try your package in my website. I created an umbraco node called "data" (url: www.mydomain.com/data - doctype: data).

    This will have 4 virtual children:

    www.mydomain.com/data

    www.mydomain.com/data/edu

    www.mydomain.com/data/edu/italy

    www.mydomain.com/data/edu/italy/institute

    www.mydomain.com/data/edu/italy/institute/public

    The "edu, italy, institute and public" are the 4 parameters I must use to filter some data.

    Can I use your package for my need?

    I'm using Umbraco v7.4.3

    Thank you in advance. Best regards.

    Adriano

  • Jonathan Richards 288 posts 1742 karma points MVP
    Aug 23, 2016 @ 11:29
    Jonathan Richards
    102

    Hi Adriano,

    For my own usage I had update the package to allow the use of up to 5 wildcard elements, but hadn't released before because I wanted to test properly before releasing.

    Now that someone requested this functionality, I have completed my tests, and updated AutoRouteTemplate to version 2.0.0.

    Please enjoy

    Jonathan

  • Adriano Fabri 458 posts 1601 karma points
    Aug 23, 2016 @ 14:00
    Adriano Fabri
    1

    Thank you Jonathan, I'll try your package ASAP.

    I hope this is perfect for my need.

    Have a good day Adriano

  • Adriano Fabri 458 posts 1601 karma points
    Aug 24, 2016 @ 16:20
    Adriano Fabri
    1

    Hi Jonathan, the package is what I need and when I tried it in a simple project, it function properly.

    When I try to use it in my custom controller, I don't find the "UmbracoParam()" method.

    I also referenced AutoRouteTemplate in my custom project, but when I try to create the params array, I don't find your method in my custom controller.

    string[] filterParams = this.UmbracoParam();
    

    I tried also this but I suppose I first of all should use a method that sets the url parameters to the label:

    string[] filterParams = new string[4];
    filterParams[0] = model.Content.GetProperty("umbracoParam1").Value.ToString();
    filterParams[1] = model.Content.GetProperty("umbracoParam2").Value.ToString();
    filterParams[2] = model.Content.GetProperty("umbracoParam3").Value.ToString();
    filterParams[3] = model.Content.GetProperty("umbracoParam4").Value.ToString();
    
    string studio = (filterParams.Length > 0) ? @filterParams[0] : "parametro \"studio\" non presente";
    string geo = (filterParams.Length > 1) ? @filterParams[1] : "parametro \"geo\" non presente";
    string istituti = (filterParams.Length > 2) ? @filterParams[2] : "parametro \"istituti\" non presente";
    string istituto = (filterParams.Length > 4) ? @filterParams[4] : "parametro \"istituto\" non presente";
    
    DatiModel.param_studio      = studio;
    DatiModel.param_geo         = geo;
    DatiModel.param_istituti    = istituti;
    DatiModel.param_istituto    = istituto;
    
    return View("Ustat_Test_Custom_Routing", DatiModel);
    

    Can you help me?

    I tried to search also in our.umbraco, but I didn't find what I need...maybe I'm wrong the research.

    Thank you

    Adriano

  • Jonathan Richards 288 posts 1742 karma points MVP
    Aug 24, 2016 @ 16:31
    Jonathan Richards
    1

    Hi Adriano,

    I'm big on using controllers in Umbraco, so yeah I really should make a proper extension method to help access the umbracoParam array that exists in the session variable from a controller. Until I do, and I apologise for not making this simpler, its only laziness on my part.

        public override ActionResult Index(RenderModel model)
        {
            string[] wildcardParameters = UmbracoContext.Current.HttpContext.Items["umbracoParam"] as string[];
            if (wildcardParameters == null)
            {
                //  There are no wildcard parameters
                return CurrentTemplate(model.Content);
            }
            if (wildcardParameters.Length == 1)
            {
                //  They typed only 1 wildcard parameter
                return CurrentTemplate(model.Content);
            }
    
            //  They typed two or more wildcard parameters
            return CurrentTemplate(model.Content);
        }
    

    Hope this helps

    Jonathan

  • Adriano Fabri 458 posts 1601 karma points
    Aug 25, 2016 @ 11:50
    Adriano Fabri
    1

    Hi Jonathan, thank you for your help...I solved with this code.

    string[] filterParams = UmbracoContext.HttpContext.Items["umbracoParam"] as string[];
    
    if (filterParams != null)
    { 
             var studio = (filterParams.Length > 0) ? @filterParams[0] : "parametro \"studio\" non presente";
             var geo = (filterParams.Length > 1) ? @filterParams[1] : "parametro \"geo\" non presente";
             var istituti = (filterParams.Length > 2) ? @filterParams[2] : "parametro \"istituti\" non presente";
             var istituto = (filterParams.Length > 3) ? @filterParams[3] : "parametro \"istituto\" non presente";
             var altro = (filterParams.Length > 4) ? @filterParams[4] : "parametro \"altro\" non presente";
             DatiModel.param_studio = studio;
             DatiModel.param_geo = geo;
             DatiModel.param_istituti = istituti;
             DatiModel.param_istituto = istituto;
             DatiModel.param_altro = altro;
    }
    return View("Ustat_Test_Custom_Routing", DatiModel);
    

    I don't know if this is the best way to do that, but for now it is fine

    Have a nice day.

    Adriano

Please Sign in or register to post replies

Write your reply to:

Draft