ArticleImage::AddImageToArticle PHP Method

AddImageToArticle() public static method

Link the given image with the given article. The template ID is the image's position in the template.
public static AddImageToArticle ( integer $p_imageId, integer $p_articleNumber, integer $p_templateId = null ) : void
$p_imageId integer
$p_articleNumber integer
$p_templateId integer Optional. If not specified, this will be the next highest number of the existing values.
return void
    public static function AddImageToArticle($p_imageId, $p_articleNumber, $p_templateId = null)
    {
        global $g_ado_db;
        if (is_null($p_templateId)) {
            $p_templateId = ArticleImage::GetUnusedTemplateId($p_articleNumber);
        }
        $queryStr = 'INSERT IGNORE INTO ArticleImages(NrArticle, IdImage, Number)' . ' VALUES(' . $p_articleNumber . ', ' . $p_imageId . ', ' . $p_templateId . ')';
        $g_ado_db->Execute($queryStr);
        $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
        $cacheService->clearNamespace('article_image');
    }

Usage Example

Example #1
0
 public function setAttachAction()
 {
     $this->_helper->layout->disableLayout();
     try {
         $articleNumber = $this->_getParam('article_number');
         $imageId = $this->_getParam('image_id');
         //$image = $this->_helper->service('image')->find($imageId);
         //$articleImage = $this->_helper->service('image')->addArticleImage($articleNumber, $image);
         ArticleImage::AddImageToArticle($imageId, $articleNumber);
         $this->view->articleImages = $this->_helper->service('image')->findByArticle($this->_getParam('article_number'));
     } catch (\InvalidArgumentException $e) {
         $this->view->exception = $e->getMessage();
     }
 }
All Usage Examples Of ArticleImage::AddImageToArticle