Obtaining Article Information, Links, and HTML Fragments
1. Getting raw article information
$results = getArticles(where, order, limit)
This function takes three parameters, and returns an array of arrays, each holding information on a particular article. The where, order, and limit variables do not need to specify their initial keywords.
Example:
$results = getArticles("topic=4", "counter DESC", "5");
this will get the five most-read articles in topic 4
Note that the information passed back is pretty much directly from the database. The only real exception to this is that some values are duplicated for backwards-compatibility. These are:
topicid = tid
topic = tid
catid = cid
2. Getting processed article information
$info = genArticleInfo($row)
This function takes a row as returned from getArticles() and does some simple parsing of it to make it more acceptable to PostNuke. The specific textfields created are listed in the user documentation for genArticleInfo(). The operations carried out on the array are as follows:
. add a number of date/time strings
. validate the informant string
. provide a 'Category: title' type article header
. sanitize (and transform) the article title and bodies
3. Getting article links
$links = genArticleLinks($info)
This function takes information as returned from genArticleInfo() and creates a number of links from it suitable both for themes and internal use. The specific links created are listed in the user documentation for genArticleLinks(). The links are 'pure', in that they are straight URLs and have no HTML tags around them.
4. Getting preformatted HTML
$preformat = genArticlePreformat($info, $links)
This function takes information as returned from genArticleInfo() and links as returned from genArticleLinks() and creates a number of preformatted HTML fragments suitable both for themes and internal use. The specific fragments created are listed int he user documentation for genArticlePreformat(). The fragments normally include formatting information and are complete and self-sufficient HTML.
5. Putting it all together
Here is a really simple example that gets a bunch of articles, generates, the relevant information, and uses it to print out a list of headlines.
// Get the latest 10 articles by author ID 5 in descending time order $articles = getArticles("aid=5", "time DESC", 10); foreach ($articles as $row) {
// Generate information for row
$info = genArticleInfo($row);
$links = genArticleLinks($info);
$preformat = genArticlePreformat($info, $links);
// Print a clickable title (with category, if any) and date of the
// story
echo "$preformat[catandtitle] ($info[briefdate])";
}
--------------------------------------------------------------------------------
PostNuke Theme Information
themeindex() and themearticle()
themeindex() and themearticle() take a number of legacy parameters, but also three arrays which hold pretty much all of the information that a user should need to create full-featured themes, and supercede the old parameters. The three separate arrays, and their current contents, are outlined below.
info
info holds raw information. Most of this comes direct from the database query on a story, however some extras are also added. info is guaranteed to have at least the following items:
. bodytext - the main text of the story
. briefdatetime - short version of the date and time the story was published
. briefdate - short version of the date the story was published
. catandtitle - the category and title of the story, in the format
'Category: Title', if the story is in a particular category
. cid - the ID of the category the story is in
. catid - the ID of the category the story is in (deprecated)
. cattitle - the name of the category the story is in
. comments - the number of comments the story has
. fulltext - home text, then body text, then notes
. hometext - the header text of the story
. informant - the person who submitted the story
. longdatetime - long version of the date and time the story was published
. longdate - long version of the date the story was published
. maintext - home text, then body text
. notes - any editorial notes on the story
. sid - the story ID
. tid - the topic ID
. topic - the topic ID (deprecated)
. topicd - the topic ID (deprecated)
. title - the story title
. topicname - the name of the topic
. topicimage - pathname to the topic image
. topictext - description of the topic
. unixtime - the Unix timestamp of the story
. version - the version of the array. This can be used to see if sepcific variabels exist in the array or not.
. withcomm - if the story allows comments to be posted with it
links
links holds a set of 'pure' URLs for a spcific story. These are used to provide ad-hoc links where required by the themer. links is guaranteed to have at least the following items:
. category - list of items in the same category as the story
. comment - comments on the story
. fullarticle - the story itself
. print - print the story
. send - send the story to a friend
. version - the version of the array. This can be used to see if sepcific variabels exist in the array or not.
preformat
preformat holds a set of pre-formatted HTML fragments that fit a standard format. These are generally considered 'intelligent', so for instance a preformat that contains a comments link will contain the correct text relating to how many comments have been previously posted. Pretty much all preformatted text contains URLs. preformat is guaranteed to have at least the following items:
. bodytext - main body of text, including autolinks if any
. bytesmore - 'bytes more' link (for back-compatibility)
. category - list of items in the same category as the story
. cattitle - the title of the story, preceded by it's category (if any)
. comment - info on current number of comments
. fulltext - home text, then body text, then notes
. hometext - initial text, including autolinks if any
. maintext - home text, then body text
. more - single generic status link (for back-compatibility)
. notes - any editorial notes on the story
. print - print the story
. readmore - 'read more' link
. send - send the story to a friend
. title - the title of the story
. version - the version of the array. This can be used to see if
sepcific variabels exist in the array or not.
Example
The PostNuke theme uses these arrays to generate a lot of content, please look at this as an example of how the arrays can be used.
6966