Page 1 of 1

CmsContentManagerUtils from frontend plugin

Posted: Thu May 06, 2021 11:24 pm
by rotezecke
I am working on a plugin (used in a content page, with limited access by a MAMS group) that is supposed to create a content page on the fly.

Code: Select all

$contentops = cmsms()->GetContentOperations();

//this line does not work:
$pagedefaults = CmsContentManagerUtils::get_pagedefaults();

$content_obj = $contentops->CreateNewContent('content');
$content_obj->SetOwner(1);
$content_obj->SetLastModifiedBy(1);
$content_obj->SetActive($pagedefaults['active']);
$content_obj->SetSecure($pagedefaults['secure']);
//and so on
        ...
//then
$error = $content_obj->ValidateData();
if(!$error)
{
  $content_obj->Save();
}		
I cannot load the pagedefaults by following the examples from some admin pages. that does not seem to work from frontend tag. Could someone point me in the right direction? Thanks

Re: CmsContentManagerUtils from frontend plugin

Posted: Sun May 09, 2021 5:22 am
by rotezecke
still dont know how to call CmsContentManagerUtils but this works:

Code: Select all

$cntMgr = \cms_utils::get_module('CMSContentManager');
$tmp = $cntMgr->GetPreference('page_prefs');
if( $tmp ) $pagedefaults = unserialize($tmp);

Re: CmsContentManagerUtils from frontend plugin

Posted: Fri May 14, 2021 12:58 pm
by velden
If you'd added that one line in your UDT it would have worked too:

Code: Select all

$contentops = cmsms()->GetContentOperations();

//this line does not work:
\cms_utils::get_module('CMSContentManager');
$pagedefaults = CmsContentManagerUtils::get_pagedefaults();

Re: CmsContentManagerUtils from frontend plugin

Posted: Fri May 14, 2021 10:56 pm
by rotezecke
Thank you.