posted time Created time: 2015-07-18 posted time Last updated time:

Latest Blog Articles for Body of Categories

Latest Blog Articles part is to show the list of blog posts with the title and description. This part is used in Blog Top page and Blog Category Pages.

Appearance and usage of Latest Blog Articles Component

The Latest Blog Articles for Blog Body Component is the body of the Blog Category Page. It lists the blog entries in the category like below.

Latest blog entries

This component shows following elements of the blog articles.

  • Blog title
  • Description of the article
  • Updated date and created date
  • Tags of the article

This component implements the pagination function. Therefore if the number of the blog entries in the category is too many to locate them in a page, it uses pagination.

In order to use this component, the Top Template have to implement the "next" and "prev" setting with meta tag of the Html.

Source code of Latest Blog Articles Component

The source code of Latest Blog Articles consists of Html code, Server side program, and Style Sheet. This component is ready for paging. Therefore, this component implements program for the paging function.

Html code

The Html code of this component is below.

This Html code uses the "@cms_page" variable. This variable has information about the title and description of the blog posts. In addition to that, they has information about the keyword tags, which the article has.

The variable is made in the server side program.

Server side program

The server side program of this component is below.

The server side program create the "@cms_page" variable, which is used in the Html code. It is created by following operations.

Set blog posts number to show in a page

At first, set the maximum number of the blog posts in a page as the "$limit" variable.

Get latest articles

The "getLatest()" function returns the base of "@cms_page" variable which is made by SQL query.

Get Total record number

In order to make pagination navigation part, the total record number is necessary. The "getTotalRecords()" function returns it. The number is calculated by the SQL query.

Create paging navigation array variable

The "Paging.getNavi()" function returns the "$navi" variable. This variable includes navigation array for pagination.

The function is available by including the "/include/paging.alns" script at the first part of this program.

Get current page's directory

The "getUrl()" function returns the url of the first page. The url of pages after number 1 is string added the page number to the first page's url.

Set url of the page navigation array variable

Set the url of the pages except the first page.

Set keyword tags to the blog post variable

The "getPageTags()" function returns records of the keyword tags which the page has.

Server side program for paging

The server side program for paging function is below.

This component supports pagination. Therefore the program to return the total number of pages is necessary.

This program get the total records number, and calculate the number of pages.

Style Sheet

The Style Sheet of this component is below.


Go to Top