给SeaCMS增加一个相似名称+同导演+同演员三个条件同时存在的标签
在内容页调用相关影片时,常用的标签有
rel=r 像似名称影片
rel=d 同导演影片
rel=y 同演员影片
这三个标签在一个循环内只能单独使用,当使用rel=r
调用相似名称影片的数量非常少时,可能无法填满预留位置,严重影响页面美观。
解决方法:增加一个支持相似名字+同导演+同演员三个条件同时存在的标签
动态模式:
编辑 /include/main.class.php
文件第1379行
$rel_d = explode ( ",", str_replace ( " ", ",", $zrel ['0']->v_director ) );
$rel_y = explode ( ",", str_replace ( " ", ",", $zrel ['0']->v_actor ) );
$rel_r = substr ( $zrel ['0']->v_name, 0, 9 );
unset ( $zrel );
switch ($vrel) {
case "d" :
foreach ( $rel_d as $value ) {
$d_str .= "'%" . $value . "%'#";
}
$d_str = rtrim ( $d_str, "#" );
$d_str = str_replace ( "#", " or m.v_director like ", $d_str );
$whereRel = " and m.v_director like $d_str ";
break;
case "y" :
foreach ( $rel_y as $value ) {
$y_str .= "'%" . $value . "%'#";
}
$y_str = rtrim ( $y_str, "#" );
$y_str = str_replace ( "#", " or m.v_actor like ", $y_str );
$whereRel = " and (m.v_actor like $y_str) ";
break;
case "r" :
$whereRel = " and m.v_name like '%$rel_r%'";
break;
下方插入
case "l":
foreach ( $rel_d as $value ) {
$d_str .= "'%" . $value . "%'#";
}
$d_str = rtrim ( $d_str, "#" );
$d_str = str_replace ( "#", " or m.v_director like ", $d_str );
foreach ( $rel_y as $value ) {
$y_str .= "'%" . $value . "%'#";
}
$y_str = rtrim ( $y_str, "#" );
$y_str = str_replace ( "#", " or m.v_actor like ", $y_str );
$whereRel=" and (m.v_name like '%$rel_r%' or (m.v_director like $d_str) or (m.v_actor like $y_str) )";
break;
静态模式:
编辑 /include/main2.class.php
文件第1372行
$rel_d = explode ( ",", str_replace ( " ", ",", $zrel ['0']->v_director ) );
$rel_y = explode ( ",", str_replace ( " ", ",", $zrel ['0']->v_actor ) );
$rel_r = substr ( $zrel ['0']->v_name, 0, 9 );
unset ( $zrel );
switch ($vrel) {
case "d" :
foreach ( $rel_d as $value ) {
$d_str .= "'%" . $value . "%'#";
}
$d_str = rtrim ( $d_str, "#" );
$d_str = str_replace ( "#", " or m.v_director like ", $d_str );
$whereRel = " and m.v_director like $d_str ";
break;
case "y" :
foreach ( $rel_y as $value ) {
$y_str .= "'%" . $value . "%'#";
}
$y_str = rtrim ( $y_str, "#" );
$y_str = str_replace ( "#", " or m.v_actor like ", $y_str );
$whereRel = " and m.v_actor like $y_str ";
break;
case "r" :
$whereRel = " and m.v_name like '%$rel_r%'";
break;
下方插入
case "l":
foreach ( $rel_d as $value ) {
$d_str .= "'%" . $value . "%'#";
}
$d_str = rtrim ( $d_str, "#" );
$d_str = str_replace ( "#", " or m.v_director like ", $d_str );
foreach ( $rel_y as $value ) {
$y_str .= "'%" . $value . "%'#";
}
$y_str = rtrim ( $y_str, "#" );
$y_str = str_replace ( "#", " or m.v_actor like ", $y_str );
$whereRel=" and (m.v_name like '%$rel_r%' or (m.v_director like $d_str) )";
break;