Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Apr 22, 2010 @ 16:52
    Ismail Mayat
    1

    Report no href as broken link

    Darren,

    Awesome package.  Just one thing in the editor if you create a link to umbraco page.  if the target page is then unpublished or deleted then the link is written out as <a href="">some text</a> the broken link does not report it as broken.  I have downloaded source code and just wanted to know where i need to change the code to test if we have href and if not report it as broken link.

    Many thanks.

     

    Ismail

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Apr 23, 2010 @ 09:53
    Darren Ferguson
    0

    Hey Ismail,

    Remind me to have a look at the beginning of next week - today is nuts!

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Apr 23, 2010 @ 10:14
    Ismail Mayat
    0

    Darren,

    Took a quick look at the source and made some changes to the code namely in publishevent.cs:

    p.run();
                int internalBrokenCounter = 0;
                if (p.Status)
                {
                    String pageData = p.Content;
                    MatchCollection links = Regex.Matches(pageData, @"href\=""(.*?)""");
                    foreach (Match link in links)
                    {
                        String linkValue = link.Groups[1].Value;
                        if (linkValue.IndexOf("://") == -1)
                        {
                            if (linkValue.IndexOf("/") == 0)
                            {
    
                                linkValue = linkValue.Substring(1);
                                linkValue = baseUrl + linkValue;
                            }
                            else if(linkValue==string.Empty)
                            {
                                linkValue = "/brokenInternalLink" + internalBrokenCounter + "-page-" + docId;
                                if (root.IndexOf("/") == 0) { root = root.Substring(1); }
                                linkValue = root.Substring(0, root.LastIndexOf("/") + 1) + linkValue;
                                internalBrokenCounter++;
                            }
                            else
                            {
    
                                if (root.IndexOf("/") == 0) { root = root.Substring(1); }
                                linkValue = root.Substring(0, root.LastIndexOf("/") + 1) + linkValue;
                            }
    
                        }
                        l.Add(linkValue);
                    }
                }

    I can now see the link in the report although I have had to blag the actual link because the links are grabbed from published page and for umbraco broken links we just have broken empty href so no way of actually knowing what it is.  

    However I am passing through in the made up url the page id that has broken links what i was thing was maybe updating the xslt that lists the broken links so that i get the page id then get the document and maybe loop through all properties that are rich text get links and from there determine the targets and write those out as part of the broken link report thus giving the end user information as to which page is deleted or unpublished.

    Many thanks for the prompt reply.

    Awesome package by the way love it voted up!

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft