We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42960
    • 1 Posts
    Hi,

    I want to create a new resource in web context and display it immediately after creation.
    The creation of the resource is working fine. But when redirecting to the resource I get an 404 error...

    So this is my sample code:
    $data = array();
    $data["createdby"] = $modx->user->id;
    $data["parent"] = 39; // the Id exists
    $data["template"] = 1; // the Id exists
    $data["hidemenu"] = 0;
    $data["isfolder"] = 0;
    $data["menuindex"] = 0;
    $data["published"] = 1; // necessary to display it immediately
    $data["richtext"] = 0;
    $data["searchable"] = 1;
    $data["pagetitle"] = "TestName";
    $data["content"] = "TestContent";
    
    $response = $modx->runProcessor('resource/create', $data);
    


    When I try to open the resource from the manager (via context menu 'View Resource') I get an empty page and empty address bar.
    Also when I try to display a simple link to the resource via [[~[[*id]]]] the link doesn't take the uri, but I'm pretty sure that it should exists (I can see an alias in the manager)

    In my opinion it seems to be a caching problem, because as soon as I either add
    $data["clearCache"] = true;
    or clear the cache in the manager the resource is displayed correctly.

    My questions are:
    Is there a possibility to do this without clearing the cache?
    And if not, is it possible without clearing the WHOLE cache? Or might this lead to any problem with the cache I can't see at the moment?

    Thanks!