I have a snippet that creates two documents, sets basic info including aliases, sets them as published and then saves them. However, when the calling snippet/resource tries to create a URL for the new document my error log starts showing:
[2012-06-14 16:20:06] (WARN @ /index.php) `523` was requested but no alias was located.
[2012-06-14 16:20:06] (WARN @ /index.php) `523` was requested but no alias was located.
[2012-06-14 16:20:06] (WARN @ /index.php) `525` was requested but no alias was located.
[2012-06-14 16:20:06] (WARN @ /index.php) `525` was requested but no alias was located.
If I create a new document that just contains
the link is correct. To the best of my knowledge the FURL is unique.
Is this a problem with trying to get the URL before its been saved to the database or something else?
The relevant calling resource code:
[[!createDownloadPage?
&item=`[[!getGet? &key=`downloadID`]]`
&parent=`353`
&ph=`link`
&md5criteria=`[[!getGet? &key=`emailAddress`]]-[[!phpTime? &format=`Uu`]]`
&pagetitle=`Free Download for [[!getGet? &key=`firstName`]] [[!getGet? &key=`lastName`]]`
&firstName=`[[!getGet? &key=`firstName`]]`
&timeout=`1440`
]]
...
[[[[[[~[[+link]]]]]]]]
[[+link]]
Relevant code for createDownloadPage
$linkParams = array (
'parent' => 65,
'timeout' => $timeout,
'md5critera' => $md5criteria . 'link',
'item' => $modx->getOption('item', $scriptProperties)
);
$downloadID = $modx->runSnippet('createDownloadLink', $linkParams);
$contentParams = array(
'firstName' => $firstName,
'downloadLink' => $modx->makeURL($downloadID)
);
$content = $modx->getChunk('freeDownloadPage', $contentParams);
$oDoc = $modx->getObject('modResource', $itemId);
$parentDoc = $modx->newObject('modResource');
$parentDoc->set('alias', sha1($md5criteria));
$parentDoc->set('pagetitle', $oDoc->get('pagetitle') . ' Download');
$parentDoc->set('parent', $parent);
$parentDoc->set('published', 1);
$parentDoc->set('container', 1);
$parentDoc->set('richtext', 0);
$parentDoc->set('template', 10);
$parentDoc->set('publishedon', time());
$parentDoc->set('unpub_date', ($timeout*60) + date('U'));
$parentDoc->save(120);
$doc = $modx->newObject('modResource');
$doc->set('pagetitle', sha1($md5criteria));
$doc->set('alias', sha1($md5criteria));
$doc->set('published', 1);
$doc->set('parent', $parentDoc->get('id'));
$doc->set('searchable', 0);
$doc->setContent($content);
$doc->set('publishedon', time());
$doc->set('cacheable', 0);
$doc->set('template', 10);
$doc->set('unpub_date', ($timeout*60) + date('U'));
$doc->save(90);
$modx->setPlaceholder($ph, $doc->get('id'));
The createDownloadLink snippet is nearly identical. The resources are being correctly created, with aliases and all.
Edit: The link placeholders in the calling document ARE populated correctly, except that a link isn't actually created. Instead, the log shows:
[2012-06-14 17:36:17] (ERROR @ /index.php) `[[+link]]` is not a valid integer and may not be passed to makeUrl()
[ed. note: jmaddington2 last edited this post 14 years, 4 months ago.]