Skip to content

Instantly share code, notes, and snippets.

@AlexDel
Created January 23, 2012 16:15
Show Gist options
  • Save AlexDel/1664037 to your computer and use it in GitHub Desktop.
Save AlexDel/1664037 to your computer and use it in GitHub Desktop.
<? function video_preview()
{
$this->load->model('text/text_model');
$params = array(
'node_tree_id' => 22,#заменить на требуемое
'from_subfolders' => 1,
'full_text' => 1,
'limit' => 4
);
$cat = $this->text_model->get_category($params);
$texts = $cat['texts'];
$data['previews'] = array();
foreach ($texts as $t)
{
$preview = array();
$preview['name'] = $t['txt_title'];
$preview['date'] = $t['txt_publish_starth'];
if(preg_match('/<img.*?src=[\'|"](.*?)[\'|"]/sixu', $t['txt_lead'], $match))
{
$preview['image'] = $match[1];
}
#с учетом того, что iframe движком не вставляется. логично использовать старый код
if(preg_match('/<object.*?data="http:\/\/www\.youtube\.com\/v\/(.*?)\?/sixu', $t['txt_text'], $match_video))
{
$preview['video'] = $match_video[1];
}
array_push($data['previews'],$preview);
}
$this->load->view('text/video_view',$data);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment