Inspiration信息推荐

ct-mobile-first
ycc 5 years ago
parent 2f9992fe01
commit 4c9a39f6ae

@ -139,7 +139,8 @@ class Information extends CI_Controller
}
//移动优先的编辑
public function edit_mobile($is_id){
public function edit_mobile($is_id)
{
//查询结构信息
$Structure = $this->InfoStructures_model->Detail($is_id);
if ($Structure == FALSE) {
@ -230,7 +231,6 @@ class Information extends CI_Controller
}
if ($Structure->is_sitecode == 'ct') {
$data['infoTypeList'] = $this->config->item('InfoType_ct');
} elseif ($Structure->is_sitecode == 'ah') {
@ -278,7 +278,6 @@ class Information extends CI_Controller
}
$data['templateList'] = $this->config->item('templates');
//翰特产品类型
$data['productTypeList'] = $this->config->item('ProductType_HT');
@ -342,15 +341,15 @@ class Information extends CI_Controller
}
/**
public function redirect($jumpUrl){
header('HTTP/1.1 301 Moved Permanently');
header($jumpUrl);// 301 跳转到设置的 url
exit();
} */
* public function redirect($jumpUrl){
*
* header('HTTP/1.1 301 Moved Permanently');
*
* header($jumpUrl);// 301 跳转到设置的 url
*
* exit();
*
* } */
public function test_proxy($url = false)
{
$curl = curl_init();
@ -558,7 +557,8 @@ class Information extends CI_Controller
return true;
}
function make_mobile_html($information){
function make_mobile_html($information)
{
$data = array();
//获取移动优先的模板,如果有的话
$mobile_first_template_path = 'mobile_first/' . $this->config->item('site_code');
@ -593,7 +593,8 @@ class Information extends CI_Controller
}
function make_pc_html($information){
function make_pc_html($information)
{
$data = array();
//获取PC的模板如果有的话
$template_path = 'mobile_first/' . $this->config->item('site_code');
@ -627,7 +628,8 @@ class Information extends CI_Controller
file_put_contents($html_path, $template, LOCK_EX);
}
function call_mobile_template_H1($mobile_first_template_path,$is_path,$ic_author,$ic_title,$ic_photo){
function call_mobile_template_H1($mobile_first_template_path, $is_path, $ic_author, $ic_title, $ic_photo)
{
$data['infocategory'] = $this->Information_model->get_detail_by_path($is_path, 1);//信息所属分类,获取信息顶级节点内容
$data['author'] = $this->Operator_model->get_author_nikename($ic_author);//获取作者信息
$data['ic_title'] = $ic_title;
@ -635,9 +637,77 @@ class Information extends CI_Controller
return $this->load->view($mobile_first_template_path . '-h1', $data, TRUE);
}
function call_mobile_template_NEXT($template_path,$is_id){
//通过内容找到第一张图片
function set_photo_content($ic_photo, $ic_content)
{
if (empty($ic_photo)) {
$images = get_image_url_by_source($ic_content);
if (!empty($images)) {
return $images[1][0];
}
} else {
return $this->config->item('site_image_url') . $ic_photo;
}
return '';
}
function call_mobile_template_NEXT($template_path, $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);//信息所属分类,获取信息顶级节点内容
switch (strtolower($data['type_detail']->ic_url_title)) {
case 'inspiration':
//随机获取两个同级节点内容
$random_array = $this->Information_model->random(2, $data['detail']->is_parent_id, array($data['detail']->is_id));
if (!empty($random_array[0])) {
$data['info_howtoplan'] = $random_array[0];
$data['info_howtoplan_root'] = $data['root_detail'];
$data['info_howtoplan']->ic_photo = $this->set_photo_content($data['info_howtoplan']->ic_photo, $data['info_howtoplan']->ic_content);
}
if (!empty($random_array[1])) {
$data['info_besttime'] = $random_array[1];
$data['info_besttime_root'] = $data['root_detail'];
$data['info_besttime']->ic_photo = $this->set_photo_content($data['info_besttime']->ic_photo, $data['info_besttime']->ic_content);
}
//漏斗作用的页面,随机挑选一篇
$random_array = array(
'/travelguide/china-facts.htm',
'/travelguide/article-top-china-tourist-destination.htm',
'/travelguide/most-beautiful-places.htm',
'/weather/china-best-times.htm',
'/travelguide/article-10-movies-to-watch.htm',
'/travelguide/article-culture-shock-in-china.htm',
'/travelguide/article-what-chinese-eat-for-breakfast.htm',
'/travelguide/china-top-10-attractions.htm',
'/travelguide/chinese-food/eight-chinese-dishes.htm',
'/travelguide/china-travel-reopen-restrictions.htm'
);
$data['info_topthings'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
if (!empty($data['info_topthings'])) {
$data['info_topthings_root'] = $data['root_detail'];
$data['info_topthings']->ic_photo = $this->set_photo_content($data['info_topthings']->ic_photo, $data['info_topthings']->ic_content);
}
//文化板块的页面,随机挑选一篇
$random_array = array(
'/travelguide/chinese-zodiac/',
'/travelguide/culture/china-arts-crafts.htm',
'/beijing/forbidden-city/',
'/travelguide/culture/traditionalmedichine.htm',
'/travelguide/chinese-tea/',
'/travelguide/kungfu/',
'/travelguide/culture/china-history.htm',
'/travelguide/chinese-food/',
'/travelguide/chinese-language/'
);
$data['info_hotel'] = $this->Information_model->Detail($random_array[rand(0, count($random_array) - 1)]);
if (!empty($data['info_hotel'])) {
$data['info_hotel_root'] = $data['root_detail'];
$data['info_hotel']->ic_photo = $this->set_photo_content($data['info_hotel']->ic_photo, $data['info_hotel']->ic_content);
}
break;
case 'destination':
//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'])) {//找不到对应信息则显示备用
@ -645,14 +715,7 @@ class Information extends CI_Controller
}
$data['info_howtoplan_root'] = $this->Information_model->get_detail_by_path($data['info_howtoplan']->is_path, 1);//信息所属分类,获取信息顶级节点内容
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;
}
$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'));
@ -661,14 +724,7 @@ class Information extends CI_Controller
}
$data['info_besttime_root'] = $this->Information_model->get_detail_by_path($data['info_besttime']->is_path, 1);//信息所属分类,获取信息顶级节点内容
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;
}
$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'));
@ -677,14 +733,7 @@ class Information extends CI_Controller
}
$data['info_topthings_root'] = $this->Information_model->get_detail_by_path($data['info_topthings']->is_path, 1);//信息所属分类,获取信息顶级节点内容
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;
}
$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'));
@ -696,15 +745,23 @@ class Information extends CI_Controller
}
$data['info_hotel_root'] = $this->Information_model->get_detail_by_path($data['info_hotel']->is_path, 1);//信息所属分类,获取信息顶级节点内容
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;
$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)':
$random_array = array(
'/feedback/',
'/travelguide/how-chinahighlights-selects-your-hotel.htm',
'/travelguide/article-private-tour-vs-group-tour.htm',
'/aboutus/who-recommended.htm',
'/aboutus/no-shops.htm',
'/aboutus/company-history.htm'
);
break;
default:
}
return $this->load->view($template_path . '-next', $data, TRUE);
}
@ -859,8 +916,7 @@ class Information extends CI_Controller
$url = isset($tempu['path']) ? $tempu['path'] : '/';
$pad = $tempu['host'];
$flag = true;
}
//如果传递进来的url没有域名则使用当前站点的信息进行判断
} //如果传递进来的url没有域名则使用当前站点的信息进行判断
else {
$url = str_replace($this->config->item('site_url'), '', $url);
$pad = str_replace('http://', '', $this->config->item('site_url'));

@ -77,6 +77,17 @@ class Information_model extends CI_Model {
return $this->GetList();
}
//在同级别下随机获取N条数据并且排除某些id
function random($topnum,$is_parent_id,array $exclude_ids){
$this->init();
$this->topNum = $topnum;
$this->search = " AND is_parent_id =". $this->HT->escape($is_parent_id);
$exclude_ids_string=implode(',',$exclude_ids);
$this->search .= " AND is_id NOT in ($exclude_ids_string,0)";
$this->orderBy = " ORDER BY NewID() ";
return $this->GetList();
}
//根据url搜索信息
function search_url($url) {
$this->init();

@ -92,7 +92,7 @@
<li class="start-nav-item"><a href="/guilin/tours.htm">Guilin</a></li>
<li class="start-nav-item"><a href="/zhangjiajie/tours.htm">Zhangjiajie</a></li>
<li class="start-nav-item"><a href="/yunnan/tours.htm">Yunnan</a></li>
<li class="start-nav-item"><a href="/huangshantours.htm">Huangshan</a></li>
<li class="start-nav-item"><a href="/huangshan/tours.htm">Huangshan</a></li>
<li class="start-nav-item"><a href="/xian/tours.htm">Xi&#39;an</a></li>
<li class="start-nav-item"><a href="/chengdu/tours.htm">Chengdu</a></li>
</li>

Loading…
Cancel
Save