init_articles

Tag {init_articles} is for calling out some or all article records within one section. With this tag you can create a page which shows you all articles in one page. Combining it with init_article tag gives developer more choices of how to present articles.

Parameters

  • parent - section ID where to get the articles. If parent is not defined then current page ID is used.
  • name - variable name where the returned data is saved. Default value is "articlelist".
  • buttons - defines which action buttons are displayed to the site editor. Values can be "new,edit,hide,move,delete".
  • start - the starting row number to return.
  • limit - the number of rows to return. You must use this parameter always with "start" parameter.
  • position - defines the location of articles on the page. You can use any numbers for position.
  • order - defines how articles are sorted. Articles can be sorted by article title, date or author name with descending or ascending order. Sample: order="title desc"
  • classes - defines alternative objects which can be used besides articles. Alternative objects: links. For example classes="article,link" allows editors to insert articles and hyperlinks.
  • start_date - defines starting date of the article list. Format dd.mm.yyyy
  • end_date - defines end date of the article list. Format dd.mm.yyyy
  • profile - defines the profile(s) of the articles. Comma separated list values must exactly match the profile name in the site's administration area. 3.3.8
  • where additional filtering criteria using WHERE SQL syntax.
    Sample:where="title='My headline'"
    3.3.9
    Note: when including any profile fields in the criteria, add also "profile" parameter for the tag.
  • on_create - comma separated statements for new articles:
    - publish: allows to publish all articles immediately. If the parameter has value "publish", then a created article is published immediately after saving. 4.0.2
    - allow_comments: ticks the check box for allowing comments in the article editor when creating a new article. 4.5.3
    Examples: on_create="publish" or on_create="publish, allow_comments" or on_create="allow_comments".
  • select - additional table fields to return using SELECT SQL syntax. 4.0.8
  • rows_on_page - how many rows to display on one page. Used with URL "page" parameter. 4.0.8.

  • metadata - defines the type of metadata set articles use in this section (use metadata ID). Only used when metadata sets exist in a database.
    This functionality is deprecated in version 4, please use profiles instead.
  • metadata_value  - filters the article list based on metadata value defined by this parameter.
    This functionality is deprecated in version 4 , please use profiles instead.
  • get_object_fields - comma seperated list of extra fields which are not included by default beacuse of optimization and speed reasons. Fields will be added as elements. 3.3.13
    This functionality is deprecated in version 4.
Note 1: If you use position parameter for one init_article occurrence, you must use it on every other occurrence too.

Note 2: Make sure that once you have already created articles with certain position number, don't change the position number in template, since you will "hide" all articles inserted with previous position number. For example, if you have created article list with position "9" and later change it to "10", all articles inserted between this change have position number "9" and they won't appear on a page under position "10".

Attributes

  • id - ID number of the article
  • parent_id - ID number of parent object
  • href - the link to article detailed view, eg "?id= 368"
  • title - the title of the article
  • is_selected - value is 1 in case of active article, 0 otherwise
  • buttons - action-buttons, available only for editors
  • date - the date of the article, format dd.mm.yyyy
  • fdate - date of the article in database format, eg yyyy-mm-dd
  • datetime - date and time of the article, format dd.mm.yyyy hh:mm. 4.4.1
  • fdatetime - date and time of the article in database format, eg yyyy-mm-dd hh:mm:ss. 4.4.1
  • details_link - alias to "href" attribute
  • details_title - the link title to article detailed view (system word)
  • printgif - the link to print view of the article with small printer-icon
  • printlink - the link to print view of the article
  • comment_link - the link to the comment board of the article
  • comment_title - the title of the link to the comment board of the article (system word)
  • add_comment_link - the hyperlink to the "add comment" form
  • add_comment_title - the title of the link to the "add comment" form
  • forum_allowed - value is 1 if forum is allowed for the article, 0 otherwise. Example: {if obj->forum_allowed == 0} Forum is not allowed {/if}. 4.1.0
  • show_headline - value is 1 if headline is visible for the article, 0 otherwise. 4.1.0
  • author - the author of the article
  • last_modified - the objects last modified time
    This functionality is deprecated in version 4, please use changed_time instead.
  • class - class name of the object. The possible values for {$obj->class} are: "section, article, link, image, comment, poll, document, article's list, link list, login-box, subject, album, iframe-box, event".
  • category - article keyword as a text. Has value only if metadata ID=2003.
    This functionality is deprecated in version 4 , please use profiles instead.
  • created_user_id - user ID who initially created the object. 4.0.3
  • created_user_name - user full name who initially created the object. 4.0.3
  • changed_user_id - user ID who made the last object saving. 4.0.3
  • changed_user_name - user full name who made the last object saving. 4.0.3
  • created_time - creating time of the object in format dd.mm.yyyy hh:ii. 4.0.3
  • fcreated_time - creating time of the object in database default format, eg yyyy-mm-dd hh:ii. 4.0.3
  • changed_time - last saving time of the object in format dd.mm.yyyy hh:ii. 4.0.3
  • fchanged_time - last saving time of the object in database default format, eg yyyy-mm-dd hh:ii. 4.0.3
  • comment_count - the number of comments. 4.0.6
    In version 3 the value is available only if field "comment_count" is included in the parameter "get_object_fields". Sample: get_object_fields= "comment_count". 3.3.13
  • last_commented_time - the last comment time in format dd.mm.yyyy hh:ii. 4.0.6
  • <attribute> - returns data field value of the profile. The value is set only if parameter "profile" is set. 4.0.8

General tags

  • <name>_newbutton - prints "New" action-button for creating a new object.
  • <name>_archive_link - the hyperlink to the articles' archive of current section.
  • <name>_archive_title -the title of the hyperlink to articles' archive (system string).
  • <name>_count - the number of returned objects.  If parameter "limit" is set then count equals to "limit" value.
  • <name>_counttotal - the total number of objects found, not affected by "limit" parameter. 3.3.7
Examples

Bulleted list of all article titles under section with id 631  {init_articles name="arts" parent="631"}
<ul>
      {foreach from=$arts item=obj}

<li><a href="{$obj->href}">{$obj->title}</a>

{foreachelse}

{$arts_newbutton}

{/foreach}

</ul> 

Init_article within init_articles loop 


{*Comment: This sample demonstrates how to display multiple articles in one page. Note that init_article allows to display also article's lead and body.*}

{init_articles name="arts" position="2"}
{foreach from=$arts item=obj}
  {init_article id=$obj->id name="art"}
  <h1>{$art->buttons}{$art->title}</h1>
  <p>{$art->lead}</p>
  <p>{$art->body}</p>
{foreachelse}
  {$arts_newbutton}
{/foreach}

Init_article with profile


{*Comment: This sample demonstrates how to display articles with profile "apartment"*}
{init_articles name="arts" profile="apartment"}

{foreach from=$arts item=apartment}
    Name: {$apartment->buttons}{$apartment->title}
    {init_article name="obj" id=$apartment->id}
    Photo: {$obj->photo}<br>
    City: {$obj->city}<br>
    Address: {$obj->address}<br>
{foreachelse}
    {$arts_newbutton}
{/foreach}

Default article view with commentboard


See Code samples