Site:Frontend:Introduction

From Metrixstream
(Redirected from Site:Introduction)
Jump to: navigation, search

Contents

Getting Started

Before you master creating websites within Metrixstream, you first need to know the basics. Read through the various sections below to give you a basic understanding of how things work and then continue on to the other sections for more detailed explainations.

Backend

The backend is responsible for coming up with efficient and scalable database queries so that you can reliably use them as you create your web pages.

Throughout your site building, you will most likely never be accessing the backend directly. This is all provided for you through a backend context, which describes how a backend query should be executed.

Backend Query

A Backend Query is a mechanism that retrieves data from the backend.

Backend Context

A Backend Context is a configuration for how a Backend Query should be executed. This configuration commonly includes # of objects, sorting field, ordering method, etc.

Each page has the option of specifying a backend context.

Additional Backend Context

Pages also have the ability to specify additional backend contexts, which let you create a modular structure to your page, such as popular videos in the upper right, latest comments in the upper left, and staff favorite content on the rest of the page. That example would be handled by creating a primary context and then two additional contexts.

Frontend

The frontend is responsible for choosing what backend queries to use per page and then using the results to generate the page through the Clearsilver templating language.

Clearsilver

Clearsilver is the mechanism used to interpret information received from a context. Information received from a context is populated into the HDF, which you can reference using Clearsilver.

Clearsilver is a language neutral template processing engine based on the MVC (Model View Control) design pattern.

The idea behind it is that the backend processes contexts, which results in an HDF object. This object contains all the necessary information required to generate the page that you want to create.

In general Clearsilver allows you to do the following:

Output a variable from the HTML to the actual page

Hey <?cs var:MS.site.user.username ?>, welcome back to our site!

Simple conditional logic checks with if/then statements

<?cs if:MS.site.user.loggedIn ?>
  Thank you for logging in, <?cs var:MS.site.user.username ?>.
<?cs else ?>
  Please login!
<?cs /if ?>

Looping through a list of items

<?cs each:item = MS.content.items ?>
  Title: <?cs var:item.title ?><br />
<?cs /each ?>

Properly escape variables using html, javascript, and url escaping

<script type="text/javascript">
  var username = "<?cs var:js_escape(MS.site.user.username) ?>";
</script>
<input type="text" name="username" value="<?cs var:html_escape(MS.site.user.username) ?>">
 <a href="http://www.test.com/?user=<?cs var:url_escape(MS.site.user.username) ?>">click here to go to your public profile page</a>

Use a built-in macro

<img src="<?cs call:getStaticUrl("logo.jpg") ?>" />

Detailed documentation of the Clearsilver language is available here: http://www.clearsilver.net/docs/

HDF

The HDF is simply a term of a list of key-value pairs. This usually consists of content titles, player urls, image urls, user information, etc. The job of each page is to reference the HDF object through Clearsilver the template is to reference the HDF keys, so you can output the HDF values.

If you aren't sure what fields are available, add the hdf parameter to the end of your site URL. (Example: http://www.test.com/?hdf) It will output all the available HDF keys.

Personal tools