Copied to clipboard

Flag this post as spam?

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


  • Lee 1130 posts 3088 karma points
    Dec 10, 2009 @ 12:09
    Lee
    0

    URL's

    Hey - Using your package and its great =)

    One question I have is about the URL's?  I am using Alphabet folders, and the URLs are being published as below

    /a/a-page-name.aspx
    /r/repeat-page.aspx
    /z/zoo-information.aspx

    Is there any way to over ride this, or make a URL like so?  As they are all part of one section?

     

    /mycustomname/a-page-name.aspx
    /mycustomname/repeat-page.aspx
    /mycustomname/zoo-information.aspx

     

    Thanks

  • Lee 1130 posts 3088 karma points
    Dec 11, 2009 @ 10:31
    Lee
    0

    Guess not :(

  • Comment author was deleted

    Dec 11, 2009 @ 10:34

    Maybe you could use the umbracourlname property, and fill that on creation of the new pages

    http://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracourlname

  • Comment author was deleted

    Dec 11, 2009 @ 10:34
  • Stefan Kip 1614 posts 4131 karma points c-trib
    Dec 11, 2009 @ 11:54
    Stefan Kip
    0

    What I'm doing at the moment:

    I have a 'folder' document inside the content tree called 'partners', but I don't want the url to be /partners/some-partner.
    So I created an instance of ApplicationBase which sets the property umbracoUrlName like /some-partner.
    The code:

    public PartnerBase()
    {
        Document.AfterPublish += new Document.PublishEventHandler(Document_AfterPublish);
    }

    void Document_AfterPublish(Document doc, PublishEventArgs e)
    {
        doc.getProperty("umbracoUrlName").Value = string.Format("/{0}", GenerateSlug(doc.Text));
        doc.Publish(doc.User);
    }

    The GenerateSlug method:

    static string GenerateSlug(string phrase)
    {
        phrase = phrase.ToLower();
        phrase = Regex.Replace(phrase, @"[^a-z0-9\s-]", string.Empty); // invalid chars
        phrase = Regex.Replace(phrase, @"\s+", " ").Trim(); // convert multiple spaces into one space
        phrase = phrase.Substring(0, phrase.Length <= 45 ? phrase.Length : 45).Trim(); // cut and trim it
        phrase = Regex.Replace(phrase, @"\s", "-"); // hyphens
        return phrase;
    }
  • Adin 11 posts 31 karma points
    Dec 31, 2010 @ 01:10
    Adin
    0

    I tried but this doesn't work for me maybe i should debug it but that requires me to setup environment on my machine.

Please Sign in or register to post replies

Write your reply to:

Draft