Custom page parameters

Contents...

In Webasyst applications utilizing the common mechanism of publishing static info pages (for example, Site, Blog, and Photos) there is an option to enter custom page parameters when creating or editing a frontend page or a blog post. Such parameters are frequently used to apply individual design to selected pages or posts without affecting the remaining pages.

Names of custom parameters may contain Latin letters and underscore characters; e.g., status or extra_class. Values of custom parameters may contain any text; e.g., special or 1. The name and the value of a parameter must be divided by an equality symbol without spaces. Each parameter must be specified on a separate line:

extra_class=1
status=special

Parameter names and values are accessible in HTML templates as items of arrays returned by the following structures:

$wa->site->pages() {* info pages of Site app frontend *}
$wa->photos->pages() {* info pages of Photos app frontend *}
$wa->blog->posts() {* blog posts *}

Each item of an array returned by one of the above structures contains information of a single website page or blog record including the custom parameters specified in the backend. You can access and use them, for example, inside a {foreach}{/foreach} cycle:

<ul>
  {foreach $wa->site->pages() as $page}
    <li>
      <a href="{$page.url}" {if $page.extra_class == '1'}class="highlighted bold"{/if}>{$page.name}</a>
    </li>
  {/foreach}
</ul>

Furthermore, in templates used in the context of an individual frontend page (e.g., page.html or post.html), where a variable with page properties is already accessible ($page or $post), you can use the desired property without a cycle as shown in the example below:

{if $page.status == 'special'}
  <div class="special_offer">
  ...
  </div>
{/if}