최신글 특정 카테고리로 갖고 오기
최신글에 특정 게시판 특정 카테고리를 갖고 오는 방법입니다.
카테고리를 추가하되 수정을 최소화하는 방식이니 테스트 하시다가 오류가 발생하면 알려 주세요.
<?=latest("theme/basic", "qa", 5, 25)?>
이게 기본적인 최신글 함수 사용법인데요,
<?=latest("theme/basic", "qa|답변", 5, 25)?>
이런 식으로 게시판 아이디 다음에 '|특정 카테고리'를 붙여 넣습니다.
그러면 뿌리는 부분에서는 끝이 났습니다.
다음으로 /lib/latest.lib.php 파일입니다.
global g5;
이 다음 줄에
list($bo_table, $category) = explode("|", $bo_table);
if($category) $where = " AND ca_name = '".$category."' ";
이 두 줄을 추가합니다.
그런 다음에
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";
이 줄을 찾으신 후에
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0".$where." order by wr_num limit 0, {$rows} ";
이렇게 수정하시면 됩니다.
카테고리를 추가하되 수정을 최소화하는 방식이니 테스트 하시다가 오류가 발생하면 알려 주세요.
<?=latest("theme/basic", "qa", 5, 25)?>
이게 기본적인 최신글 함수 사용법인데요,
<?=latest("theme/basic", "qa|답변", 5, 25)?>
이런 식으로 게시판 아이디 다음에 '|특정 카테고리'를 붙여 넣습니다.
그러면 뿌리는 부분에서는 끝이 났습니다.
다음으로 /lib/latest.lib.php 파일입니다.
global g5;
이 다음 줄에
list($bo_table, $category) = explode("|", $bo_table);
if($category) $where = " AND ca_name = '".$category."' ";
이 두 줄을 추가합니다.
그런 다음에
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";
이 줄을 찾으신 후에
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0".$where." order by wr_num limit 0, {$rows} ";
이렇게 수정하시면 됩니다.
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기
댓글 36개
[http://blog-imgs-44.fc2.com/w/a/r/wareureu/227.gif]
혹시 다른카테고리도 같이 사용할수있는 방법이 없을까요? ^^;
<?=latest("theme/free_board", "fboard1|자유1", 1, 25)?>
<?=latest("theme/free_board", "fboard1|자유2", 1, 25)?>
<?=latest("theme/free_board", "fboard1|자유3", 1, 25)?>
자유2와 자유3을 넣으면 자유1만 3줄로 나오고있습니다 ^^;
게시판은 1개이고 거기에 분류 3종류를 뽑아낼수있는 방법이 있는지 질문드립니다 ㅎㅎ;
<?=latest("theme/free_board", "fboard1|자유1", 1, 25)?>
<?=latest("theme/free_board", "fboard1|자유2", 1, 25)?>
<?=latest("theme/free_board", "fboard1|자유3", 1, 25)?>
$sql~~~ 밑에 echo $sql; 해서 찍어 보세요. 뭐라고 쿼리가 찍히는지.
윗 분과 같은 문제입니다.
특정 카테고리 하나만 불렀을 때는 잘 되는데
같은 페이지 내에
<?=latest("theme/free_board", "fboard1|자유1", 1, 25)?>
<?=latest("theme/free_board", "fboard1|자유2", 1, 25)?>
<?=latest("theme/free_board", "fboard1|자유3", 1, 25)?>
식으로 불러오면 첫번째 불러온 카테고리만 반복해서 3번 나옵니다.
부탁드립니다.
$sql = " select * from {$tmp_write_table} ~~~
이렇게 된 부분이 있습니다. 바로 밑에 echo $sql; 이렇게 했을 때 값이 어떻게 나오는지 알려 주세요.
$sql 에 사용되는 예제나 힌트좀 얻을수있을까요 ^^; 불편드려죄송합니다.
질문이 너무 추상적이라 답변을 할 수가 없네요. 허허허
제가 남긴 답변 때문이라면 /lib/latest.lib.php 이 파일에 있는 $sql이라는 변수 다음에 저걸 찍어 보라는 의미였습니다.
왕계란님 귀한시간내주시고 봐주셔서 정말감사드립니다 ^^
Warning: fwrite(): supplied argument is not a valid stream resource in C:\APM_Setup\htdocs\g5\lib\latest.lib.php on line 87
Warning: fclose(): supplied argument is not a valid stream resource in C:\APM_Setup\htdocs\g5\lib\latest.lib.php on line 88
Warning: include(G5_THEME_PATH/skin/latest/basic/latest.skin.php) [function.include]: failed to open stream: No such file or directory in C:\APM_Setup\htdocs\g5\lib\latest.lib.php on line 93
Warning: include() [function.include]: Failed opening 'G5_THEME_PATH/skin/latest/basic/latest.skin.php' for inclusion (include_path='.') in C:\APM_Setup\htdocs\g5\lib\latest.lib.php on line 93
에러도 없고 반응도 없네요.. 어디가 문제일까요? -_-;;
[http://sir.kr/data/editor/1905/cd1925c888c6c585358ab024829d8a79_1557972738_1913.png]
define('G5_USE_CACHE', true); // 최신글등에 cache 기능 사용 여부
라고 되어 있다면 저 부분을 false로 바꿔서 해 보세요.
게시물이 없습니다. 로 나오네요 ;;
[http://sir.kr/data/editor/1905/cd1925c888c6c585358ab024829d8a79_1557979464_7769.png]
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0".$where." order by wr_num limit 0, {$rows} ";
echo $sql;
이렇게 하면 메인에 쿼리가 우째 나오는지 알려 주세요.
이렇게 나오는데요
특수문자가 들어가서 안 되나 싶어 테스트를 했더니 잘 됩니다.
select * from g5_write_Performed_business where wr_is_comment = 0 AND ca_name = '기업지원' order by wr_num limit 0, 9
이런식으로 나옵니다.
<?=latest("theme/free_board", "fboard1|기업지원", 1, 25)?>
이렇게 하신 건가요?
<?=latest('pic_list', 'free|aaa', 2, 23)?>
<?=latest('pic_list', 'free|bb', 2, 23)?>
저는 이렇게 하니 잘 나옵니다.
http://exam.dothome.co.kr/
/config.php 파일을 열어서
define('G5_USE_CACHE', true); // 최신글등에 cache 기능 사용 여부
라고 되어 있다면 저 부분을 false로 바꿔서 해 보세요.
<<< 이렇게 하니 됩니다.
감사합니다. 예쁘게 잘 출력됩니다.
감사합니다. 혹시 타이틀도 카테고리명 나오게 하려면 어떻게 해야하는지 알려주실 수 있을까요? 게시판명이 나와서요.