From LifeType Wiki
Name: stickyposts
Latest version: 1.0
Download link: http://prdownloads.sourceforge.net/lifetype/1.1_stickyposts.zip?download
License: GPL
Author: lss
[edit] Description
This plugin offers features to get all articles from specific article cateogries as announcements and sticky articles.
[edit] Configuration
In ControlCenter:
- Create two categories for Sticky and Annouce.
- You can configure this plugin in controlcetner >> StickyPosts .
- maxStickys and maxAnnouces are numbers of sticky/announce articles for display in blog. The default value is 5.
- Select category for store sticky/announce articles.
In tempalte file, You can use:
- $stickyposts->isEnabled() to check the plugin is enabled or not.
- $stickyposts->getArticles( 'sticky' ) to get an array of articles for sticky. This will get max articles you set in controlcenter.
- $stickyposts->getArticles( 'announce' ) to get an array of articles for announce. This will get max articles you set in controlcenter.
- $stickyposts->getArticles( 12 ) to get an array of all articles for categoryId = 12.
- $stickyposts->getCategory( 'sticky' ) to get an category object for sticky articles.
- $stickyposts->getCategory( 'announce' ) to get an category object for annuonce articles.
- $stickyposts->getCategory( 12 ) to get an category object for categoryId = 12.
Where the 'sticky' and 'announce' are plugin reverse string.
Example: This is a very simple example for use stikcyposts plugin in template, Rewrite it as you like. This example modifies main.template of template 'blueish'.
{include file="$blogtemplate/header.template"}
<div id="content">
{if $stickyposts->isEnabled()}
<h2>Sticky Posts</h2>
{assign var=stickys value=$stickyposts->getArticles('sticky')}
{foreach from=$stickys item=post}
<h2 class="title"><a href="{$url->postPermalink($post)}">{$post->getTopic()}</a></h2>
{/foreach}
{assign var=stickyCategory value=$stickyposts->getCategory('sticky')}
<h4><a href="{$url->categoryLink($stickyCategory)}">more sticky posts</a></h4>
<h2>Announce Posts</h2>
{assign var=stickys value=$stickyposts->getArticles('announce')}
{foreach from=$stickys item=post}
<h2 class="title"><a href="{$url->postPermalink($post)}">{$post->getTopic()}</a></h2>
{/foreach}
{assign var=announceCategory value=$stickyposts->getCategory('announce')}
<h4><a href="{$url->categoryLink($announceCategory)}">more announce posts</a></h4>
{/if}
{foreach from=$posts item=post}
{include file="$blogtemplate/post.template"}
{/foreach}
</div>
{include file="$blogtemplate/panel.template"}
{include file="$blogtemplate/footer.template"}
If you want sticky posts just show in home page, (not in monthly archive page and category page), just add a {if $showAll}{/if} statement outside the {if $stickyposts->isEnabled()}{/if} like this:
{if empty($showAll)}
{if $stickyposts->isEnabled()}
.....
{/if}
{/if}
[edit] Notes
May someone kindly make an good example of template. I make a very bad one.
2005-05-21 change note: If you pass a smarty variable which stores categoryId to getArticles/getCategory method like $stickyposts->getCategory($catId), it will return null. I have fix it. You should update your pluginstickyposts.class.php. for now, you can download from http://bugs.plogworld.net/view.php?id=531 .
2005-05-18 change note: I lost a {/if} before {foreach from=$posts item=post}. It was fixed.
2005-05-18 change note: Add note for how stickyposts just show in home page.
