信息推荐显示

ct-mobile-first
ycc 5 years ago
parent 56b584f0e6
commit 6329909c52

@ -574,7 +574,8 @@ class Information extends CI_Controller
$mobile_template_H1=$this->call_mobile_template_H1($mobile_first_template_path,$this->input->post('is_parent_id'),$this->input->post('ic_author'),$this->input->post('ic_title'),$this->input->post('ic_photo'));//H1模板替换
$mobile_template=str_replace('<!--@HEAD_1@-->', $mobile_template_H1, $mobile_template);
$mobile_template=str_replace('<!--@CUSTOM-CONENT@-->', $this->input->post('ic_content'), $mobile_template);
$template_NEXT=$this->call_mobile_template_NEXT($mobile_first_template_path,$this->input->post('is_id'));
$mobile_template=str_replace('<!--@ARTICLENEXT@-->', $template_NEXT, $mobile_template);
// /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
$mobile_html=$this->config->item('cache')[$this->config->item('site_code')]['cache_path'].$this->input->post('ic_url');
$mobile_html=str_replace("\\", "/", $mobile_html);
@ -603,7 +604,8 @@ class Information extends CI_Controller
$template_H1=$this->call_mobile_template_H1($template_path,$this->input->post('is_parent_id'),$this->input->post('ic_author'),$this->input->post('ic_title'),$this->input->post('ic_photo'));//H1模板替换
$template=str_replace('<!--@HEAD_1@-->', $template_H1, $template);
$template=str_replace('<!--@CUSTOM-CONENT@-->', $this->input->post('ic_content'), $template);
$template_NEXT=$this->call_mobile_template_NEXT($template_path,$this->input->post('is_id'));
$template=str_replace('<!--@ARTICLENEXT@-->', $template_NEXT, $template);
// /travelguide/chinese-zodiac/monthly-fortune-for-dog.htm
$html_path=$this->config->item('cache')[$this->config->item('site_code')]['cache_path'].$this->input->post('ic_url');
$html_path=str_replace("\\", "/", $html_path);
@ -623,19 +625,72 @@ class Information extends CI_Controller
return $this->load->view($mobile_first_template_path.'-h1', $data, TRUE);
}
function call_mobile_template_NEXT($template_path,$is_parent_id,$ic_author,$ic_title,$ic_photo){
function call_mobile_template_NEXT($template_path,$is_id){
$data['detail']=$this->Information_model->Detail($is_id);//信息所属分类,获取信息顶级节点内容
$data['root_detail']=$this->Information_model->get_detail_by_path($data['detail']->is_path,1);//信息所属分类,获取信息顶级节点内容
//how to plan
$data['info_howtoplan']=$this->Information_model->search_by_words($data['root_detail']->is_path,array('how','plan'));
if(empty($data['info_howtoplan'])){//找不到对应信息则显示备用
$data['info_howtoplan']=$this->Information_model->Detail('/travelguide/plan-first-trip.htm');
}
if(!empty($data['info_howtoplan'])){
if(empty($data['info_howtoplan']->ic_photo)){
$images=get_image_url_by_source($data['info_howtoplan']->ic_content);
if(!empty($images)){
$data['info_howtoplan']->ic_photo=$images[1][0];
}
}else{
$data['info_howtoplan']->ic_photo=$this->config->item('site_image_url').$data['info_howtoplan']->ic_photo;
}
}
//best time to visit
$data['info_besttime']=$this->Information_model->search_by_words($data['root_detail']->is_path,array('best','time'));
if(empty($data['info_besttime'])){
$data['info_besttime']=$this->Information_model->Detail('/weather/china-best-times.htm');
}
if(!empty($data['info_besttime'])){
if(empty($data['info_besttime']->ic_photo)){
$images=get_image_url_by_source($data['info_besttime']->ic_content);
if(!empty($images)){
$data['info_besttime']->ic_photo=$images[1][0];
}
}else{
$data['info_besttime']->ic_photo=$this->config->item('site_image_url').$data['info_besttime']->ic_photo;
}
}
//top things to do
$data['info_topthings']=$this->Information_model->search_by_words($data['root_detail']->is_path,array('top','things'));
if(empty($data['info_topthings'])){
$data['info_topthings']=$this->Information_model->Detail('/travelguide/article-top-china-tourist-destination.htm');
}
if(!empty($data['info_topthings'])){
if(empty($data['info_topthings']->ic_photo)){
$images=get_image_url_by_source($data['info_topthings']->ic_content);
if(!empty($images)){
$data['info_topthings']->ic_photo=$images[1][0];
}
}else{
$data['info_topthings']->ic_photo=$this->config->item('site_image_url').$data['info_topthings']->ic_photo;
}
}
//hotel , where to stay
$data['infocategory']=$this->Information_model->Detail($is_parent_id);//信息所属分类获取信息父级节点url title
$data['author']=$this->Operator_model->get_author_nikename($ic_author);//获取作者信息
$data['ic_title']=$ic_title;
$data['ic_photo']=$ic_photo;
$data['info_hotel']=$this->Information_model->search_by_words($data['root_detail']->is_path,array('hotel'));
if(empty($data['info_hotel'])){
$data['info_hotel']=$this->Information_model->search_by_words($data['root_detail']->is_path,array('where','stay'));
}
if(empty($data['info_hotel'])){
$data['info_hotel']=$this->Information_model->Detail('/travelguide/most-beautiful-places.htm');
}
if(!empty($data['info_hotel'])){
if(empty($data['info_hotel']->ic_photo)){
$images=get_image_url_by_source($data['info_hotel']->ic_content);
if(!empty($images)){
$data['info_hotel']->ic_photo=$images[1][0];
}
}else{
$data['info_hotel']->ic_photo=$this->config->item('site_image_url').$data['info_hotel']->ic_photo;
}
}
return $this->load->view($template_path.'-next', $data, TRUE);
}

@ -326,3 +326,10 @@ function get_content_by_url($url) {
curl_close($curl); //关闭CURL会话
return $tmpInfo; //返回数据
}
//获取内容中图片地址
function get_image_url_by_source($source){
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.jpeg|\.png|\.jpg]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern, $source, $match);
return $match;
}

@ -64,6 +64,19 @@ class Information_model extends CI_Model {
return $this->GetList();
}
//根据关键词来搜索内容
function search_by_words($is_path,array $words){
$this->init();
$this->topNum = 1;
$sql_keyword=' AND ( 1=1 ';
foreach ($words as $item) {
$sql_keyword .=" AND ic_url like '%". $this->HT->escape_like_str($item) ."%' ";
}
$sql_keyword.=' ) ';
$this->search =" AND is1.is_path LIKE '$is_path%' ". $sql_keyword;
return $this->GetList();
}
//根据url搜索信息
function search_url($url) {
$this->init();

@ -139,7 +139,7 @@
//移动到任意节点下
function move_by_is_id(is_id) {
is_parent_id = prompt("请输入移动到的节点ID:", "");
is_parent_id = prompt("请输入移动到的节点ID(is_id):", "");
if (is_parent_id != null) {
if (confirm('请确认是否要移动到:' + is_parent_id)) {
var urlReQuery = "<?php echo site_url('information/move_by_is_id'); ?>";

@ -0,0 +1,49 @@
<div class="articlereco">
<div class="recotitlebg">
<h2>Related Articles</h2>
</div>
<?php if (!empty($info_howtoplan)) { ?>
<div class="articlenext">
<a href="<?php echo $info_howtoplan->ic_url; ?>" rel="nofollow"><img
src="<?php echo $info_howtoplan->ic_photo; ?>"
alt="<?php echo $info_howtoplan->ic_title; ?>" class="img-responsive"></a>
<span class="categorycenter"><?php echo $root_detail->ic_url_title; ?></span>
<span class="articlenexttitle"><a
href="<?php echo $info_howtoplan->ic_url; ?>"><?php echo $info_howtoplan->ic_url_title; ?></a></span>
</div>
<?php } ?>
<?php if (!empty($info_besttime)) { ?>
<div class="articlenext">
<a href="<?php echo $info_besttime->ic_url; ?>" rel="nofollow"><img
src="<?php echo $info_besttime->ic_photo; ?>"
alt="<?php echo $info_besttime->ic_title; ?>" class="img-responsive"></a>
<span class="categorycenter"><?php echo $root_detail->ic_url_title; ?></span>
<span class="articlenexttitle"><a
href="<?php echo $info_besttime->ic_url; ?>"><?php echo $info_besttime->ic_url_title; ?></a></span>
</div>
<?php } ?>
<?php if (!empty($info_topthings)) { ?>
<div class="articlenext">
<a href="<?php echo $info_topthings->ic_url; ?>" rel="nofollow"><img
src="<?php echo $info_topthings->ic_photo; ?>"
alt="<?php echo $info_topthings->ic_title; ?>" class="img-responsive"></a>
<span class="categorycenter"><?php echo $root_detail->ic_url_title; ?></span>
<span class="articlenexttitle"><a
href="<?php echo $info_topthings->ic_url; ?>"><?php echo $info_topthings->ic_url_title; ?></a></span>
</div>
<?php } ?>
<?php if (!empty($info_hotel)) { ?>
<div class="articlenext">
<a href="<?php echo $info_hotel->ic_url; ?>" rel="nofollow"><img
src="<?php echo $info_hotel->ic_photo; ?>"
alt="<?php echo $info_hotel->ic_title; ?>" class="img-responsive"></a>
<span class="categorycenter"><?php echo $root_detail->ic_url_title; ?></span>
<span class="articlenexttitle"><a
href="<?php echo $info_hotel->ic_url; ?>"><?php echo $info_hotel->ic_url_title; ?></a></span>
</div>
<?php } ?>
</div>

@ -175,7 +175,10 @@
</nav>
<!--@HEAD_1@-->
<div id="main_content_mobile"><!--@CUSTOM-CONENT@--></div>
<div id="main_content_mobile">
<!--@CUSTOM-CONENT@-->
<!--@ARTICLENEXT@-->
</div>
<footer>
<div class="infotailor">

Loading…
Cancel
Save