DEV Community

웹학교
웹학교

Posted on

1 1

그누보드5 최신글 반영하기

그누보드5를 설치하고 특정 게시판의 최신글을 원하는 페이지에 반영하여 보자.

확인사항

1) 최신글 라이브러리
최신글을 처리하는 라이브러리는 /lib/latest.lib.php 파일이다.
이 파일을 열어보면 특정 게시판의 최신글을 어떻게 불러와서 처리하는지 알 수 있다.
이 라이브러리 파일을 최신글 반영하는 페이지 상단에 추가해야 한다.
일반적으로 그누보드5를 설치하면 head.php파일내에 아래와 같이 추가되어 있다.

include_once(G5_LIB_PATH.'/latest.lib.php');
Enter fullscreen mode Exit fullscreen mode

직접 페이지를 만들어 사용할 경우, 이 부분을 확인하여 없다면 추가해 주어야 한다.

2) 특정 위치에 최신글 반영하기
해당 페이지 상단에 최신글 라이브러리 파일을 추가했다면 이제 원하는 위치에 최신글을 반영할 수 있다.

echo latest('스킨명', '게시판아이디', 출력라인수, 제목글자수);
Enter fullscreen mode Exit fullscreen mode
  • 스킨명은 /skin/latest아래에 있거나 테마를 적용한다면 /theme/테마명/skin/latest/아래에 해당 폴더형태로 존재한다. 배포판을 기본 설치하면 basic이라는 스킨과 최근 추가된 pic_block, notice, pic_list 등을 볼 수 있다.
  • 게시판아이디는 관리자화면>게시판관리자에서 만든 게시판 아이디이다. 게시판 주소 /bbs/board.php?bo_table=free형식에서 free가 게시판 아이디이다.
  • 출력라인수는 최신글을 화면에 보여줄 때 몇 개의 게시판 글을 가져올 것인지 결정하는 것이다.
  • 제목글자수는 게시판에 등록된 글의 제목 글자수이다. 긴 제목인 경우, 적절하게 줄여서 보여줄 수 있다.
echo latest('pic_list', 'free', 4, 23); 
Enter fullscreen mode Exit fullscreen mode

이것은 스킨 pic_list을 사용하고 free아이디를 가지는 게시판에서 4개의 글을 가져오는데 제목의 길이는 23자이다.

그누보드5강좌

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay