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?
-
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
I was wrong, link is not replaced, it is just empty. So rendered page has <a href="">link</a>.
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;
would this work?
[[~256:is=``:then=`256.html`:else=`[[~256]]`]]
-
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
Be sure that you have this tag in the head section of all your templates:
<base href="[[!++site_url]]" />