Sorry to report but it wouldn’t work. What am I missing?
I’m using NewsPublisherTagging snippet (same as NewsPublisher with added functionality for tags) to add documents and I figured out it didn’t clear the cache when I added a post (missing parameter), so after adding a document and listing it with Ditto, the link was www.domain.com/103.html (if the documents id was 103). I had to open the document in manager and resave it.
When I added the clearcache parameter, the link for new documents was immediately the right one (www.domain.com/my/path/to/page/alias.html)
Now, when I use the code from NewsPublisherTagging
if($clearcache==1){
include_once $modx->config['base_path']."manager/processors/cache_sync.class.processor.php";
$sync = new synccache();
$sync->setCachepath("assets/cache/");
$sync->setReport(false);
$sync->emptyCache(); // first empty the cache
}
// get redirect/post id
$redirectid = $modx->db->getValue('SELECT id as \'redirectid\' FROM '.$modx->getFullTableName('site_content').' WHERE createdon=\''.$createdon.'\'');
$postid = isset($postid) ? $postid:$redirectid;
// redirect to post id
$modx->sendRedirect( $modx->makeUrl($postid, '', ''));
it still doesn’t work.
If I clear the cache and remove the alias parameter (as shown above), the redirect is still to the www.domain.com/id.html
If anybody wants the link and un/pwd to the site, please, write me PM.
At this moment I’m using
$modx->sendRedirect($modx->config[site_url].'index.php?id='.$postid);
to get the things right.