From ea7ccf984d35ea92e929381275213b456561d3be Mon Sep 17 00:00:00 2001 From: ycc Date: Mon, 25 Jan 2021 11:09:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8E=A8=E8=8D=90=E8=A7=84?= =?UTF-8?q?=E5=88=99=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/information.php | 49 ++++++------------------ application/models/information_model.php | 6 +-- application/views/bootstrap3/welcome.php | 2 +- 3 files changed, 16 insertions(+), 41 deletions(-) diff --git a/application/controllers/information.php b/application/controllers/information.php index ee1abcff..857b55a1 100644 --- a/application/controllers/information.php +++ b/application/controllers/information.php @@ -751,7 +751,7 @@ class Information extends CI_Controller function call_mobile_template_NEXT($template_path, $is_id) { - $data['detail'] = $this->Information_model->Detail($is_id);//信息所属分类,获取信息顶级节点内容 + $data['detail'] = $this->Information_model->Detail($is_id); $data['type_detail'] = $this->Information_model->get_detail_by_path($data['detail']->is_path, 0);//信息所属分组,根据分组进行不同推荐 $data['root_detail'] = $this->Information_model->get_detail_by_path($data['detail']->is_path, 1);//信息所属分类,获取信息顶级节点内容 @@ -805,9 +805,13 @@ class Information extends CI_Controller $data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content); } break; - case 'destination': + case 'planing-1(guide)': + case 'planning-2 (decision tips)': + case 'destination': //url的第一段表示地区,根据第一段来搜索相关数据如/beijing/ 而不是根据is_parent_id因为可能信息和线路是在不同的分类下 + $destination_url=trim($data['detail']->ic_url); + $destination_url=substr($destination_url,0,strpos($destination_url,'/',1)+1); //how to plan - $data['info_howtoplan'] = $this->Information_model->search_by_words($data['root_detail']->is_path, array('how', 'plan')); + $data['info_howtoplan'] = $this->Information_model->search_by_words($destination_url, array('how', 'plan'),$data['detail']->is_id); if (empty($data['info_howtoplan'])) {//找不到对应信息则显示备用 $data['info_howtoplan'] = $this->Information_model->Detail('/travelguide/plan-first-trip.htm'); } @@ -816,7 +820,7 @@ class Information extends CI_Controller $data['info_howtoplan']->ic_photo = $this->set_photo_content($data['info_howtoplan']->ic_photo, $data['info_howtoplan']->ic_content); } //best time to visit - $data['info_besttime'] = $this->Information_model->search_by_words($data['root_detail']->is_path, array('best', 'time')); + $data['info_besttime'] = $this->Information_model->search_by_words($destination_url, array('best', 'time'),$data['detail']->is_id); if (empty($data['info_besttime'])) { $data['info_besttime'] = $this->Information_model->Detail('/weather/china-best-times.htm'); } @@ -825,7 +829,7 @@ class Information extends CI_Controller $data['info_besttime']->ic_photo = $this->set_photo_content($data['info_besttime']->ic_photo, $data['info_besttime']->ic_content); } //top things to do - $data['info_topthings'] = $this->Information_model->search_by_words($data['root_detail']->is_path, array('top', 'things')); + $data['info_topthings'] = $this->Information_model->search_by_words($destination_url, array('top', 'things'),$data['detail']->is_id); if (empty($data['info_topthings'])) { $data['info_topthings'] = $this->Information_model->Detail('/travelguide/article-top-china-tourist-destination.htm'); } @@ -833,21 +837,7 @@ class Information extends CI_Controller if (!empty($data['info_topthings'])) { $data['info_topthings']->ic_photo = $this->set_photo_content($data['info_topthings']->ic_photo, $data['info_topthings']->ic_content); } - //hotel , where to stay - $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'); - } - $data['info_hotel_root'] = $this->Information_model->get_detail_by_path($data['info_hotel']->is_path, 1);//信息所属分类,获取信息顶级节点内容 - if (!empty($data['info_hotel'])) { - $data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content); - } - break; - case 'planing-1(guide)': - case 'planning-2 (decision tips)': + //第四篇,随机推荐下方url $random_array = array( '/feedback/', '/travelguide/how-chinahighlights-selects-your-hotel.htm', @@ -856,24 +846,9 @@ class Information extends CI_Controller '/aboutus/no-shops.htm', '/aboutus/company-history.htm' ); - $data['info_howtoplan'] = $this->Information_model->Detail('/travelguide/article-private-tour-vs-group-tour.htm'); - if (!empty($data['info_howtoplan'])) { - $data['info_howtoplan_root'] = $this->Information_model->get_detail_by_path($data['info_howtoplan']->is_path, 1);//信息所属分类,获取信息顶级节点内容 - $data['info_howtoplan']->ic_photo = $this->set_photo_content($data['info_howtoplan']->ic_photo, $data['info_howtoplan']->ic_content); - } - $data['info_besttime'] = $this->Information_model->Detail('/travelguide/how-chinahighlights-selects-your-hotel.htm'); - if (!empty($data['info_besttime'])) { - $data['info_besttime_root'] = $this->Information_model->get_detail_by_path($data['info_besttime']->is_path, 1);//信息所属分类,获取信息顶级节点内容 - $data['info_besttime']->ic_photo = $this->set_photo_content($data['info_besttime']->ic_photo, $data['info_besttime']->ic_content); - } - $data['info_topthings'] = $this->Information_model->Detail('/aboutus/who-recommended.htm'); - if (!empty($data['info_topthings'])) { - $data['info_topthings_root'] = $this->Information_model->get_detail_by_path($data['info_topthings']->is_path, 1);//信息所属分类,获取信息顶级节点内容 - $data['info_topthings']->ic_photo = $this->set_photo_content($data['info_topthings']->ic_photo, $data['info_topthings']->ic_content); - } - $data['info_hotel'] = $this->Information_model->Detail('/aboutus/company-history.htm'); + $data['info_hotel']=$this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]); if (!empty($data['info_hotel'])) { - $data['info_hotel_root'] = $this->Information_model->get_detail_by_path($data['info_hotel']->is_path, 1);//信息所属分类,获取信息顶级节点内容 + $data['info_hotel_root'] = $this->Information_model->get_detail_by_path($data['info_hotel']->is_path, 1); $data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content); } break; diff --git a/application/models/information_model.php b/application/models/information_model.php index a11e89a5..ebafb5ca 100644 --- a/application/models/information_model.php +++ b/application/models/information_model.php @@ -65,15 +65,15 @@ class Information_model extends CI_Model { } //根据关键词来搜索内容 - function search_by_words($is_path,array $words){ + function search_by_words($url,array $words,$self_is_id){ $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 .=" AND ic_title like '%". $this->HT->escape_like_str($item) ."%' "; } $sql_keyword.=' ) '; - $this->search =" AND is1.is_path LIKE '$is_path%' ". $sql_keyword; + $this->search =" AND ic_url LIKE '$url%' ". $sql_keyword.' AND is_id<>'.$self_is_id; return $this->GetList(); } diff --git a/application/views/bootstrap3/welcome.php b/application/views/bootstrap3/welcome.php index 3831e009..2ae39aef 100644 --- a/application/views/bootstrap3/welcome.php +++ b/application/views/bootstrap3/welcome.php @@ -31,7 +31,7 @@
-
ic_title; ?> + +