method set documentation in bbn\Appui\Cms
Sets content, title, start and end for the given URL.
function($url, string $title = '', string $content = '', string $excerpt = '', string $start = NULL, string $end = NULL, array $tags = NULL, string $id_type = NULL, string $id_media = NULL, string $id_option = NULL)
{
string $title = '',
string $content = '',
string $excerpt = '',
string $start = null,
string $end = null,
array $tags = null,
string $id_type = null,
string $id_media = null,
string $id_option = null
): bool
{
if (is_array($url)) {
$tmp = $url;
foreach ($tmp as $k => $v) {
$$k = $v;
}
}
if (!is_string($url) || empty($url)) {
throw new Exception(X::_("The CMS article MUST have a URL"));
}
if ($note = $this->getByUrl($url, true)){
$id_note = $note['id'];
}
if (!empty($id_note)) {
$cfg = $this->get($id_note);
}
elseif (!($cfg = $this->getByUrl($url, true))) {
throw new Exception(X::_("Impossible to find the article with URL") . ' ' . $url);
}
$change = 0;
if (($cfg['title'] !== $title) || ($cfg['content'] !== $content) || ($cfg['excerpt'] !== $excerpt)) {
$change += (int)$this->setContent($cfg['id_note'], $title, $content, $excerpt);
}
if (($cfg['start'] !== $start) || ($cfg['end'] !== $end)) {
$change += (int)$this->setEvent($cfg['id_note'], [
'start' => $start,
'end' => $end
]);
}
if (is_array($tags)) {
$change += (int)$this->note->setTags($cfg['id_note'], $tags);
}
if ($id_type && ($cfg['id_type'] !== $id_type)) {
$change += (int)$this->setType($cfg['id_note'], $id_type);
}
if ($id_option && ($cfg['id_option'] !== $id_option)) {
$change += (int)$this->setOption($cfg['id_note'], $id_option);
}
if ($id_media !== $cfg['id_media']) {
if ($id_media) {
$change += (int)$this->setDefaultMedia($id_note, $id_media);
}
else {
$change += (int)$this->unsetDefaultMedia($id_note);
}
}
if ($change) {
$this->cacheDelete($cfg['id_note']);
}
return $change ? true : false;
}
Sets content, title, start and end for the given URL. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2023
BBN Solutions