We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20619
    • 4 Posts
    Hi everyone! For example I have a page with id 10, and I put on this page a link to another page, lets say to page 256 in this way [[~256]]. If there is no page with id 256, the link will be transformed to the link to page 10 (same page in other words). So if I have a broken links on my site, I cannot find them by link checkers. Is there any workarounds to prevent this behaviour, so that broken links not being converted?
      • 27708 MODX Staff
      • 2,502 Posts
      Multisanti,

      Redirects that occur for onPageNotFound (an event in MODX) should still send the link checker the 404 header before sending it to the page you have set up as your error_page. What is your error_page set as in your install? Have you looked at the Web Inspector in your browser to see what headers are returned? As I noted. The link checker should detect anything other than a 200.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 20619
        • 4 Posts
        Quote from: smashingred at Jul 22, 2014, 08:16 AM
        Multisanti,

        Redirects that occur for onPageNotFound (an event in MODX) should still send the link checker the 404 header before sending it to the page you have set up as your error_page. What is your error_page set as in your install? Have you looked at the Web Inspector in your browser to see what headers are returned? As I noted. The link checker should detect anything other than a 200.

        I don't speak english well, so I probably poorly explained the problem. I will try to explain it by steps. So I log in into manager account and select page to edit (lets say page with id 10). There is some text on this page and I want some word to be a link to the other page, like this <a href="[[~256]]">link<a>. It's important to notice, that there is no page with id 256 on my site, so link is actually broken. Then I save changes. Everything is perfectly fine till now, link is poining right where I want to (to page with id 256). Now if I open page 10 in browser and see where my link is pointing it appears to point to page 10 instead of page 256. So the link is not broken, it is replaced. Somewhere during page rendering parser replaces broken link with link to current page. No redirect involved. No onPageNotFound event firing. I go back to manager panel and edit this page again, I see that link is still pointing to page 256.
          • 20619
          • 4 Posts
          I was wrong, link is not replaced, it is just empty. So rendered page has <a href="">link</a>.
            • 20619
            • 4 Posts
            I ended up monkey patching makeUrl() function in modcontext.class.php. Replacing this lines:

            $alias= '';
            $this->xpdo->log(xPDO::LOG_LEVEL_WARN, '`' . $id . '` was requested but no alias was located.');

            with

            $alias = $id.".html";
            $found= true;
              • 4172
              • 5,888 Posts
              would this work?

              [[~256:is=``:then=`256.html`:else=`[[~256]]`]]
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 27708 MODX Staff
                • 2,502 Posts
                I am unsure why you are linking to pages that don't exist. Additionally, you should really consider why you are hacking the core. Do you not have an alias set on the ID 256? I am very confused as to what you're trying to accomplish. Perhaps screenshots showing what you're seeing in your edit view and describe what the expected outcome is.
                  Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
                  • 3749
                  • 24,544 Posts
                  Be sure that you have this tag in the head section of all your templates:

                  <base href="[[!++site_url]]" />


                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting