{save_mailinglist}

Tag {save_mailinglist} allows to save the mailinglist subscriptions. Since version 4.4.3.

Parameters

  • user - user ID who's subscription is saved. Default value is the logged in user ID.
  • fields - array of section ID values which can be subscribed to

Example

First, display the subscribable sections:

<form action="POST">
{init_mailinglist name="list"}
{if $list_count > 0}
{********** TITLE **********}
<h1>{sysword word="mailinglists" type="saurus4"}</h1>
<table>
{********** PRINT CHECKBOXES AND SECTION NAMES **********}
{foreach from=$list item=section}
<tr>
<td>
<input type="checkbox" name="mailinglist_sections[]" value="{$section->id}" {if $section->user_subscribed == 1} checked="checked"{/if}>
<a href="?id={$section->id}" target="_blank">{$section->title}</a>
</td>
</tr>
{/foreach}
</table>
{/if}
<input type="submit" value="Subscribe">
</form>

then, save the posted values:

{save_mailinglist fields=$smarty.post.mailinglist_sections} 

{init_mailinglist}

Tag {init_mailinglist} returns all subscribable sections.

 Parameters

  • name - variable name where the returned data is saved. Default value is "mailinglist".
  • name_separator -  the character(s) that separates the section name in the full section path (default is " > ").

Attributes

  • id - section ID number.
  • title - title of the section.
  • user_subscribed  - boolean value showing if the currently logged in user is subscribed to that mailinglist (1) or not (0).

General tags

  • <name>_count - the number of returned objects.

Example

{init_mailinglist name="list"}

{foreach from=$list item=section}
    <input type="checkbox" name="rubriik[]" value="{$section->id}"{if $section->user_subscribed == 1} checked{/if}>
    <a href="?id={$section->id}" target="_blank">{$section->title}</a>
{/foreach}