Как добавить массовую генерацию в свой раздел?
Внимание данный раздел предназначен только для разработчиков! Вы должны понимать что делаете. Техническая поддержка для данного раздела оказывается только в качестве отдельной, платной услуги.
/** * @param int $article_id The ID of the news article to retrieve. * @param int $language_id The ID of the language to retrieve the article in. * * @return array|null The news article row or null */ public function getNewsArticle($article_id , $language_id) { $query = $this->db->query("SELECT DISTINCT *, (SELECT keyword FROM " . DB_PREFIX . "url_alias WHERE query = 'news_article_id=" . (int)$article_id . "') AS keyword FROM " . DB_PREFIX . "news_article p LEFT JOIN " . DB_PREFIX . "news_article_description pd ON (p.article_id = pd.article_id) WHERE p.article_id = '" . (int)$article_id . "' AND pd.language_id = '" . (int)$language_id . "'"); return $query->row; }
/** * @param int $article_id The ID of the news article to update. * @param array &$data An array containing the new values for the article's columns. * The array keys should match the column names in the * 'news_article_description' table. * @param int $language_id The ID of the language in which to update the article. * * @return void This function does not return a value. */ public function editNewsArticle($article_id , &$data , $language_id){ $query = $this->db->query("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '".DB_DATABASE."' AND TABLE_NAME = '".DB_PREFIX."news_article_description'"); $description_columns = array_map(function($i){return $i['COLUMN_NAME'];} , $query->rows); $fields = []; foreach ($description_columns as $column){ if( isset($data[$column]) ) $fields[] = " `$column` = '". $this->db->escape($data[$column]) ."'"; } $this->db->query("UPDATE " . DB_PREFIX . "news_article_description SET ". implode(',' , $fields ) ." WHERE language_id = '" . (int) $language_id . "' AND article_id = '" . (int) $article_id . "'"); }/** * Returns a mapping of custom routes to their corresponding controller methods. * * This function returns an associative array where the keys are custom routes * and the values are arrays of controller methods that should be executed when * the corresponding route is accessed. * * In this case, the function maps the 'blog/article' route to the 'getNewsArticle' * and 'editNewsArticle' methods. * * @return array An associative array mapping custom routes to their corresponding controller methods. */ public static function custom(){ return [ 'blog/article' => ['getNewsArticle', 'editNewsArticle'], //'blog/blog' => ['getterBlog' , 'setterBlog'] , // etc ]; }
PreviousКак добавить кнопку GPT в новый разделNextКак добавить новую переменную или новое поле, к примеру sku
Last updated