Skip to content

Instantly share code, notes, and snippets.

@justenj
Last active February 26, 2016 18:49
Show Gist options
  • Save justenj/3e525403af46fcb2a27e to your computer and use it in GitHub Desktop.
Save justenj/3e525403af46fcb2a27e to your computer and use it in GitHub Desktop.
<?php
$end = '<div class="clear"> </div>';
$ress = $modx->getCollection('modResource', array('parent' => 43, 'content:LIKE' => '%'.$end.'%'));
$arIds = array();
foreach ($ress as $res) {
$arIds[] = $res->id;
}
$ress = $modx->getCollection('modResource', array('parent' => 43, 'content:LIKE' => '%div class="slider_lynx%', 'id:IN' => $arIds));
// print count($ress);
foreach ($ress as $res) {
// print '<a href="http://ezois.nermolrx.bget.ru/manager/?a=resource/update&id=' . $res->id . '" target="_blank">' . $res->pagetitle . '</a>';
// print "<br>";
$start = strpos($res->content, '<div class="slider_lynx');
$end = strpos($res->content, '<div class="clear"> </div>');
$content = substr($res->content, $start, $end + 37 - $start);
$res->content = str_replace($content, '[[$promo_content_slider]]', $res->content);
// print $res->content;
$res->save();
// $arContent = explode('upload/', $content);
// $arSrc = array();
// foreach ($arContent as $index => $img) {
// if ($index === 0) continue;
// $end_img = strpos($img, '"');
// $src = 'upload/' . substr($img, 0, $end_img);
// $arSrc[] = array('MIGX_id' => $index, 'image' => $src);
// }
// $res->setTVValue('migx_content_slider', json_encode($arSrc));
// print "\n\n\n\n\n\n====================================\n\n\n\n\n";
// break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment