Skip to content

Instantly share code, notes, and snippets.

@Fi1osof
Created January 9, 2013 20:13
Show Gist options
  • Save Fi1osof/4496395 to your computer and use it in GitHub Desktop.
Save Fi1osof/4496395 to your computer and use it in GitHub Desktop.
<?php
$modx->setLogTarget('HTML');
print '<pre>';
$topic = $modx->modblog->getTopic(289);
$blogs = $modx->modblog->getBlogs(); // Получаем все блоги
$blogtopics = array();
foreach($blogs as $blog){
// Создаем объект Топик-Блог (еще не сохраняем)
$tb = $modx->newObject('SocietyBlogTopic');
$tb->addOne($blog);
$blogtopics[] = $tb;
}
// Добавляем к топику все связки Топик-Блог (еще не сохраненные)
$topic->addMany($blogtopics);
// Сохраняет все связки, которых еще не существует
$topic->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment