Hello.
I create new resource with my snippet.
After success creation I need to redirect to created resource.
To generate redirect url I user $modx->makeURL();
But url is empty.
Here is my code:
<?php
if(isset($_REQUEST[’status’])){
if(isset($_REQUEST[’broadcast_name’])){
$broadcast = $modx->newObject(’modResource’);
$broadcast->set(’pagetitle’,$_REQUEST[’broadcast_name’]);
$broadcast->set(’description’,$_REQUEST[’broadcast_description’]);
$broadcast->set(’published’,1);
$broadcast->set(’template’,2);
$broadcast->set(’searchable’,1);
$broadcast->set(’cacheable’,1);
$broadcast->set(’createdby’,$modx->user->get(’id’));
$broadcast->set(’publichedby’,$modx->user->get(’id’));
$broadcast->set(’parent’,2);
if($broadcast->save()===true){
$id=$broadcast->get(’id’);
$url = $modx->makeUrl($id,’’,’’,’full’);
print_r($url." ".$id); // here url is empty, but id is correct.
}
}
}
if use this method:
header(’Location:
http://turncamon.com/index.php?id=’.$broadcast->get(’id’));
all works fine.
But I want do this with modx api.
If anybody know what could be the reason, tell please.