Site:Integration

From Metrixstream
Revision as of 15:17, 16 May 2012 by MetrixAdmin (Talk | contribs)

Jump to: navigation, search

Contents

Integration

Integration into Metrixstream is necessary when developing features outside the core platform. This can be done through a GitHub.com account. Once you have your account setup and repository created, contact support@metrixstream.com, so that we can configure your license so it fetches resources from GitHub.com for your extensions.

Backend Contexts

Backend Contexts are the heart of the site engine. You can create your own Backend Context by simply extending the BackendContext abstract class.

Make sure your class name ends with "Context" and that the beginning of your class name is the same as the result of getInternalName().

ExampleContext

Below is ExampleContext, which simply is accepting a value via URL through the "hello" parameter. It then takes that parameter and sets it into it's HDF object.

class ExampleContext extends BackendContext {

  public function getInternalName() {
    return "example";
  }

  public function getDisplayName() {
    return "My Example Context";
  }

  public function isDependentOnScope($scopeKey) {
    return false;
  }

  public function getConsumableParams() {
    return Array("hello");
  }

  public function filterParam($paramName, $paramValue, $whitelist = Array()) {
    switch($paramName) {
      case "hello": return $paramValue;
    }
    return null;
  }

  public function &execute(ScopeContext &$Scope, PageContext &$Page) {
    $App =& $this->getApplicationContext();
    $Render =& $App->getRenderContext();

    $params = Array(
      "hello" => $this->getParam($Page, "hello", "")
    );

    $out =& $Render->getRenderOutput();
    $out->setCacheable(true);
    $out->getHDF()->set("hello", $params["hello"]);

    return $out;
  }
}

Code Location

Each Backend Context class file must be placed within the context/backend folder. Each class file must also have the same name as the return value of the getInternalName() function along with a ".php" extension.

Here is a sample of this would look inside Github. https://github.com/metrixsean/Metrixstream-Sample-Integration/blob/master/context/backend/example.php

Page Integration

Once your new Context is checked into Github, you need to go to the Metrixstream Setup Panel, click on Shortcuts -> License Manager, and then click the "UPDATE GITHUB" button. This will cause all of your servers to get the latest updates from Github.

Now you can choose your new Backend Context in your site page creation.

Within your Site, choose "ADD PAGE". Give your page a name and then scroll down to the Backend Context section. Make sure to pick "My Example Context" and click the "SAVE" button.

Within your Site Page, you can now access the HDF key that you set in your context. This is as simple as the following:

Hello... my new context lets me reference the following key:

MS.hello = <?cs var:MS.hello ?>
Personal tools