Skip to main content

Posts

Showing posts from May, 2011

How to update an article

$program = new mxProgram;
$program->getBy(array('id' => $programCodeOrID, 'code' => array($programCodeOrID, '=', 'OR')));
$article = $program->getArticle($recId);
$article->fieldname1 = $value1;
$article->fieldname2 = $value2;
$articleupdate = $article->update();

How to insert an article

$program = new mxProgram;
$program->getBy(array('id' => $programCodeOrID, 'code' => array($programCodeOrID, '=', 'OR')));
$article = $program->getEmptyArticle();
$article->fieldname1 = $value1;
$article->fieldname2 = $value2;
$articleAdd = $program->addArticle($article);

How to get the article's file/blob attribute

$fieldset = new mxFieldset();
$fieldset->getBy( array( 'frmid' => $formsetid, 'column' => 'attachment1'));
if( 0 == $fieldset->id) {
  echo 'error: ' . $fieldset->getLastErrorMessage();
  return;
}

$blob = $article->getBlobData( $fieldset, true);
if( $blob && 0 id ) {
  $blob->contenttype data size filename <==== The original file name when being uploaded.
}

[MXAE] How To Get Articles (And Print Out)

To list an article (or articles) using MXAE-API.

//one article
$program = new mxProgram;
$program->getBy(array('id' => $programCodeOrID, 'code' => array($programCodeOrID, '=', 'OR')));
$article = $program->getArticle($recId);


//articles (more than one)
$arcs = $prog->getArticles(array('category' => $fVal, 'orderby' => ' foreach($arcs as $theArcs) {
echo "{$theArcs->nationality}";
echo "{$theArcs->dateofbirth->format("d-m-Y")}"; //date format
}



//total articles
$totalArticle = $program->getArticleCount();