First Steps

In the following we give a short example how to use the erminas SmartAPI.

After the login a project is selected and all pages based on a specific Content Class will get a “.php” extension.

// RedDot Login with (user/password)
var authData = new PasswordAuthentication("user", "password");

var login = new ServerLogin {Address = new Uri("http://my-reddot-server/cms"), AuthData = authData};

// Session is the entry point to interact with the RedDot server.
// Creating the session object automatically creates a connection.
// Dispose() closes the connection in a a clean way (this is done
// automatically at the end of the using block).
using(var session = SessionBuilder.CreateOrReplaceOldestSession(login))
{
  // Select a project based on the name
  var project = session.ServerManager.Projects.GetByName("MyProjekt");

  // Find all pages based on the Content Class "MyContentClass"
  var pageSearch = project.Pages.CreateSearch();
  pageSearch.ContentClass = project.ContentClasses.GetByName("MyContentClass");

  var pages = pageSearch.Execute();

  // Attach suffix ".php" to all filenames of the pages found
  foreach(var curPage in pages )
  {
    curPage.Filename = curPage.Filename + ".php";

    // Commit changes to the server
    curPage.Commit();
  }
}