{init_article}

Articles in Saurus CMS are handled by two functions:

  • {init_articles} returns a list of articles with most common attributes like "title" and timestamp.
  • {init_article} gives you access to whole set of fields of specific article including body and lead text.

Usage

{init_article [id = value] [name = value] [parameter = value ..]}

Returns

One article object stored in variable defined by parameter "name".

Parameters

id ID of the article to initialize, usually retrieved by {init_articles} function. When undefined, current ID in URL is used. int  
name

Defines variable for storing the article object. Default value is "article".

string  
buttons

Defines a list of actions displayed in v-shaped context menu. Default value is "new,edit,hide,move,delete". You can use any combination of those to restrict some of the actions by user.

comma separated string  
on_create

Enables you to set default values when new article is created.
Examples: on_create="publish" or on_create="publish, allow_comments" or on_create="allow_comments".

comma separated string  
  publish: By default, objects are set to be hidden/unpublished when created by user. You can force publishing by using on_create="publish". Default value is "hide".   4.0.2
 

allow_comments: sets the check box for enabling comments.

  4.5.3
system_message

Way to call special system articles without knowing their ID. System messages are site/language specific. Possible values are:

  • "footer" - site footer contents, used by Saurus CMS sample templates.
  • "headlogo" - site heading contents, used by sample templates.
  • "tyhiotsing" - site search returned no results.
  • "error_page" - error in submitting feedback form.
  • "404error"- page not found.
  • "ok_page"- sucessfully submitted feedback form.
  • "login_incorrect" - wrong username or password.
  •  "unustatud_parool_saadetud" - forgotten password sent to user.
  • "kasutaja_registreeritud" - user successfully registered.
  • "kasutaja_uuendatud" - user profile updated.
  • "kasutaja_locked" - user locked.
  • "your_IP_disabled" - user's IP is blocked by site admin.
  • "gallup_ip_olemas" - this IP has already voted in this poll.
string 4.1.0

Attributes

Common attributes      
id ID of the object. int  
parent_id ID of the parent object in site hierachy. int  
href Hyperlink address to the object in format of ?id=123. When aliases are used, returns alias name in public view instead. string  
title Title of the object. string  
lead Lead text of the article. Normally, text entered by user in article editor, it is returned by "body" attribute. But when user inserts "Lead/body separator" from article editor's toolbar into text, the text before separator will become articles "lead" while text following separator will become "body". string  
body Body part of article's text. string  
Comments and timestamp    
buttons

Displays v-shaped context menu for authorized editors.

html  
class Class name of the object. Possible values are: "section, article, link, image, comment, poll, document, article's list, link list, login-box, subject, album, iframe-box, event" string  
comment_count Number of comments.  int 4.0.6
last_commented_time Time of last comment in format dd.mm.yyyy hh:ii. datetime 4.0.6
created_time Time of creation of the object in format of  dd.mm.yyyy hh:ii. datetime 4.0.3
fcreated_time Time of creation of the object in database default format, eg yyyy-mm-dd hh:ii.  datetime 4.0.3
created_user_id ID of the user who initially created the object.  int 4.0.3
created_user_name Name of the user who initially created the object.  string 4.0.3
changed_time

Time of last saving of the object in format dd.mm.yyyy hh:ii.

datetime 4.0.3
fchanged_time Time of last saving of the object in database default format, eg yyyy-mm-dd hh:ii. datetime 4.0.3
changed_user_id ID of the user who saved the object last. int 4.0.3
changed_user_name Name of the user who saved the object last. string 4.0.3
is_selected

Returns 1 when article belongs to the parent branch of current object.

boolean  
Specific attributes      
date

Article's default profile has date/time field which can be freely modified by the user. This attribute returns the date value in format of dd.mm.yyyy.

date  
fdate Same as "date" attribute but in database format of yyyy-mm-dd date  
datetime

Article's default profile has date/time field which can be freely modified by the user. This attribute returns the date and time value in format of dd.mm.yyyy hh:mm.

datetime 4.4.1
fdatetime

Same as "datetime" attribute but in database format of yyyy-mm-dd hh:mm:ss.

datetime 4.4.1
author The "author" field in article's default profile which can be freely modified by the user. string  
show_headline Equals 1 when "Show headline" is checked by the user. boolean 4.1.0
forum_allowed Equals 1 when "Allow comments" is checked by the user. boolean 4.1.0
<attribute> Returns value of specific profile field. The value is set only if parameter "profile" is used for {init_articles}.   4.0.8

 General tags

<name>_newbutton Outputs action button for creating new object. html  
<name>_count Number of returned objects. When parameter "limit" is set, equals value of "limit". int  
<name>_counttotal Total number of objects found, not affected by "limit" parameter.  int  

Examples

Display list of all available articles in current section. We display both article's lead and body this time.

{init_articles name="article_list"}
{foreach from=$article_list item="article"}
    <h1>{$article->buttons}{$article->title}</h1>
    {init_article id=$article->id name="article_details"}
    {$article_details->lead}{$article_details->body}
{foreachelse}
    {$article_list_newbutton}
{/foreach}

Modified version of previous example. We added articles' author and date below headline. We also check whether article has both lead and body parts, in this case we only display leady with "Read further" link to article's detail view.

{init_articles name="article_list"}
{foreach from=$article_list item="article"}
    <h1>{$article->buttons}{$article->title}</h1>
    <p>{$article->author} @ {$article->date}</p>
    {init_article id=$article->id name="article_details"}

    {if $article_details->body && $article_details->lead}
	{$article_details->lead}
	<p><a href="{$article_details->href}">Read further</a></p>
    {else}
        {$article_details->lead}{$article_details->body}
    {/if}
{foreachelse}
    {$article_list_newbutton}
{/foreach}

Initialize and display system article "footer". This is good way to define footer which has to stay in one place site-wide. You do not have to know it's ID or parent. As system messages are site/language specific this displays different content per site/language. Please note we have enabled only button "edit" so that user can't delete or hide it once created.

{init_article system_message="footer" name="footer_article" buttons="edit"}
{$footer_article->buttons}{$footer_article->body}