Ka.Info

From KickApps Documentation

Jump to: navigation, search

Ka.Info is a global JavaScript object that is found on every KickApps powered page. It provides information about the user visiting the page, the contents of the page, as well as a host of other things.

You can use Ka.Info in your JavaScript to further customize your KickApps powered community. For example, you could leverage the “USERGENDER” property to display a unique experience for males and females. You could use the “USERAGE” property to block certain pages from people above (or below) a certain age limit.


Syntax:

/**
 * Ka.Info.PROPERTY
 * -or-
 * Ka.Info.Section.PROPERTY
 */
var currentMemberId = Ka.Info.USERID;
var currentMemberPoints = Ka.Info.CurrentMember.POINTS

Contents

Globals

Note: The properties in this section are available on all KickApps pages.

Ka.Info.PROPERTY
AFFILIATESITECATEGORIES
(String) List of categories this site belongs to
AFFILIATESITEENABLEDADS
(String) True of ADs are enabled on this site
AFFILIATESITEID
(String) Represents the Affiliate Site ID
AFFILIATESITETAGLINE
(String) Site tag line
AUTOAPPROVALPHOTOS
(String) True if photos are automatically approved
AUTOAPPROVALCOMMENTS
(String) True if comments are automatically approved
AUTOAPPROVALMSGBOARDPOSTS
(String) True if message board posts are automatically approved
PAGE
(String) Represents the physical page location
PAGETYPE
(String) Represents the type of page being viewed
STATICSERVER
(String) URL of generic KickApps static server
STATICSERVERCSS
(String) URL of KickApps CSS static server
STATICSERVERJS
(String) URL of KickApps JS static server
STATICSERVERIMAGES
(String) URL of KickApps images static server
SITENAME
(String) Represents name of current site
SSOENABLED
(String) True if SSO is enabled on site
SSOREGISTERURL
(String) URL of the SSO registration page
SSOLOGINURL
(String) URL of the SSO login page
USERASTROSIGN
(String) Represents current member's astrological sign
USERID
(String) Represents current member's member ID
USERNAME
(String) Represents current member's user name
USERGENDER
(String) Represents current member's gender
USERAGE
(String) Represents current member's age
USERPHOTO
(String) Path to current member's photo
ROLENAME
(String) Represents current member's role type
AUTOAPPROVECONTENT
(String) True if content is automatically approved
AUDIOPHOTOSERVERPATH
(String) URL of KickApps asset static server
CHATFEATURE
(String) True if chat feature is enabled
R7
(String) Represents current application server
RELNUM
(String) Represents current version of KickApps application
TINYMCELOCALE
(String) Represents TinyMCE locale
SITELANGID
(String) Represents site language ID


Features

Note: The properties in this section are available on all KickApps pages.

Ka.Info.Features.PROPERTY
MEMBERRATING
(Bool) True if member ratings is enabled
VIDEO
(Bool) True if video sharing is enabled
PHOTO
(Bool) True if photo sharing is enabled

Current Member

Note: The properties in this section are available on all KickApps pages.

Ka.Info.CurrentMember.PROPERTY
COUNTRY
(String) The member's country according to their profile
CITY
(String) The member's city according to their profile
STATE
(String) The member's state according to their profile
POSTALCODE
(String) The member's postal code according to their profile
POINTS
(String) How many points the member has accumulated
LEVEL
(String) The level the member is currently at
LASTLOGIN
(String) The last time the member logged in


Default Icons

Note: The properties in this section are available on all KickApps pages.

Ka.Info.DefaultIcons.PROPERTY
VIDEO
(String) The full path of the default video icon
PHOTO
(String) The full path of the default photo icon
AUDIO
(String) The full path of the default audio icon

Message Board

Note: The properties in this section are only available on KickApps Message Board pages.

Ka.Info.MessageBoard.PROPERTY
AUTOAPPROVENEWPOSTS
(String) True if message board posts are automatically approved

Note: The properties below are only available immediately after a new discussion has been created.

NEWDISCUSSIONTHREADID
(String) Represents the ID of the newly created thread
NEWDISCUSSIONTHREADTITLE
(String) Represents the title of the newly created thread

Note: The following properties are not namespaced.

Ka.Info.PROPERTY
ENABLEDREPLIES
(String) Represents how many replies are enabled in this thread
TOTALREPLIES
(String) Represents how many total replies are in this thread
ENABLEDDISCUSSIONS
(String) Represents how many discussions are enabled in this forum
TOTALDISCUSSIONS
(String) Represents how many total discussions are in this forum
PINNEDDISCUSSIONS
(String) Represents how many discussions are pinned in this forum


Profile

Note: The properties in this section are only available on KickApps Profile pages.

Ka.Info.Profile.PROPERTY
ISPRIVATE
(Bool) True if this member has a private profile
PHOTOTHUMBNAIL
(String) URL of the member's profile photo

Note: The following properties are not namespaced.

Ka.Info.PROPERTY
PROFILEID
(String) Represents the member ID to whom this profile belongs to
PROFILENAME
(String) Represents the member name to whom this profile belongs to

Note: The following properties are only available on public profiles.

Ka.Info.PROPERTY
AVERAGERATING
(String) The average rating for this member
RATED
(String) The current member's rating of this member
VOTES
(String) How many votes have been cast on this member
PROFILEADMINTAGS
(String) Represents admin tags for this member


Media Play Page

Note: The properties in this section are only available on KickApps Media Play pages.

Ka.Info.Media.PROPERTY
CONTRIBUTER
(String) Represents the username of the media contributor

Note: The following properties are not namespaced.

Ka.Info.PROPERTY
BLOGTYPE
(String) Represents which type of blog this is
MEDIATYPE
(String) Represents which type of media this is
MEDIAID
(String) ID of the current media item
MEDIANAME
(String) Name of the current media item
MEDIAOWNERID
(String) ID of the member who contributed this media
MEDIAWIDTH
(String) Width of the current media item
MEDIAHEIGHT
(String) Height of the current media item
MEDIAWIDGETID
(String) ID the the current widget containing the current media
MEDIAADMINTAGS
(String) Admin tags for current media
PATHTOMEDIA
(String) Path to the actual media
MEDIAPATHTOPREVIEW
(String) Path to the thumbnail for this media item
AVERAGERATING
(String) Average rating of current media item
RATED
(String) The current members rating of this media item
VOTES
(String) How many votes have been cast on this media item
ORIGVIDEOFORMAT
(String) Represents the original format of this video before transcoding
USERROLE
(String) Represents the role of the current member
MEDIACATEGORIES
(String) List of categories this media item belongs to


Groups Page

Note: The properties in this section are only available on KickApps Group pages.

Ka.Info.Groups.PROPERTY
GROUPCATEGORY
(String) Represents the category this group belongs to
GROUPSUBCATEGORIES
(String) List of subcategories this group belongs to

Note: The following properties are not namespaced.

Ka.Info.PROPERTY
CLUBID
(String) ID of the current group
CLUBNAME
(String) Name of the current group
ISUSERMEMBER
(String) True if the current member is a member of the current group
NUMMEMBERS
(String) Represents number of members in this group

Some Ka.Info Tutorials

The Ka.Info JavaScript object is on all KickApps-powered pages and contains basic information about the site, the logged-in user, and the current page details. You can use this object to extend the capability of your site even further, and target your code for specific pages, sections, or even users.


The Ka.Info object never contains sensitive information such as passwords.

Here is a list of things you can do using Ka.Info:

Target a script to specific page with Ka.Info.Page

Targetting specific pages with your JavaScript has never been easier. Just use the new JavaScript variable Ka.Info.PAGE. It contains a unique identifier for every KickApps page. For example, say you wanted to target some JavaScript for your "My Home" page. Simply follow these steps:

  1. Write your JavaScript code for that page as normal. (We'll wrap an if-statement around it later.)
  2. Surf to your "My Home" page
  3. If you're using Firefox and have the Firebug plugin installed, type this into your console window: Ka.Info.PAGE The response is the unique id string of that page.

    If you don't have Firefox or Firebug you can view the source code of the page and do a search for 'Ka.Info' and look for the value of PAGE. The id string for "My Home" for example, is 'pages/myPlace.jsp'. Copy this value and save it for the next step.
  4. Wrap an if-statement around the code you written in step one, checking if the Ka.Info.PAGE variable is the one you want: if (Ka.Info.PAGE == 'pages/myPlace.jsp'){ //my code for this page here. }

You can also target every page except for a certain page using the != operator, multiple pages using the && operator.

Target a script to a list page for a specific media type with Ka.Info.Page and Ka.Util.getLocationParam

To distinguish a list page in your JavaScript you can use the trusted Ka.Info.PAGE variable paired with a handy dandy utility function called Ka.Util.getLocationParam - a utility method to get the mediaType GET parameter from the URL. Here's an example:

if (Ka.Info.PAGE == "search/searchPage.jsp" && Ka.Util.getLocationParam('mediaType') === 'photo'){
	alert('Photo list page!')
}

Target a script to a specific section of your site with Ka.Info.PAGETYPE

Using the Ka.Info.PAGETYPE variable, you can target your code for certain sections of your site (for example, all Message Board pages):

 if (Ka.Info.PAGETYPE == 'mb'){ //my code for this section here. } 

Just follow the same 4 steps in Ka.Info.PAGE replacing the PAGE reference with PAGETYPE. Note that not all KickApps powered pages have PAGETYPEs.

Detect whether a user is logged-in with Ka.Info.USERID

If the USERID variable is empty - it means no user logged-in. You can wrap your member-specific code around an if statement that checks for this:

 if (Ka.Info.USERID != ''){ //enter code for logged in users } 

Make it complex

Some pages have addition Ka.Info variables unique to that page. For example, all media play pages have an extra variable called Ka.Info.MEDIATYPE which tells you the format of the media ('AUDIO','VIDEO','BLOG'). Using a combination of these variables and the && (and), || (or), == (equals), != (not equas) operators you can really customize a script for almost any case.

Happy coding!

See also: Ka.Info_Tutorials