$content_obj->ValidateData() returns error when it should not
Posted: Fri May 14, 2021 11:15 pm
my plugin that creates pages on the fly is coming along but it has at least one flaw. The code to create the page is pretty much a clone from the admin page. However, I am setting the alias
$newfieldname is a MAMS property, just been tested whether or not it is a new property, or existing one. That works fine. And it is highly unlikely that the MAMS property will ever be an existing page alias, however, I'd prefer to test it at this point (but don't know how). I cannot use this one:
as it always returns an error:
1) can I test whether or not a page alias already exists, and
2) why would $content_obj->ValidateData(); report the error, when $content_obj->Save(); works just fine?
The pages that I end up creating are exactly as I want them to be, short of the missing error/alias check. Thank you.
Code: Select all
...
$content_obj->SetAlias($newfieldname);
Code: Select all
$error = $content_obj->ValidateData();
So i guess I have two questions:[0] => An error occurred parsing content blocks (look for an invalid template, or duplicated content blocks)
[1] => No default content block was detected in this template. Please ensure that you have a {content} tag in the page template.
1) can I test whether or not a page alias already exists, and
2) why would $content_obj->ValidateData(); report the error, when $content_obj->Save(); works just fine?
The pages that I end up creating are exactly as I want them to be, short of the missing error/alias check. Thank you.