불가피하게 광고코드를 위젯스킨에 넣을 수 밖에 없어 광고용 위젯스킨 파일을 따로만들었습니다.
<!--@elseif($wi->list_type == "ad")-->
<!--#include("./ad.html")-->
<!--@else-->
<!--#include("./news.html")-->
<!--@end-->
이렇게 해서 list_type을 ad 로 지정하면 ad.html 에 들어있는 광고코드가 출력되게 해 놓았는데요.
광고 타입을 여러개중에 랜덤으로 보여주고 싶은데요.
ad.html , ad1.html, ad2.html 세개 중에 랜덤으로 뽑아서 선택되게 해주고 싶습니다.
댓글 2
ad[0]="<!--#include("./ad.html")-->";
ad[1]="<!--#include("./ad1.html")-->";
ad[2]="<!--#include("./ad2.html")-->";
var ad_banner=Math.floor(Math.random()*(ad.length));
헤더에 자바 스크립트 이렇게 넣으시고
<!--@elseif($wi->list_type == "ad")-->
<script>document.write(ad[ad_banner]);</script>
<!--@else-->
<!--#include("./news.html")-->
<!--@end-->
이렇게 삽입하면 어떨까요
{@
$a = array(0, 1, 2);
shuffle($a);
$b = array_pop($a);
}
<!--@elseif($wi->list_type == "ad" && $b =='0')-->
<!--#include("./ad0.html")-->
<!--@elseif($wi->list_type == "ad" && $b =='1')-->
<!--#include("./ad1.html")-->
<!--@elseif($wi->list_type == "ad" && $b =='2')-->
<!--#include("./ad2.html")-->
<!--@else-->
<!--#include("./news.html")-->
<!--@end-->
이렇게 처리했습니다.