Displaying items by tag: k2

Monday, 21 July 2014 00:00

K2 Module API

The K2 Module is implemented with the plg_jbackend_k2 plugin. It provides functions related to K2 content construction kit for Joomla (items and categories). Here is the list of supported methods.

Get the list of categories

Request parameters

action=get
module=k2
resource=categories
rootid=<R> (optional)
endlevel=<E> (optional)

Example

<end-point>?action=get&module=k2&resource=categories&rootid=<R>&endlevel=<E>

Example (REST format)

<end-point>/get/k2/categories?rootid=<R>

Response

{
    "status": "ok",
    "total": <T>,
    "categories": [
        {
            "id": "<category id>",
            "name": "<category name>",
            "alias": "<category alias>",
            "description": "<category description>",
            "parent": "<parent category id>"
        },
        ...
        {
            "id": "<category id>",
            "name": "<category name>",
            "alias": "<category alias>",
            "description": "<category description>",
            "parent": "<parent category id>"
        }
    ]
}

Notes

If rootid is specified, starts to get subcategories from the specified category id instead of the root category. If endlevel is specified, get categories and all subcategories up to the specified number of level, otherwise get all levels (default).

 

Get a category

Request parameters

action=get
module=k2
resource=categories
id=<N>

Example

<end-point>?action=get&module=k2&resource=categories&id=<N>

Example (REST format)

<end-point>/get/k2/categories/<N>

Response

{
    "status": "ok",
    "id": "<category id>",
    "name": "<category name>",
    "alias": "<category alias>",
    "description": "<category description>",
    "robots": "<meta robots>",
    "author": "<meta author>",
    "language": "<language code>",
    "parent": "<category id>"
}

Notes

Language can be "*" if any.

 

Get the list of items

Request parameters

action=get
module=k2
resource=items
cats=<C1,C2,...,CN> (optional)
subs=<0|1> (optional)
featured=<0|1|2> (optional)
limit=<L> (optional)
page=<P> (optional)
ordering=<field> (optional)

Example

<end-point>?action=get&module=k2&resource=items&cats=<C>&subs=1

Example (REST format)

<end-point>/get/k2/items?cats=<C>&limit=<L>&page=<P>

Response

{
    "status": "ok",
    "total": "<total items>",
    "limit": <pagination limit>,
    "offset": <pagination offset>,
    items: [
        {
            "id": "<item id>",
            "title": "<item title>",
            "alias": "<item alias>",
            "content": "<item content>",
            "featured": "<featured>",
            "images": {
                "image": "<image URL>",
                "imageWidth": "<image width>",
                "image_caption": "<image caption>",
                "image_credits": "<image credits>",
                "imageXSmall": "<image extra small URL>",
                "imageSmall": "<image small URL>",
                "imageMedium": "<image medium URL>",
                "imageLarge": "<image large URL>",
                "imageXLarge": "<image extra large URL>"
            },
            "video": {
                "video": "<video URL>",
                "video_caption": "<video caption>",
                "video_credits": "<video credits>"
            },
        "language": "<item language>",
        "category_id": "<category id>",
        "category_name": "<category name>",
        "author": "<item author>",
        "created": "<item creation date>",
        "modified": "<item modification date>"
        },
        ...
        {
            ...
        }
    ]
}

Notes

Cats:
List of categories id to include

Subs:
0=Do not include sub categories (default), 1=Include sub categories

Featured:
0=Hide, 1=Show (default), 2=Show only featured items

Ordering:
date, rdate, alpha, ralpha, order, rorder, featured, hits, rand, best, modified, publishUp, id (default)

Created and modified date format is YYYY-MM-DD HH:MM:SS

 

Get an item

Request parameters

action=get
module=k2
resource=items
id=<N>

Example

<end-point>?action=get&module=k2&resource=items&id=<N>

Example (REST format)

<end-point>/get/k2/items/<N>

Response

{
    "status": "ok",
    "id": "<item id>",
    "title": "<item title>",
    "alias": "<item alias>",
    "content": "<item content>",
    "featured": "<featured>",
    "images": {
        "image": "<image URL>",
        "imageWidth": "<image width>",
        "image_caption": "<image caption>",
        "image_credits": "<image credits>",
        "imageXSmall": "<image extra small URL>",
        "imageSmall": "<image small URL>",
        "imageMedium": "<image medium URL>",
        "imageLarge": "<image large URL>",
        "imageXLarge": "<image extra large URL>"
    },
    "video": {
        "video": "<video URL>",
        "video_caption": "<video caption>",
        "video_credits": "<video credits>"
    },
    "metadesc": "<meta description>",
    "metakey": "<meta keywords>",
    "metadata": {
        "robots": "<meta robots>",
        "author": "<meta author>",
        "rights": "<meta content rights>",
        "xreference": "<meta external reference>"
    },
    "language": "<language code>",
    "category_id": "<category id>",
    "category_name": "<category name>",
    "author": "<item author>",
    "created": "<item creation date>",
    "modified": "<item modification date>"
}

Notes

Created and modified date format is YYYY-MM-DD HH:MM:SS

Language can be "*" if any.

 

Plugin Settings

jBackend K2 Plugin Settings

The following options are available for user plugin:

Option Description
Full image URL Generate absolute URL (i.e. with domain) for images fields.
Full video URL Generate absolute URL (i.e. with domain) for video fields.
Full img tag URL Force absolute URL (i.e. with domain) in any HTML img tag.
Content in items Include or exclude full content in the items response.