Login

Recover Your Password


AddonBaseClass


The base class for all Contensive add-ons.


Methods


Execute()

Execute() is like the main method of an addon. It is the only method required by an addon. An addon can be executed on a webpage, as a process, or make ajax requests to a server.

Signatures

public abstract object Execute(BaseClasses.CPBaseClass CP);

Arguments

CP
BaseClasses.CPBaseClass
call-by-value
CP is an instance of CPBaseClass, and it has a valid CP.MyAddon object that points to any current addon parameters. The parameters are the values for that addon in the database.

Return

object
If the result is an object, it is automatically serialized as a JSON string which is useful for making ajax requests to a server. If the result is a string, it is displayed to a document or logged in the process log depending on the addon context.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Sample {
    class HelloWorldClass : AddonBaseClass {
        public override object Execute(CPBaseClass CP) {

            return "Hello World";
        }
    }
}

CPAddonBaseClass


CP.Addon - The Addon class represents the instance of an add-on. To use this class, use its constructor and open an addon. Use these properties to retrieve it's configuration.

Properties


ccGuid
string
The guid used to uniquely identify the add-on.

public abstract string ccGuid { get; }
ID
int
The local ID of this addon on this site.

public abstract int ID { get; }

Methods


Execute()

Execute an addon in the default addon environment (type=simple, etc) and returns its resulting object. Generally addons return strings.

Signatures

//  Provide details for the execution environment, 
// such as argument key value pairs.
Execute(string addonGuid, 
    CPUtilsBaseClass.addonExecuteContext executeContext);

// Pass arguments to the addon that can 
// be read with cp.doc.get() methods.
Execute(int addonId, 
    Dictionary<string, string> argumentKeyValuePairs);

// Pass arguments to the addon that can 
// be read with cp.doc.get() methods.
Execute(string addonGuid, 
    Dictionary<string, string> argumentKeyValuePairs);

// Provide details for the execution environment, 
// such as argument key value pairs.
Execute(int addonId, 
    CPUtilsBaseClass.addonExecuteContext executeContext);

Execute(int addonId);

Execute(string addonGuid);

Arguments

addonGuid
string
call-by-value
Specified Addon's GUID.

addonId
int
call-by-value
Specified Addon ID number

argumentKeyValuePairs
Dictionary<string, string>
call-by-value
Pass arguments to the addon that can be read with cp.doc.get() methods.

executeContent
CPUtilsBaseClass.addonExecuteContext
call-by-value
Provide details for the execution environment, such as argument key value pairs.

Return

object
Generally return a string.

ExecuteAsync()

Execute an addon asynchonously with the current session environment.

Signatures

// Arguments can be passed that the addon can 
// read with cp.doc.get methods.
ExecuteAsync(int addonid, 
    Dictionary<string, string> argumentKeyValuePairs);

// Arguments can be passed that the addon can 
// read with cp.doc.get methods.
ExecuteAsync(string addonGuid, 
    Dictionary<string, string> argumentKeyValuePairs);

ExecuteAsync(int addonid);

ExecuteAsync(string addonGuid);

Arguments

addonGuid
string
call-by-value
Specified Addon's GUID.

addonid
int
call-by-value
Specified Addon ID number.

argumentKeyValuePairs
Dictionary<string, string>
call-by-value
Pass arguments to the addon that can be read with cp.doc.get() methods.

Return

void

ExecuteAsyncByUniqueName()

Execute an addon asynchonously with the current session environment.

Signatures

// Arguments can be passed that the addon can 
// read with cp.doc.get methods.
ExecuteAsyncByUniqueName(string addonName, 
    Dictionary<string, string> argumentKeyValuePairs);

ExecuteAsyncByUniqueName(string addonName);

Arguments

addonName
string
call-by-value
Name of specified Addon.

argumentKeyValuePairs
Dictionary<string, string>
call-by-value
Pass arguments to the addon that can be read with cp.doc.get() methods.

Return

void

ExecuteByUniqueName()

Execute an addon in the default addon environment (type=simple, etc) and returns its resulting object. Generally addons return strings.

Signatures

// Pass arguments to the addon that can 
// be read with cp.doc.get() methods.
ExecuteByUniqueName(string addonName, 
    Dictionary<string, string> argumentKeyValuePairs);

// Provide details for the execution environment, 
// such as argument key value pairs.
ExecuteByUniqueName(string addonName, 
    CPUtilsBaseClass.addonExecuteContext executeContext);

ExecuteByUniqueName(string addonName);

Arguments

addonName
string
call-by-value
Name of specified Addon.

argumentKeyValuePairs
Dictionary<string, string>
call-by-value
Pass arguments to the addon that can be read with cp.doc.get() methods.

executeContent
CPUtilsBaseClass.addonExecuteContext
call-by-value
Provide details for the execution environment, such as argument key value pairs.

Return

object
Generally return string.

InstallCollectionFile()

Install an addon collection from a file in private files.

Signatures

InstallCollectionFile(string privatePathFilename, 
    ref string returnUserError);

Arguments

privatePathFilename
string
call-by-value
Name of file in private files.

returnUserError
string
call-by-reference
Call-by-reference string that gets updated if an error occurs while installing the collection.

Return

bool
Return true if the collection was successfully installed.

InstallCollectionFileAsync()

Install addon collection from a file in private files.

Signatures

InstallCollectionFileAsync(string privatePathFilename);

Arguments

privatePathFilename
string
call-by-value
Name of file in private files.

Return

int
Return a taskID number that can be used to check the status of the asynchronous installation.

InstallCollectionFromLibrary()

Install addon collection by its guid from the addon collection library.

Signatures

InstallCollectionFromLibrary(string collectionGuid, 
    ref string returnUserError);

Arguments

collectionGuid
string
call-by-value
Specified Addon collection's GUID.

returnUserError
string
call-by-reference
Call-by-reference string that gets updated if an error occurs while installing the collection.

Return

bool
Return true if the collection was installed successfully, false if otherwise.

InstallCollectionFromLibraryAsync()

Install addon collection by its guid from the addon collection library.

Signatures

InstallCollectionFromLibraryAsync(string collectionGuid);

Arguments

collectionGuid
string
call-by-value
Specified Addon collection's GUID.

Return

int
Return a taskID number that can be used to check the status of the asynchronous installation.

InstallCollectionFromLink()

Install addon collection by its guid from the addon collection library.

Signatures

InstallCollectionFromLink(string link, 
    ref string returnUserError);

Arguments

link
string
call-by-value
Link to specified collection.

returnUserError
string
call-by-reference
Call-by-reference string that gets updated if an error occurs while installing the collection.

Return

bool
Return true if collection was successfully installed.

InstallCollectionFromLinkAsync()

Install addon collection by its guid from the addon collection library.

Signatures

InstallCollectionFromLinkAsync(string link);

Arguments

link
string
call-by-value
Link to specified collection.

Return

int
Return a taskID number that can be used to check the status of the asynchronous installation.

InstallCollectionsFromFolder()

Install an addon collection by its GUID from the addon collection library.

Signatures

InstallCollectionsFromFolder(string privateFolder, 
    bool deleteFolderWhenDone, ref string returnUserError);

Arguments

deleteFolderWhenDone
bool
call-by-value
If true, folder in private files will be deleted if collection is installed successfully.

privateFolder
string
call-by-value
Name of folder in private files.

returnUserError
string
call-by-reference
Call-by-reference string that gets updated if an error occurs while installing the collection.

Return

bool
Return true if the collection was installed successfully.

InstallCollectionsFromFolderAsync()

Install addon collection by its guid from the addon collection library.

Signatures

InstallCollectionsFromFolderAsync(string privateFolder, 
    bool deleteFolderWhenDone);

Arguments

deleteFolderWhenDone
bool
call-by-value
If true, folder in private files will be deleted if collection is installed successfully.

privateFolder
string
call-by-value
Name of folder in private files.

Return

int
Return a taskID number that can be used to check the status of the asynchronous installation.

[deprecated] Open()

Use a model object instead. Open an addon.

Signatures

Open(int AddonId);

Open(string AddonNameOrGuid);

Arguments

AddonId
int
call-by-value
Specified Addon ID number.

AddonNameOrGuid
string
call-by-value
Specified Addon name or Addon GUID.

Return

bool
Return true if Addon was successfully opened.

CPBaseClass


The object passed to an addon in the add-ons execute method. See the AddonBaseClass for details of the addon execute method.

Properties


Addon
CPAddonBaseClass
The addon class handles access to an add-on's features. Use the Utils object to run an addon. An instance of the Addon class is passed to the executing addon in the MyAddon object so it can access any features needed.

public abstract CPAddonBaseClass Addon { get; }
Cache
CPCacheBaseClass
The Cache objects handles caching. Use this class to save blocks of data you will use again.

public abstract CPCacheBaseClass  Cache { get; }
Content
CPContentBaseClass
The Content class handles functions related to content meta such as determining the table used for a content definition, getting a recordid based on the name, or accessing the methods that control workflow publishing.

public abstract CPContentBaseClass Content { get; }
Db
CPDbBaseClass
The Db object handles direct access to the Database. The ContentSet functions in the CPCSBaseClass are prefered for general use.

public abstract CPDbBaseClass Db { get; }
Doc
CPDocBaseClass
The Doc object handles features related to the document (page) being constructed in the current call.

public abstract CPDocBaseClass Doc { get; }
Email
CPEmailBaseClass
The Email object handles email functions.

public abstract CPEmailBaseClass Email { get; }
Group
CPGroupBaseClass
The Group Object accesses group features. Group Features generally associate people and roles.

public abstract CPGroupBaseClass Group { get; }
Html
CPHtmlBaseClass
The HTML class handles functions used to read and produce HTML elements.

public abstract CPHtmlBaseClass  Html { get; }
Request
CPRequestBaseClass
The Request object handles data associated with the request from the visitor.

public abstract CPRequestBaseClass  Request { get; }
Response
CPResponseBaseClass
The Response object handles the stream of data back to the visitor.

public abstract CPResponseBaseClass  Response { get; }
Site
CPSiteBaseClass
The Site Class handles features related to the current site.

public abstract CPSiteBaseClass  Site { get; }
User
CPUserBaseClass
The User Class handles details related to the user and its related people record.

public abstract CPUserBaseClass User { get; }
UserError
CPUserErrorBaseClass
The UserError Class handles error handling for those conditions you want the user to know about or correct. An example of this is a login error.

public abstract CPUserErrorBaseClass UserError { get; }
Utils
CPUtilsBaseClass
The Utils class handles basic utilities and other features not classified.

public abstract CPUtilsBaseClass  Utils { get; }
Version
string
Contensive version.

public abstract string Version { get; }
Visit
CPVisitBaseClass
The Visit Class handles details related to the visit. For instance it holds the number of pages hit so far and has methods for adding and modifying user defined visit properties.

public abstract CPVisitBaseClass Visit { get; }
Visitor
CPVisitorBaseClass
The Visitor Class handles details related to the visitor. For instance it holds the browser type used by the visitor.

public abstract CPVisitorBaseClass Visitor { get; }

Methods


BlockNew()

Construct new Block object.

Signatures

BlockNew();

Arguments

No arguments


Return

CPBlockBaseClass
The new block object.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class BlockNewSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        { 
            // Append a hello world paragraph tag
            // to the new block. See CPBlockBaseClass
            // for more info on append.
            CPBlockBaseClass newBlock = cp.BlockNew();

            string html = cp.Html.p("Hello World!");

            newBlock.Append(html);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

CSNew()

Construct new CS object.

Signatures

CSNew();

Arguments

No arguments.


Return

CPCSBaseClass
The new CS object.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSNewSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Insert a new content row. See
            // CPCSBaseClass for more info.
            CPCSBaseClass newCS = cp.CSNew();

            newCS.Insert("amountRemaining");

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

DbNew()

Construct new Db object. CP.Db methods are for the default datasource. Use this method to create a db object for other datasources.

Signatures

DbNew(string DataSourceName);

Arguments

DataSourceName
string
call-by-value
Desired name for the new datasource.

Return

CPDbBaseClass
A new Db class. An exception is thrown if the Datasource cannot be opened.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DbNewSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create a new Db and dispose of it.
            // See CPDbBaseClass for more info.
            string dataSourceName = "exampleDb";
            CPDbBaseClass newDb = cp.DbNew(dataSourceName);

            newDb.Dispose();

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

CPBlockBaseClass


CP.Block - an object that holds and manipulates a block of HTML.


Methods


Append()

Append the htmlString into the current Block.

Signatures

Append(string htmlString);

Arguments

htmlString
string
call-by-value
The HTML string to be appended to the block.

Return

void

Clear()

Clear the contents of the current block.

Signatures

Clear();

Arguments

No arguments.


Return

void

Dispose()

Support IDisposable.

Signatures

Dispose();

Arguments

No arguments.


Return

void

GetHtml()

Return the entire html of the current block.

Signatures

GetHtml();

Arguments

No arguments.


Return

string
Return the entire HTML of the block as string.

GetInner()

Return the innerHtml from the current block specified by the findSelector.

Signatures

GetInner(string findSelector);

Arguments

findSelector
string
call-by-value
Similar to the JQuery selector. To find an html element that has the class="myClass" you user findSelector=".myClass", to find the first html element that has the id="myId" you user findSelector="#myId", etc.

Return

string
Return the inner HTML as string.

GetOuter()

Return the outer Html specified by the findSelector.

Signatures

GetOuter(string findSelector);

Arguments

findSelector
string
call-by-value
Similar to the JQuery selector. To find an html element that has the class="myClass" you user findSelector=".myClass", to find the first html element that has the id="myId" you user findSelector="#myId", etc.

Return

string
Return the outer HTML as string.

ImportFile()

Load the block with the body of a file in the wwwRoot.

Signatures

ImportFile(string wwwFileName);

Arguments

wwwFileName
string
call-by-value
Name of the file in the wwwRoot.

Return

void

Load()

Load the block with an HTML string.

Signatures

Load(string htmlString);

Arguments

htmlString
string
call-by-value
The HTML string to load.

Return

void

OpenCopy()

Load the block with the contents of a record in Copy Content.

Signatures

OpenCopy(string copyRecordName);

Arguments

copyRecordName
string
call-by-value
Name of the record in Copy Content.

Return

void

OpenFile()

Load the block with the entire contents of a file in the wwwRoot.

Signatures

OpenFile(string wwwFileName);

Arguments

wwwFileName
string
call-by-value
Name of the file in the wwwRoot.

Return

void

OpenLayout()

Load the block with the contents of a record in Layouts.

Signatures

OpenLayout(string layoutRecordName);

Arguments

layoutRecordName
string
call-by-value
Name of the layout record in Layouts.

Return

void

Prepend()

Prepend the htmlString on the current block.

Signatures

Prepend(string htmlString);

Arguments

htmlString
string
call-by-value
The HTML to be prepended to the block.

Return

void

SetInner()

Set the innerHtml of an element in the current block specified by the findSelector.

Signatures

SetInner(string findSelector, string htmlString);

Arguments

findSelector
string
call-by-value
Similar to the JQuery selector. To find an html element that has the class="myClass" you user findSelector=".myClass", to find the first html element that has the id="myId" you user findSelector="#myId", etc.

htmlString
string
call-by-value
The inner HTML to set in the block.

Return

void

SetOuter()

Set the OuterHtml in the current block specified by the findSelector to the htmlString.

Signatures

SetOuter(string findSelector, string htmlString);

Arguments

findSelector
string
call-by-value
Similar to the JQuery selector. To find an html element that has the class="myClass" you user findSelector=".myClass", to find the first html element that has the id="myId" you user findSelector="#myId", etc.

htmlString
string
call-by-value
The outer HTML to be set in the block.

Return

void

CPCacheBaseClass


The Cache objects handles caching. Use this class to save blocks of data you will use again.


Methods


Clear()

Invalidate one or more cache objects by key.

Signatures

Clear(List<string> keyList);

[deprecated]
Clear(string ContentNameList);

Arguments

ContentNameList
string
call-by-value
A comma delimited list of Content table names.

keyList
List<String>
call-by-value
One or more cache objects referenced by key.

Return

void

Examples:

using Contensive.BaseClasses;
using System.Collections.Generic;

namespace Contensive.Samples
{
    public class CacheClearSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create a keyList containing multiple
            // made up keys that would reference
            // cached objects.
            List<string> keyList = new List<string>();
            keyList.Add("sampleKey1");
            keyList.Add("sampleKey2");

            // Invalidate the made up cached objects.
            cp.Cache.Clear(keyList);

            return "";
        }
    }
}

ClearAll()

Invalidate all system cache.

Signatures

ClearAll();

Arguments

No arguments.


Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CacheClearAllSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Invalidate all system cache.
            cp.Cache.ClearAll();

            return "";
        }
    }
}

CreateDependencyKeyInvalidateOnChange()

Create a key used only as a dependency. If any record in the table is added/deleted/modified, this key will be updated, invalidating the parent object.

Signatures

CreateDependencyKeyInvalidateOnChange(string tableName);

CreateDependencyKeyInvalidateOnChange(string tableName, 
    string dataSourceName);

Arguments

dataSourceName
string
call-by-value
The name of the data source.

tableName
string
call-by-value
The name of the Db table that the cache will be dependent on.

Return

string
Return the name of the dependency key.

CreateKey()

Create a cache key for a domain model. This key is used to cache a model more complex than a simple string or int.

Signatures

CreateKey(string objectName);

CreateKey(string objectName, string objectUniqueIdentifier);

Arguments

objectName
string
call-by-value
A generic domain model name. This name is arbitrary and does not have to be unique.

objectUniqueIdentifier
string
call-by-value
This identifier must be unique. Using a record/content's ID number is a common identifier since a unique key will be created when concatenated with the objectName.

Return

string
Return the name of the key.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CreateKeySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create a complicated objext to cache.
            MyComplicatedPersonRecord sampleRecord = 
                new MyComplicatedPersonRecord();
            sampleRecord.firstname = "John";
            sampleRecord.lastname = "Smith";
            sampleRecord.ID = 1;
            sampleRecord.organizationName = "Contensive";

            // Create an arbitrary domain model name.
            string objectName = "complicatedPersonRecord1";
            // Use the record's ID number.
            string objectUniqueIdentifier = 
                sampleRecord.ID.ToString();

            // Create the key.
            string key = cp.Cache.CreateKey(objectName, 
                objectUniqueIdentifier);

            cp.Cache.Store(key, sampleRecord);

            return "";
        }

        private class MyComplicatedPersonRecord
        {
            public string firstname;
            public string lastname;
            public int ID;
            public string organizationName;
        }
    }
}

CreateKeyForDbRecord()

Creates a cache key for a database model object.

Signatures

CreateKeyForDbRecord(int recordId, string tableName);

CreateKeyForDbRecord(int recordId, string tableName, 
    string dataSourceName);

Arguments

dataSourceName
string
call-by-value
Name of the data source.

recordId
int
call-by-value
ID number of the desired record in the content table.

tableName
string
call-by-value
Name of the content table containing the desired record.

Return

string
Return the name of the key.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CreateKeyForDbRecordSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            int recordId = 2;
            string tableName = "sampleContent";

            // Create the key
            string key = cp.Cache.CreateKeyForDbRecord(recordId, tableName);
            string value = cp.Content.GetRecordName("Sample Content", recordId);

            cp.Cache.Store(key, value);

            return "The value of the cached record: " + cp.Cache.GetText(key)
                + "<br>The key: " + key;
        }
    }
}

CreatePtrKeyforDbRecordGuid()

Create a key that's a pointer to the record referenced by GUID.

Signatures

CreatePtrKeyforDbRecordGuid(string guid, string tableName);

CreatePtrKeyforDbRecordGuid(string guid, string tableName, 
    string dataSourceName);

Arguments

dataSourceName
string
call-by-value
Name of the data source.

guid
string
call-by-value
Desired Db record's GUID.

tableName
string
call-by-value
Name of the table containing the desired record.

Return

string
Return the name of the key.

Examples:

uusing Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CreatePtrKeyforDbRecordGuidSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string guid = "{d02fe8c2-4e8f-4c39-ae59-511f88049e0e}";
            string tableName = "sampleContent";

            // Create the key
            string key = cp.Cache.CreatePtrKeyforDbRecordGuid(guid, tableName);
            string value = cp.Content.GetRecordName("Sample Content", 3);

            cp.Cache.Store(key, value);

            return "The value of the cached record: " + cp.Cache.GetText(key)
                +"<br>The key: " + key;
        }
    }
}

CreatePtrKeyforDbRecordUniqueName()

Create a key that's a pointer to a Db record with a unique name. Only use in tables with unique record names. This system aims to standardize the naming of cache keys to avoid duplicate records being cached.

Signatures

CreatePtrKeyforDbRecordUniqueName(string name, 
    string tableName);

CreatePtrKeyforDbRecordUniqueName(string name, 
    string tableName, string dataSourceName);

Arguments

dataSourceName
string
call-by-value
Name of the data source.

name
string
call-by-value
The name of a record in a data table. Every record should have a unique name.

tableName
string
call-by-value
Name of the table containing the desired record.

Return

string
Return the name of the key.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CreatePtrKeyforDbRecordUniqueNameSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Get the unique record name.
            string name = cp.Content.GetRecordName("Sample Content", 4);
            string tableName = "sampleContent";

            // Create the key.
            string key = cp.Cache.CreatePtrKeyforDbRecordGuid(name, tableName);

            cp.Cache.Store(key, name);

            return "The value of the cached record: " + cp.Cache.GetText(key)
                + "<br>The key: " + key;
        }
    }
}

GetBoolean()

Return a boolean from a cache. Method returns false if the cache is empty or invalid.

Signatures

GetBoolean(string key);

Arguments

key
string
call-by-value
Key corresponding to site property.

Return

bool
Boolean value from a cache.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CacheGetBooleanSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "booleanCache";

            // Get the double value
            bool value = cp.Cache.GetBoolean(key);

            // Check if the cache is empty or invalid,
            // store something if it is.
            if (value == false)
            {
                cp.Cache.Store(key, true);

                return "The cached boolean: " + cp.Cache.GetBoolean(key);
            }
            return "The cached boolean: " + value;
        }
    }
}

GetDate()

Return a date from a cache. Method returns Date.MinValue if the cache is empty or invalid.

Signatures

GetDate(string key);

Arguments

key
string
call-by-value
Cache object referenced by key.

Return

DateTime
Date from a cache.

Examples:

using Contensive.BaseClasses;
using System;

namespace Contensive.Samples
{
    public class CacheGetDateSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "dateCache";

            // Get the DateTime value
            DateTime value = cp.Cache.GetDate(key);

            // Check if the cache is empty or does
            // not store today's date. Store 
            // today's date if true.
            if (value != DateTime.Now || value == DateTime.MinValue)
            {
                cp.Cache.Store(key, DateTime.Now);

                return "Today's date: " + cp.Cache.GetDate(key);
            }
            return "Today's date: " + value;
        }
    }
}

GetInteger()

Return an integer from cache. Method returns 0 if the cache is empty or invalid.

Signatures

GetInteger(string key);

Arguments

key
string
call-by-value
Cache object referenced by key.

Return

int
Integer from a cache.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CacheGetIntegerSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "intCache";

            // Get the integer
            int value = cp.Cache.GetInteger(key);

            // Check if the cache is empty or invalid,
            // store something if it is.
            if (value == 0)
            {
                cp.Cache.Store(key, 1337);

                return "The cached integer: " + cp.Cache.GetInteger(key);
            }
            return "The cached integer: " + value;
        }
    }
}

GetNumber()

Return a double from cache. Method returns 0 if the cache is empty or invalid.

Signatures

GetNumber(string key);

Arguments

key
string
call-by-value
Cache object referenced by key.

Return

double
Double value from a cache.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CacheGetNumberSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "numberCache";

            // Get the double
            double value = cp.Cache.GetNumber(key);

            // Check if the cache is empty or invalid,
            // store something if it is.
            if (value == 0)
            {
                cp.Cache.Store(key, 23.7);

                return "The cached object: " + cp.Cache.GetNumber(key);
            }
            return "The cached object: " + value;
        }
    }
}

GetObject()

Return the value of a cache. If the cache is empty or invalid, the method will return null.

Signatures

GetObject(string key);

Arguments

key
string
call-by-value
Cache object referenced by key.

Return

object
The value of the specified cache.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CacheGetObjectSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "objectCache";

            // Get the object
            object value = cp.Cache.GetObject(key);

            // Check if the cache is empty or invalid,
            // store something if it is.
            if(value == null)
            {
                cp.Cache.Store(key, 5.4);

                return "The cached object: " + cp.Cache.GetObject(key);
            }
            return "The cached object: " + value;
        }
    }
}

GetObject<T>()

Get an object of type T from a cache. Returns null if the cache is empty or invalid type.

Signatures

GetObject<T>(string key);

Arguments

key
string
call-by-value
Cache object referenced by key.

Return

T
Return object of type T from cache.

Examples:

using Contensive.BaseClasses;
using System.Collections.Generic;

namespace Contensive.Samples
{
    public class CacheGetGenericObjectSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "genericCache";

            // Get the cached list of strings.
            object value = cp.Cache.GetObject>(key);

            // Check if the cache is empty or invalid,
            // store something if it is.
            if (value == null)
            {
                // Make a list of animals to cache.
                List animals = new List();
                animals.Add("dog");
                animals.Add("cat");
                animals.Add("fish");

                // Store the list.
                cp.Cache.Store(key, animals);

                string retVal = "";

                // Read the list of animals into a string.
                foreach(string s in cp.Cache.GetObject>(key))
                {
                    retVal += s + "<br>";
                }
                return "The cached objects:<br>" + retVal;
            }
            return "The cached objects:<br>" + value;
        }
    }
}

GetText()

Return a string from cache. If the cache is empty or invalid, the method returns an empty string.

Signatures

GetText(string key);

Arguments

key
string
call-by-value
Cache object referenced by key.

Return

string
A string from a cache.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CacheGetTextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "textCache";

            // Get the text
            string value = cp.Cache.GetText(key);

            // Check if the cache is empty or invalid,
            // store something if it is.
            if (value == "")
            {
                cp.Cache.Store(key, "Hello world!");

                return "The cached text: " + cp.Cache.GetText(key);
            }
            return "The cached text: " + value;
        }
    }
}

Invalidate()

Invalidate a cache.

Signatures

Invalidate(string key);

Arguments

key
string
call-by-value
Cache object referenced by key.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CacheInvalidateSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "sampleKey";

            // Invalidate a made up cached object.
            cp.Cache.Invalidate(key);

            return "";
        }
    }
}

InvalidateAll()

Invalidate all system cache.

Signatures

InvalidateAll();

Arguments

No arguments.


Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CacheInvalidateAllSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Invalidate all system cache.
            cp.Cache.InvalidateAll();

            return "";
        }
    }
}

InvalidateContentRecord()

Invalidate a key based on the table and recordId.

Signatures

InvalidateContentRecord(string contentName, int recordId);

Arguments

contentName
string
call-by-value
Name of the content table containing the desired record.

recordId
int
call-by-value
Id number of record in content table.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CacheInvalidateContentRecordSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            int recordId = 2;
            string contentName = "Sample Content";

            // Invalidate a cached record in the "Sample Content"
            // content table.
            cp.Cache.InvalidateContentRecord(contentName,
                recordId);

            return "";
        }
    }
}

[deprecated] InvalidateTag()

Use Invalidate(key). Invalidates a cache tag.

Signatures

InvalidateTag(string tag);

Arguments

tag
string
call-by-value
Tag that references a cached object.


InvalidateTagList()

Invalidate a list of cache keys.

Signatures

InvalidateTagList(List<string> keyList);

Arguments

keyList
List<String>
call-by-value
One or more cache objects referenced by key.

Return

void

Examples:

using Contensive.BaseClasses;
using System.Collections.Generic;

namespace Contensive.Samples
{
    public class CacheInvalidateTagListSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create a keyList containing multiple
            // made up keys that would reference
            // cached objects.
            List<string> keyList = new List<string>();
            keyList.Add("sampleKey1");
            keyList.Add("sampleKey2");

            // Invalidate the made up cached objects.
            cp.Cache.InvalidateTagList(keyList);

            return "";
        }
    }
}

[deprecated] Read()

Use GetText(key) instead. Read a key from the cache.

Signatures

Read(string key);

Arguments

key
string
call-by-value
Cache object referenced by key.


[deprecated] Save()

Use Store(). Saves a key=value pair.

Signatures

Save(string key, string Value);

Save(string key, string Value, string tagCommaList);

Save(string key, string Value, string tagCommaList, 
    DateTime ClearOnDate);

Arguments

ClearOnDate
DateTime
call-by-value
Saved object is cleared on this date.

key
string
call-by-value
The name of the key that will reference the cached object.

tagCommaList
string
call-by-value
A comma delimited list of tags that reference the cached object.

value
string
call-by-value
The object to cache.

Return

void

[deprecated] SetKey()

Set a cache key.

Signatures

SetKey(string key, object Value);

SetKey(string key, object Value, DateTime invalidationDate);

SetKey(string key, object Value, DateTime invalidationDate, 
    List<string> tagList);

SetKey(string key, object Value, DateTime invalidationDate, 
    string tag);

SetKey(string key, object Value, List<string> tagList);

SetKey(string key, object Value, string tag);

Arguments

invaldiationDate
DateTime
call-by-value
Specified date to invalidate the stored key.

key
string
call-by-value
Name of the key.

tag
string
call-by-value
Tag associated with the cached object.

tagList
List<String>
call-by-value
List of tags associated with the cached object.

value
object
call-by-value
The object to cache.

Return

void

Store()

Store an object to a key.

Signatures

// Invalidate the object if a dependentKey 
// is updated after this object is stored.
Store(string key, object value, List<string> dependentKeyList);

// Invalidate the object if a dependentKey 
// is updated after this object is stored.
Store(string key, object value, string dependentKey);

Store(string key, object value);

Store(string key, object value, DateTime invalidationDate);

Store(string key, object value, DateTime invalidationDate, 
    List<string> dependentKeyList);

Store(string key, object value, DateTime invalidationDate, 
    string dependentKey);

Arguments

dependentKey
string
call-by-value
A single dependent key. If the record(s) referenced by the dependent key are changed, the cache will be invalidated.. The dependent keys can be made with methods like CreateKey().

dependentKeyList
List<String>
call-by-value
A list object containing multiple dependentKeys. If any of the records referenced by the keys are changed, the cache will be invalidated. The dependent keys can be made with methods like CreateKey().

invalidationDate
DateTime
call-by-value
Specified date to invalidate the stored object.

key
string
call-by-value
Name of the key that the object is stored under.

value
object
call-by-value
The value to cache.

Return

void

Examples:

using Contensive.BaseClasses;
using System;

namespace Contensive.Samples
{
    public class CacheStoreSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Get the unique record name
            string name = cp.Content.GetRecordName("Sample Content", 5);
            string tableName = "sampleContent";

            // Create the key
            string key = cp.Cache.CreatePtrKeyforDbRecordGuid(name, tableName);

            // Cache will invalidate in 5 days from creation
            DateTime invalidationDate = DateTime.Now.AddDays(5);

            // Cache will invalidate if any changes are made to the 
            // Sample Content table.
            string dependentKey = cp.Cache.CreateKeyForDbRecord(5, "sampleContent");

            // Cache the object
            cp.Cache.Store(key, name, invalidationDate, dependentKey);

            return "The value of the cached record: " + cp.Cache.GetText(key)
                + "<br>The key: " + key;
        }
    }
}

UpdateLastModified()

Updates the cache dependency key for the specified table when one of its records has been modified.

Signatures

UpdateLastModified(string tableName);

Arguments

tableName
string
call-by-value
Name of the desired Db table.

Return

void

CPContentBaseClass


CP.Content - contains features related to the content engine.


Methods


[deprecated] AbortEdit()

Workflow editing is deprecated. Discard changes made to content.

Signatures

AbortEdit(string ContentName, int RecordId);

Arguments

ContentName
string
call-by-value
Name of desired content.

RecordID
int
call-by-value
ID number of desired record.

Return

void

AddContent()

Adds content. See signature comments for further functionality.

Signatures

// Create a new content with default fields. 
// sqlTablename created from contentName. 
// After the call, modify the content with the database model.
AddContent(string ContentName);

// Create a new content with sqlTablename and default 
// fields. After the call, modify the content with the 
// database model.
AddContent(string ContentName, string sqlTableName);

// Create new content with sqlTablename and default fields
// on the default datasource. Modify the content with
// the database model.
AddContent(string ContentName, string sqlTableName, 
    string dataSource);

Arguments

ContentName
string
call-by-value
Name of desired content.

dataSource
string
call-by-value
The default data source.

sqlTableName
string
call-by-value
Desired name of SQL table.

Return

int
Return the record ID number for the new content.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddContentSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string ContentName = "Example Content";
            string sqlTableName = "exampleContent";
            string dataSource = "default";

            cp.Content.AddContent(ContentName, sqlTableName, dataSource);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

AddContentField()

Create a new field in an existing content.

Signatures

AddContentField(string ContentName, string FieldName, 
    fileTypeIdEnum fileTypeEnum);

AddContentField(string ContentName, string FieldName, 
    int FieldType);

Arguments

ContentName
string
call-by-value
Name of desired content.

FieldName
string
call-by-value
Desired field name to add.

FieldType
int
call-by-value
Integer reference to field type.

FieldType
int
call-by-value
Integer reference to field type.

fileTypeEnum
fileTypeIdEnum
call-by-value
Enum reference to file type.

Return

int
Return the ID number of the new field.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddContentFieldSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string content = "Sample Content";
            string fieldName = "Sample ID";

            // See fileTypeIdEnum for info on different types.
            int newFieldId = cp.Content.AddContentField(content, fieldName,
                CPContentBaseClass.fileTypeIdEnum.Integer);

            return fieldName + " ID#" + newFieldId + " is the new field in " +
                content;
        }
    }
}

AddRecord()

Inserts a record and returns its ID number.

Signatures

// Inserts a record
AddRecord(string ContentName);

// Inserts a record and sets its name
AddRecord(string ContentName, string recordName);

[deprecated]
AddRecord(object ContentName);

Arguments

ContentName
string
call-by-value
Name of desired content.

ContentName
object
call-by-value
Name of desired content.

recordName
string
call-by-value
Name of record to add.

Return

int
Return the ID number for the new record.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddRecordSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string fieldName = "Sample ID";
            string ContentName = "Sample Content";
            int newRecordId = cp.Content.AddRecord(
                ContentName, fieldName);

            return "ID#" + newRecordId + " is the new record in " +
                fieldName;
        }
    }
}

[deprecated] ApproveEdit()

Workflow editing is deprecated. Approve changes made to content.

Signatures

ApproveEdit(string ContentName, int RecordId);

Arguments

ContentName
string
call-by-value
Name of desired content.

RecordID
int
call-by-value
ID number of desired record.

Return

void

Delete()

Delete records based from a table based on a content name and SQL criteria.

Signatures

Delete(string ContentName, string SQLCriteria);

Arguments

ContentName
string
call-by-value
Name of desired content.

SQLCriteria
string
call-by-value
SQL criteria to select which records to delete.

Return

void

DeleteContent()

Delete a content from the system, sqlTable is left intact.

Signatures

DeleteContent(string ContentName);

Arguments

ContentName
fileTypeIdEnum
call-by-value
Name of desired content.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DeleteContentSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            cp.Content.DeleteContent(ContensiveExamplesModel.contentName);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
        // Private inner model class that references the content attributes.
        private class ContensiveExamplesModel
        {
            public const string contentName = "Contensive Examples";
            public const string contentTableName = "contensiveExamples";
            private const string contentDataSource = "default";

        }
    }
}

GetAddLink()

Get an icon linked to the administration site which adds a new record to the content.

Signatures

GetAddLink(string ContentName, string PresetNameValueList, 
    bool AllowPaste, bool IsEditing);

Arguments

AllowPaste
bool
call-by-value
the returned string will include a cut icon if 'AllowPaste' is true and the content supports cut-paste from the public site.

ContentName
string
call-by-value
Name of desired content.

IsEditing
bool
call-by-value
This call returns nothing if 'IsEditing' is false. Set it to true if IsEditing(contentName) is true.

PresetNameValueList
string
call-by-value
A comma delimited list of name=value pairs. Each name is a field name and the value is used to prepopulate the new record.

Return

string
Return the add link.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetAddLinkSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string ContentName = "Sample Content";
            string PresetNameValueList = "";
            bool AllowPaste = false;
            // User must be editing for add link to appear.
            bool IsEditing = cp.User.IsEditing(ContentName);

            string addLink = cp.Content.GetAddLink(ContentName, 
                PresetNameValueList, AllowPaste, IsEditing);

            // Get a div tag with the add link inside,
            // see CPHtmlBaseClass for more info.
            string html = cp.Html.div(addLink);

            return html;
        }
    }
}

GetContentControlCriteria()

Returns an SQL compatible where-clause which includes all the content ID values allowed for this content name.

Signatures

GetContentControlCriteria(string ContentName);

Arguments

ContentName
string
call-by-value
Name of desired content.

Return

string
Return the SQL compatible where-clause as string.

GetCopy()

Get the string from the 'Copy Content' record based on it's name.

Signatures

GetCopy(string CopyName);

GetCopy(string CopyName, string DefaultContent);

GetCopy(string CopyName, string DefaultContent, 
    int personalizationPeopleId);

Arguments

CopyName
string
call-by-value
Name of the 'Copy Content' record.

DefaultContent
string
call-by-value
Provided default content that will be used to create the record if it does not already exist.

personalizationPeopleId
int
call-by-value
If the content relate's to a person record, the personalizationPeopleId is the ID number of the affected person record.

Return

string
Return the string from 'Copy Content'.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetCopySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string copyName = "Sample Copy";

            string copy = cp.Content.GetCopy(copyName);

            return "The copy: " + copy;
        }
    }
}

GetDataSource()

Get the datasource name of the content given.

Signatures

GetDataSource(string ContentName);

Arguments

ContentName
string
call-by-value
Name of desired content.

Return

string
Return the data source name.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetDataSourceSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Get the data source.
            string DS = cp.Content.GetDataSource("Sample Content");

            return "Sample Content belongs to the " +
                DS + " data source.";
        }
    }
}

GetEditLink()

Get an icon linked to the administration site which edits the referenced record. The record is identified by its ID. The recordname is only used for the display caption.

Signatures

GetEditLink(string ContentName, string RecordID, bool AllowCut, 
    string RecordName, bool IsEditing);

Arguments

AllowCut
bool
call-by-value
If true and the content allows cut and paste, then a cut icon will be included in the return string.

ContentName
string
call-by-value
Name of desired content.

IsEditing
bool
call-by-value
This call returns nothing if 'IsEditing' is false. Set it to true if IsEditing(contentName) is true.

RecordID
string
call-by-value
Desired content's ID number as string.

RecordName
string
call-by-value
Record name that is used as a caption for the label for easy identification of what is being edited.

Return

string
Return the edit link.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetEditLinkSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string ContentName = "Sample Content";
            string RecordID = "2";
            string RecordName = "SampleRecord2";
            bool AllowCut = false;
            // User must be editing for the edit link to appear.
            bool IsEditing = cp.User.IsEditing(ContentName);

            string editLink = cp.Content.GetEditLink(
                ContentName, RecordID, AllowCut, RecordName, IsEditing);

            // Get a div tag with the edit link inside,
            // see CPHtmlBaseClass for more info.
            string html = cp.Html.div(editLink);

            return html;
        }
    }
}

[deprecated] GetFieldProperty()

Use GetFieldMeta() along with the specified property.

Signatures

[deprecated]
GetFieldProperty(string ContentName, string FieldName, string PropertyName);

Arguments

ContentName
string
call-by-value
Name of desired content.

FieldName
string
call-by-value
Name of desired field.

PropertyName
string
call-by-value
Name of desired field property.


GetID()

Get the content ID number.

Signatures

GetID(string ContentName);

Arguments

ContentName
string
call-by-value
Name of desired content.

Return

int
Return the content's ID number.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class ContentGetIDSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            int ID = cp.Content.GetID("Sample Content");

            return "#" + ID + " Sample Content";
        }
    }
}

getLayout()

Gets the html layout field of a layout record.

Signatures

getLayout(string layoutName);

Arguments

layoutName
string
call-by-value
Name of desired layout.

Return

string
Return the layout name.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetLayoutSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string layout = cp.Content.getLayout("defaultLayout");

            return "The layout retrieved: " + layout;
        }
    }
}

GetLinkAliasByPageID()

Returns the primary link alias for the record id and querystringsuffix. The default link is returned if no alias exists.

Signatures

GetLinkAliasByPageID(int PageID, string QueryStringSuffix, string DefaultLink);

Arguments

DefaultLink
string
call-by-value
This value is returned if no link alias is found.

PageID
int
call-by-value
Document's page ID number - cp.Doc.PageId.

QueryStringSuffix
string
call-by-value
Name=value pairs in Querystring format that are used to identify additional link aliases.

Return

string
Return the link alias.

GetListLink()

Get a linked icon to the admin list page for the content.

Signatures

GetListLink(string ContentName);

Arguments

ContentName
string
call-by-value
Name of desired content.

Return

string
Return the list link.

GetPageLink()

Return the appropriate link for a page.

Signatures

GetPageLink(int PageID);

GetPageLink(int PageID, string QueryStringSuffix);

GetPageLink(int PageID, string QueryStringSuffix, bool AllowLinkAlias);

Arguments

AllowLinkAlias
bool
call-by-value
Alias linked can be used if true.

PageID
int
call-by-value
Document's page ID number - cp.Doc.PageId.

QueryStringSuffix
string
call-by-value
Name=value pairs in Querystring format that are used to identify additional link aliases.

Return

string
Return the appropriate link for a page.

[deprecated] GetProperty()

Use models to access record fields. Get a specified property from a specified content.

Signatures

GetProperty(string ContentName, string PropertyName);

Arguments

ContentName
string
call-by-value
Name of desired content.

PropertyName
string
call-by-value

Return

string
Return the field property.

GetRecordID()

Return a record's ID given it's name. If duplicates exist, the first one ordered by ID is returned.

Signatures

GetRecordID(string ContentName, string RecordName);

Arguments

ContentName
string
call-by-value
Name of desired content.

RecordName
string
call-by-value
Record name in the content.

Return

int
Return the record ID number.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetRecordIDSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string ContentName = "Sample Content";
            string recordName = "SampleRecord1";

            int recordId = cp.Content.GetRecordID(
                ContentName, recordName);

            return "The record ID is: " + recordId;
        }
    }
}

GetRecordName()

Return a records name given it's ID number.

Signatures

GetRecordName(string ContentName, int RecordID);

Arguments

ContentName
string
call-by-value
Name of desired content.

RecordID
int
call-by-value
ID number of desired content.

Return

string
Return the record name.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetRecordNameSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string ContentName = "Sample Content";
            int recordId = 1;

            string recordName = cp.Content.GetRecordName(
                ContentName, recordId);

            return "The record name is: " + recordName;
        }
    }
}

GetTable()

Get the table used for a content definition.

Signatures

GetTable(string ContentName);

Arguments

ContentName
string
call-by-value
Name of desired content.

Return

string
Return the table name.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetTableSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string content = "Sample Content";

            // Get the table name
            string table = cp.Content.GetTable(content);

            return content + " holds the " + 
                table + " table.";
        }
    }
}

GetTableID()

Return the recordId in the ccTables table for the specified table.

Signatures

GetTableID(string tableName);

Arguments

tableName
string
call-by-value
Name of desired table.

Return

int
Return the record ID number in the ccTables table for the given table.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetTableIDSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Get the table ID of the table
            // linked to 'Sample Content'
            int tableID = cp.Content.GetTableID(
                "sampleContent");

            return "The table ID is #" + tableID;
        }
    }
}

[deprecated] GetTemplateLink()

Template link is no longer supported. Gets an edit link for the specified template.

Signatures

GetTemplateLink(int TemplateID);

Arguments

TemplateID
int
call-by-value
ID number of desired template.

Return

string
Return a link to the template.

IsChildContent()

Used to test if the child content ID is a child of the parent content ID.

Signatures

IsChildContent(string ChildContentID, string ParentContentID);

Arguments

ChildContentID
string
call-by-value
Child content ID number as string.

ParentContentID
string
call-by-value
Parent content ID number as string.

Return

bool
Return true if the content is a child to the given parent, false if it is not.

IsField()

Used to test if a field exists in a content definition.

Signatures

IsField(string ContentName, string FieldName);

Arguments

ContentName
string
call-by-value
Name of desired content.

FieldName
string
call-by-value
Name of desired field in the content.

Return

bool
Return true if the field exists in a content definition, false if it does not.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class ContentIsFieldSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string ContentName = "Sample Content";
            string FieldName = "name";

            if(cp.Content.IsField(ContentName, FieldName)) {
                return FieldName + " is a field in " +
                    ContentName;
            } else
            {
                return FieldName + " is a field in " +
                    ContentName;
            }
        }
    }
}

IsLocked()

Used to test if a record is currently being edited.

Signatures

IsLocked(string ContentName, string RecordID);

Arguments

ContentName
string
call-by-value
Name of desired content.

RecordID
string
call-by-value
Record ID number of desired content as string.

Return

bool
Return true if the record is currently being edited, false if it is not.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class IsLockedSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string fieldName = "Sample ID";
            string content = "Sample Content";

            // Check if the field is locked
            if (cp.Content.IsLocked(content, fieldName))
            {
                return fieldName + " is locked";
            }
            else
            {
                return fieldName + " is not locked";
            }
        }
    }
}

[deprecated] IsWorkflow()

Workflow editing is deprecated. Used to test if the specified content is workflow.

Signatures

IsWorkflow(string ContentName);

Arguments

ContentName
string
call-by-value
Name of desired content.

Return

bool
Return true if the given content is workflow.

[deprecated] PublishEdit()

Workflow editing is deprecated. Publish changes made to content.

Signatures

PublishEdit(string ContentName, int RecordID);

Arguments

ContentName
string
call-by-value
Name of desired content.

RecordID
int
call-by-value
ID number of desired record.

Return

void

SetCopy()

Set a string in a 'Copy Content' record.

Signatures

SetCopy(string CopyName, string Content);

Arguments

Content
string
call-by-value
Content to be inserted into the 'Copy Content' record.

CopyName
string
call-by-value
Name of the 'Copy Content' record.

Return

void

Examples:

uusing Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SetCopySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string CopyName = "Sample Copy";

            cp.Content.SetCopy(CopyName, "Sample Content");

            return CopyName + " has been set.";
        }
    }
}

[deprecated] SubmitEdit()

Workflow editing is deprecated. Submit changes made to content.

Signatures

SubmitEdit(string ContentName, int RecordID);

Arguments

ContentName
string
call-by-value
Name of desired content.

RecordID
int
call-by-value
ID number of desired record.

Return

void

Enums


fileTypeIdEnum

File types that indicate the type of a content field upon creation.

Types

Integer = 1


cp.Content.fileTypeIdEnum.Integer
Text = 2


cp.Content.fileTypeIdEnum.Text
LongText = 3


cp.Content.fileTypeIdEnum.LongText
Boolean = 4


cp.Content.fileTypeIdEnum.Boolean
Date = 5


cp.Content.fileTypeIdEnum.Date
File = 6
				


cp.Content.fileTypeIdEnum.File
Lookup = 7


cp.Content.fileTypeIdEnum.Lookup
Redirect = 8


cp.Content.fileTypeIdEnum.Redirect
Currency = 9


cp.Content.fileTypeIdEnum.Currency
FileText = 10
				


cp.Content.fileTypeIdEnum.FileText
FileImage = 11


cp.Content.fileTypeIdEnum.FileImage
Float = 12


cp.Content.fileTypeIdEnum.Float
AutoIdIncrement = 13


cp.Content.fileTypeIdEnum.AutoIdIncrement
ManyToMany = 14


cp.Content.fileTypeIdEnum.ManyToMany
MemberSelect = 15


cp.Content.fileTypeIdEnum.MemberSelect
FileCSS = 16


cp.Content.fileTypeIdEnum.FileCSS
FileXML = 17


cp.Content.fileTypeIdEnum.FileXML
FileJavascript = 18


cp.Content.fileTypeIdEnum.FileJavascript
Link = 19


cp.Content.fileTypeIdEnum.Link
ResourceLink = 20


cp.Content.fileTypeIdEnum.ResourceLink
HTML = 21


cp.Content.fileTypeIdEnum.HTML
FileHTML = 22


cp.Content.fileTypeIdEnum.FileHTML

GoogleVisualizationStatusEnum

The status codes outputted by Google Visualization.

Types

OK = 1


cp.Content.GoogleVisualizationStatusEnum.OK
warning = 2


cp.Content.GoogleVisualizationStatusEnum.warning
ErrorStatus = 3


cp.Content.GoogleVisualizationStatusEnum.ErrorStatus

CPCSBaseClass


CP.CS - The primary interface to the database. This object is similar to a recordset. It includes features of the content meta data. When a record is inserted, the default values of the record are available to read.


Methods


Close()

Closes an open record set. Should be called every time a record set is opened.

Signatures

Close();

Arguments

No arguments.


Return

void

Delete()

Deletes the current row.

Signatures

Delete();

Arguments

No arguments.


Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSDeleteSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if(cs.Open("Sample Content"))
            {
                // Delete the current row of
                // the made up content table
                cs.Delete();

                cs.Close();
            }

            return "";
        }
    }
}

Dispose()

Support IDisposable.

Signatures

Dispose();

Arguments

No arguments.


Return

void

FieldOK()

Test if the given field is valid for this record set.

Signatures

FieldOK(string fieldName);

Arguments

fieldName
string
call-by-value
Name of the desired field.

Return

bool
Return true if the given field is valid, false if otherwise.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSFieldOKSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                // Test if the 'name' field in
                // people is OK.
                if(cs.FieldOK("name")) {
                    cs.Close();
                    return "Field is ok.";
                }               
            }
            return "";
        }
    }
}

GetAddLink()

Gets an icon linked to the add function in the admin site for this content.

Signatures

GetAddLink();

GetAddLink(string presetNameValueList);

GetAddLink(string presetNameValueList, bool allowPaste);

Arguments

allowPaste
bool
call-by-value
The returned string will include a cut icon if 'AllowPaste' is true and the content supports cut-paste from the public site.

presetNameValueList
string
call-by-value
insert description

Return

string
Return the icon linked to the add function in the admin site for this content.

GetBoolean()

Get the field value cast as a boolean.

Signatures

GetBoolean(string fieldName);

Arguments

fieldName
string
call-by-value
Name of desired field.

Return

bool
Return the field value cast as a boolean.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSGetBooleanSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                // Get the boolean of the first
                // person record's active status.
                if(cs.GetBoolean("active"))
                {
                    cs.Close();

                    return "User is active.";
                }
            }
            return "";
        }
    }
}

GetDate()

Gets the field value cast as a DateTime value.

Signatures

GetDate(string fieldName);

Arguments

fieldName
string
call-by-value
Name of desired field.

Return

DateTime
Return the field value cast as a DateTime value.

Examples:

using Contensive.BaseClasses;
using System;

namespace Contensive.Samples
{
    public class CSGetDateSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                // Get the date of the first
                // person record's last visit.
                DateTime lastVisit = 
                    cs.GetDate("lastvisit");

                cs.Close();

                return "Last visitted on: " +
                    lastVisit;
            }
            return "";
        }
    }
}

GetEditLink()

Gets an icon linked to the edit function in the admin site for this content.

Signatures

GetEditLink();

GetEditLink(bool allowCut);

Arguments

allowCut
bool
call-by-value
If true and the content allows cut and paste, then a cut icon will be included in the return string.

Return

string
Return the icon linked to the edit function in the admin site for this content.

GetFilename()

If the field stores content in an external file, this method returns the filename for the field. Use this call to create the appropriate filename when a new file is added. The ContentName argument is required if the data set was opened with a query inste

Signatures

GetFilename(string fieldName);

GetFilename(string fieldName, string originalFilename);

GetFilename(string fieldName, string originalFilename, string contentName);

Arguments

contentName
string
call-by-value
The desired content's contentName field.

fieldName
string
call-by-value
Name of desired field.

originalFilename
string
call-by-value
This file and path is relative to the site's content file path and does not include a leading slash. To use this file in a URL, prefix with cp.site.filepath.

Return

string
Return the filename for the field.

GetFormInput()

Returns a form input element based on a content field definition.

Signatures

GetFormInput(string contentName, string fieldName);

GetFormInput(string contentName, string fieldName, int height);

GetFormInput(string contentName, string fieldName, int height, int width);

GetFormInput(string contentName, string fieldName, int height, int width, string htmlId);

[deprecated]
GetFormInput(string contentName, string fieldName, string height);

[deprecated]
GetFormInput(string contentName, string fieldName, string height, string width);

[deprecated]
GetFormInput(string contentName, string fieldName, string height, string width, string htmlId);

Arguments

contentName
string
call-by-value
The name of the desired content table.

fieldName
string
call-by-value
Field name in the inputted content.

height
int
call-by-value
Height of the form.

htmlId
string
call-by-value
The HTML element ID attribute.

width
int
call-by-value
Width of the form.

Return

object
Return the form input element.

GetHtml()

Gets the result of getText() after verifying its content is valid for use in HTML content. The content is returned without conversion If the field is a fieldTypeHtml. If the field is any other type, the content is HtmlEncoded first.

Signatures

GetHtml(string fieldName);

Arguments

fieldName
string
call-by-value
Name of the desired field.

Return

string
Return the HTML as string.

GetInteger()

Gets the field value cast as an integer.

Signatures

GetInteger(string fieldName);

Arguments

fieldName
string
call-by-value
Name of the desired field.

Return

int
Return the field value cast as an integer value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSGetIntegerSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                // Get the number of visits for
                // the first people record.
                int visits =
                    cs.GetInteger("visits");

                cs.Close();

                return "Number of visits: " +
                    visits;
            }
            return "";
        }
    }
}

GetNumber()

Gets the field value cast as a double value.

Signatures

GetNumber(string fieldName);

Arguments

fieldName
string
call-by-value
Name of the desired field.

Return

double
Return the field value cast as a double value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSGetNumberSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            // Open a made of content table
            // containing user balances.
            if (cs.Open("User Balances"))
            {
                // Get the first person record's 
                // balance.
                double balance =
                    cs.GetNumber("balance");

                cs.Close();

                return "Current balance: $" +
                    balance;
            }
            return "";
        }
    }
}

GetRowCount()

Returns the number of rows in the result.

Signatures

GetRowCount();

Arguments

No arguments.


Return

int
Return the row count as an integer value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSGetRowCountSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                // Get the row count of the 
                // current record set returned by
                // open.
                int rowCount = cs.GetRowCount();

                cs.Close();

                return "The opened record set has " +
                    rowCount + " row(s)";
            }
            return "";
        }
    }
}

GetSQL()

Gets the query used to generate the results.

Signatures

GetSQL();

Arguments

No arguments.


Return

string
Return the query used to generate the results.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSGetSQLSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                string sql = cs.GetSQL();

                cs.Close();

                return "The query used to generate" +
                    "the results: " + sql;
            }
            return "";
        }
    }
}

GetText()

Gets the result and converts it to a text type. For field types that store text in files, the text is returned instead of the filename. These include textfile, cssfile, and javascriptfile. The filename is returned for file types that do not contain text.

Signatures

GetText(string fieldName);

Arguments

fieldName
string
call-by-value
Name of the desired field.

Return

string
Return the result converted to a text type.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSGetTextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                // Get the first person record's 
                // first name.
                string firstName = 
                    cs.GetText("firstname");

                cs.Close();

                return "Hello, " + firstName;
            }
            return "";
        }
    }
}

[deprecated] GetTextFile()

Use getText() to get copy, getFilename() to get file.

Signatures

GetTextFile(string FieldName);

Arguments

FieldName
string
call-by-value
Name of desired field.

Return

string
Return the text file.

GetValue()

Gets the value directly from the field, without the conversions associated with GetText().

Signatures

GetValue(string fieldName);

Arguments

fieldName
string
call-by-value
Name of the desired field.

Return

string
Return the value directly from the field.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSGetValueSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                // Get the first person record's 
                // first name.
                string firstName =
                    cs.GetValue("firstname");

                cs.Close();

                return "Hello, " + firstName;
            }
            return "";
        }
    }
}

GoFirst()

Move to the first record in the current record set.

Signatures

GoFirst();

Arguments

No arguments.


Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSGoFirstSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            string retVal = "";

            if (cs.Open("People"))
            {
                // Add the first ID to retVal
                retVal = "ID #" + cs.GetInteger("id");

                // Move forward in the record set
                cs.GoNext();
                retVal += " ID #" + cs.GetInteger("id");
                cs.GoNext();
                retVal += " ID #" + cs.GetInteger("id");

                // Go back to the first.
                cs.GoFirst();
                retVal += " ID #" + cs.GetInteger("id");

                cs.Close();
            }
            return retVal;
        }
    }
}

GoNext()

Move to the next record in a result set.

Signatures

GoNext();

Arguments

No arguments.


Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSGoNextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                // Move to the second record
                cs.GoNext();
                // Get the name field of the second
                // record
                string name = cs.GetText("name");

                cs.Close();

                return name;
            }
            return "";
        }
    }
}

Insert()

Insert a record, leaving the dataset open in this object. Call cs.close() to close the data.

Signatures

Insert(string contentName);

Arguments

contentName
string
call-by-value
The name of the desired content table.

Return

bool
Return true if the insertion was successful, false if otherwise.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSInsertSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            // Insert a default record.
            cs.Insert("People");

            // Close the record set afterwards.
            cs.Close();

            return "";
        }
    }
}

[deprecated] NextOK()

Move to the next record in a result set and return true if the row is valid.

Signatures

NextOK();

Arguments

No arguments.


Return

bool
Return true if the next record is valid, false if otherwise.

OK()

Tests if there is valid data in the current row of the result set.

Signatures

OK();

Arguments

No arguments.


Return

bool
Returns true if there is valid data in the current row of the result set, false if otherwise.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSOKSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                string retVal = "";

                // cs.OK() is typically used in 
                // while loops to determine
                // the stopping point.
                while(cs.OK())
                {
                    retVal += cs.GetText(
                        "name") + ";";

                    // Move to the next record
                    cs.GoNext();
                }

                cs.Close();

                return retVal;
            }
            return "";
        }
    }
}

Open()

Opens a record set with the records specified by the sqlCriteria.

Signatures

Open(string contentName);

Open(string contentName, string sqlCriteria);

Open(string contentName, string sqlCriteria, string sortFieldList);

Open(string contentName, string sqlCriteria, string sortFieldList, bool activeOnly);

Open(string contentName, string sqlCriteria, string sortFieldList, bool activeOnly, string selectFieldList);

Open(string contentName, string sqlCriteria, string sortFieldList, bool activeOnly, string selectFieldList, int pageSize);

Open(string contentName, string sqlCriteria, string sortFieldList, bool activeOnly, string selectFieldList, int pageSize, int pageNumber);

Arguments

activeOnly
bool
call-by-value
When true, only fields with the 'active' option turned on are selected. All fields are selected if false.

contentName
string
call-by-value
The name of the desired content table.

pageNumber
int
call-by-value
Given the number of records per page, divide that by the total number of records to determine which page will contain the desired records.

pageSize
int
call-by-value
Number of records per page. Use to limit the number of records opened.

selectFieldList
string
call-by-value
A comma delimited list of specific fields to open within the content table. See the example for format. All fields are opened by default.

sortFieldList
string
call-by-value
This list is equivalent to the 'ORDER BY' SQL keyword. It is a comma delimited list of terms that ill sort the resulting record set in ascending order by default.

sqlCriteria
string
call-by-value
The query criteria.

Return

bool
Return true if the record set was opened successfully, false if otherwise.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSOpenSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            // Open the content.
            if (cs.Open("People"))
            {
                // Manipulate the content here.

                // Close the content before
                // returning.
                cs.Close();
            }
            return "";
        }
    }
}

[deprecated] OpenGroupListUsers()

Use OpenGroupUsers instead. The GroupCommaList is a comma delimited list of groups and cannot handle group names that include a comma.

Signatures

OpenGroupListUsers(string GroupCommaList);

OpenGroupListUsers(string GroupCommaList, string SQLCriteria);

OpenGroupListUsers(string GroupCommaList, string SQLCriteria, string SortFieldList);

OpenGroupListUsers(string GroupCommaList, string SQLCriteria, string SortFieldList, bool ActiveOnly);

OpenGroupListUsers(string GroupCommaList, string SQLCriteria, string SortFieldList, bool ActiveOnly, int PageSize);

OpenGroupListUsers(string GroupCommaList, string SQLCriteria, string SortFieldList, bool ActiveOnly, int PageSize, int PageNumber);

Arguments

ActiveOnly
bool
call-by-value
When true, only fields with the 'active' option turned on are selected. All fields are selected if false.

GroupCommaList
string
call-by-value
Comma delimited list of group names.

PageNumber
int
call-by-value
Given the number of records per page, divide that by the total number of records to determine which page will contain the desired records.

PageSize
int
call-by-value
Number of records per page. Use to limit the number of records opened.

SortFieldList
string
call-by-value
This list is equivalent to the 'ORDER BY' SQL keyword. It is a comma delimited list of terms that ill sort the resulting record set in ascending order by default.

SQLCriteria
string
call-by-value
The SQL query criteria.

Return

bool
Return true if the record set was opened successfully, false if otherwise.

OpenGroupUsers()

Opens a record set with user records that are in a Group.

Signatures

OpenGroupUsers(List<string> groupList);

OpenGroupUsers(List<string> groupList, string sqlCriteria);

OpenGroupUsers(List<string> groupList, string sqlCriteria, string sortFieldList);

OpenGroupUsers(List<string> groupList, string sqlCriteria, string sortFieldList, bool activeOnly);

OpenGroupUsers(List<string> groupList, string sqlCriteria, string sortFieldList, bool activeOnly, int pageSize);

OpenGroupUsers(List<string> groupList, string sqlCriteria, string sortFieldList, bool activeOnly, int pageSize, int pageNumber);

OpenGroupUsers(string groupName);

OpenGroupUsers(string groupName, string sqlCriteria);

OpenGroupUsers(string groupName, string sqlCriteria, string sortFieldList);

OpenGroupUsers(string groupName, string sqlCriteria, string sortFieldList, bool activeOnly);

OpenGroupUsers(string groupName, string sqlCriteria, string sortFieldList, bool activeOnly, int pageSize);

OpenGroupUsers(string groupName, string sqlCriteria, string sortFieldList, bool activeOnly, int pageSize, int pageNumber);

Arguments

activeOnly
bool
call-by-value
When true, only fields with the 'active' option turned on are selected. All fields are selected if false.

groupList
List<String>
call-by-value
A list object containing multiple desired groupNames.

groupName
string
call-by-value
Name of desired group.

pageNumber
int
call-by-value
Given the number of records per page, divide that by the total number of records to determine which page will contain the desired records.

pageSize
int
call-by-value
Number of records per page. Use to limit the number of records opened.

sortFieldList
string
call-by-value
This list is equivalent to the 'ORDER BY' SQL keyword. It is a comma delimited list of terms that ill sort the resulting record set in ascending order by default.

sqlCriteria
string
call-by-value
The query criteria.

Return

bool
Return true if the record set was opened successfully, false if otherwise.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class OpenGroupUsersSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            string groupName = "Site Managers";
            string sqlCriteria = "(memberid = " + cp.User.Id + ")";

            // Open the records in 'Member Rules'.
            if(cs.OpenGroupUsers(groupName, sqlCriteria))
            {
                return cs.GetText("memberid");
            }
            return "";
        }
    }
}

OpenRecord()

Opens a record set with the record specified by the recordId.

Signatures

OpenRecord(string contentName, int recordId);

OpenRecord(string contentName, int recordId, string selectFieldList);

OpenRecord(string contentName, int recordId, string selectFieldList, bool activeOnly);

Arguments

activeOnly
bool
call-by-value
When true, only fields with the 'active' option turned on are selected. All fields are selected if false.

contentName
string
call-by-value
The name of the desired content table.

recordId
int
call-by-value
The ID number of the desired record.

selectFieldList
string
call-by-value
A comma delimited list of specific fields to open within the content table. See the example for format. All fields are opened by default.

Return

bool
Return true if the record was opened successfully, false if otherwise.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class OpenRecordSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            string contentName = "People";
            int recordId = cp.User.Id;
            string selectFieldList = "firstname,lastname";
            bool activeOnly = true;

            if(cs.OpenRecord(contentName, recordId, 
                selectFieldList, activeOnly))
            {
                string firstName = cs.GetText("firstname");
                string lastName = cs.GetText("lastname");

                cs.Close();

                return "Hello, " + firstName +
                    " " + lastName + "!";
            }
            return "";
        }
    }
}

OpenSQL()

Opens a record set based on an SQL statement.

Signatures

OpenSQL(string sql);

OpenSQL(string sql, string dataSourcename);

OpenSQL(string sql, string dataSourcename, int pageSize);

OpenSQL(string sql, string dataSourcename, int pageSize, int pageNumber);

Arguments

dataSourcename
string
call-by-value
Name of the content's data source.

pageNumber
int
call-by-value
Given the number of records per page, divide that by the total number of records to determine which page will contain the desired records.

pageSize
int
call-by-value
Number of records per page. Use to limit the number of records opened.

sql
string
call-by-value
The SQL query.

Return

bool
Return true if the record set was opened successfully, false if otherwise.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class OpenSQLSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            // Query ccMemberRules for all people that
            // belong to the 'Site Managers' group
            string sql = "select memberid from ccMemberRules where " +
                "groupid = " + cp.Db.EncodeSQLNumber(1);

            // Open the record set based on the sql query.
            if(cs.OpenSQL(sql))
            {
                // Get the name of the first person.
                string firstPerson = cp.Content.GetRecordName(
                    "People", cs.GetInteger("memberid"));

                cs.Close();

                return "The first person in the list is: " +
                    firstPerson;
            }
            return "";
        }
    }
}

[deprecated] OpenSQL2()

Use OpenSql().

Signatures

OpenSQL2(string SQL);

OpenSQL2(string SQL, string DataSourcename);

OpenSQL2(string SQL, string DataSourcename, int PageSize);

OpenSQL2(string SQL, string DataSourcename, int PageSize, int PageNumber);

Arguments

DataSourcename
string
call-by-value
Name of the content's data source.

PageNumber
string
call-by-value
Given the number of records per page, divide that by the total number of records to determine which page will contain the desired records.

PageSize
string
call-by-value
Number of records per page. Use to limit the number of records opened.

SQL
string
call-by-value
The SQL query.

Return

bool
Return true if the record set was opened successfully, false if otherwise.

Save()

Forces a save of any changes made to the current row. A save occurs automatically when the content set is closed or when it moves to another row.

Signatures

Save();

Arguments

No arguments.


Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSSaveSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                // Make a change in the current row.
                cs.SetField("nickname", "super user");

                // Force a save.
                cs.Save();

                cs.Close();
            }
            return "";
        }
    }
}

SetField()

Sets a value in a field of the current row.

Signatures

SetField(string fieldName, bool fieldValue);

SetField(string fieldName, DateTime fieldValue);

SetField(string fieldName, int fieldValue);

SetField(string fieldName, object fieldValue);

SetField(string fieldName, string fieldValue);

Arguments

fieldName
string
call-by-value
Name of the desired field.

fieldValue
string, int, bool, DateTime, object
call-by-value
Value to set in the field.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CSSetFieldSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the cs object.
            CPCSBaseClass cs = cp.CSNew();

            if (cs.Open("People"))
            {
                // Make a change in the current row.
                cs.SetField("firstname", "super user");

                cs.Close();
            }
            return "";
        }
    }
}

[deprecated] SetFile()

Use SetField() for all field types that store data in files (textfile, cssfile, etc).

Signatures

SetFile(string FieldName, string Copy, string ContentName);

Arguments

ContentName
string
call-by-value
The desired content's contentName field.

FieldName
string
call-by-value
Name of the desired field.

Return

void

SetFormInput()

Processes a value from the incoming request to a field in the current row.

Signatures

SetFormInput(string fieldName);

SetFormInput(string fieldName, string requestName);

Arguments

fieldName
string
call-by-value
Name of the desired field.

requestName
string
call-by-value
Name of the incoming request.

Return

void

CPDbBaseClass


The Db object handles direct access to the Database. The ContentSet functions in the CPCSBaseClass are prefered for general use.

Properties


SQLTimeout
int
Get or set the timeout for all Db methods in the current process.

public abstract int SQLTimeout { get; set; }

Methods


[deprecated] DbGetConnectionString()

Use Db.GetConnectionString().

Signatures

DbGetConnectionString(string DataSourcename);

Arguments

DataSourcename
string
call-by-value
Name of the desired data source.

Return

string
Return the connection string.

[deprecated] DbGetDataSourceType()

Use GetDataSourceType( dataSourceName )

Signatures

DbGetDataSourceType(string DataSourcename);

Arguments

DataSourcename
string
call-by-value
Name of the desired data source.

Return

int
Return an int referencing the data source type.

[deprecated] DbGetTableID()

Use GetTableId() instead.

Signatures

DbGetTableID(string TableName);

Arguments

TableName
string
call-by-value
Name of desired table.

Return

int
Return the table ID number.

[deprecated] DbIsTable()

Use isTable() instead.

Signatures

DbIsTable(string DataSourcename, string TableName);

Arguments

DataSourcename
string
call-by-value
Name of desired data source.

TableName
string
call-by-value
Name of desired table.

Return

bool
Return true if the given name is a table, false if otherwise.

[deprecated] DbIsTableField()

Use isTableField() instead.

Signatures

DbIsTableField(string DataSourcename, string TableName, string FieldName);

Arguments

DataSourcename
string
call-by-value
Name of desired data source.

FieldName
string
call-by-value
Name of desired field in the table.

TableName
string
call-by-value
Name of desired table.

Return

bool
Return true if the given table exists and the field exists within the table, false if otherwise.

Delete()

Delete the record specified by tablename and recordId.

Signatures

[deprecated]
Delete(string dataSourcename, string tableName, int recordId);

Delete(string tableName, int recordId);

Arguments

dataSourceName
string
call-by-value
Name of desired data source.

recordId
int
call-by-value
ID number of desired record in table.

tableName
string
call-by-value
Name of desired table.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DbDeleteSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Delete a made up record from a 
            // made up table.
            string tableName = "exampleTableName";
            int recordId = 2;

            cp.Db.Delete(tableName, recordId);

            return "";
        }
    }
}

Dispose()

Support disposable for non-default datasources.

Signatures

Dispose();

Arguments

No arguments.


Return

void

EncodeSQLBoolean()

Encode a boolean value to be used in an sql Query for this application. Boolean fields are stored as integers in Contensive. Example 'select id from ccmembers where active='+EncodeSqlBoolean(true).

Signatures

EncodeSQLBoolean(bool sourceBoolean);

Arguments

sourceBoolean
bool
call-by-value
The source boolean expression to be encoded.

Return

string
Return the encoded boolean.

Examples:

using Contensive.BaseClasses;
using System.Data;

namespace Contensive.Samples
{
    public class EncodeSQLBooleanSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Write a SQL query with the encoded boolean in
            // the 'where' clause.
            string sql = "select id from ccmembers where " +
                "active = " + cp.Db.EncodeSQLBoolean(true);

            DataTable activePeopleList = cp.Db.ExecuteQuery(sql);

            // Manipulate the DataTable here.

            return "";
        }
    }
}

EncodeSQLDate()

Encode a date value to be used in an sql Query for this application. Example 'select id from ccmembers where dateadded>'+EncodeSqlDate( myBirthday ).

Signatures

EncodeSQLDate(DateTime sourceDate);

Arguments

sourceDate
DateTime
call-by-value
The source DateTime value to be encoded.

sourceDate
DateTime
call-by-value
Encoded DateTime value to be used in a SQL query.

Return

string
The encoded DateTime value.

Examples:

using Contensive.BaseClasses;
using System.Data;

namespace Contensive.Samples
{
    public class EncodeSQLDateSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Write a SQL query with the encoded date in
            // the 'where' clause.
            string sql = "select id from ccmembers where " +
                "dateadded = " + cp.Db.EncodeSQLDate(
                    new System.DateTime(03/27/2019));

            DataTable PeopleTable = cp.Db.ExecuteQuery(sql);

            // Manipulate the DataTable here.

            return "";
        }
    }
}

EncodeSQLNumber()

Encode a numeric value (integer or double) to be used in an sql Query for this application.

Signatures

EncodeSQLNumber(double sourceNumber);

EncodeSQLNumber(int sourceNumber);

Arguments

sourceNumber
int, double
call-by-value
The source integer or double value to be encoded.

Return

string
The encoded integer or double value.

Examples:

using Contensive.BaseClasses;
using System.Data;

namespace Contensive.Samples
{
    public class EncodeSQLNumberSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Write a SQL query with the encoded number in
            // the 'where' clause.
            string sql = "select id from ccmembers where " +
                "birthdayyear = " + cp.Db.EncodeSQLNumber(
                    1995);

            DataTable peopleTable = cp.Db.ExecuteQuery(sql);

            // Manipulate the DataTable here.

            return "";
        }
    }
}

EncodeSQLText()

Encode a text string value to be used in an sql Query for this application. Example 'select id where name='+EncodeSqlText( 'bob' ).

Signatures

EncodeSQLText(string sourceText);

Arguments

sourceText
string
call-by-value
The source text string to be encoded.

Return

string
The encoded text string.

Examples:

using Contensive.BaseClasses;
using System.Data;

namespace Contensive.Samples
{
    public class EncodeSQLTextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Write a SQL query with the encoded text in
            // the 'where' clause.
            string sql = "select id from ccmembers where " +
                "name = " + cp.Db.EncodeSQLText(
                    cp.User.Name);

            DataTable peopleTable = cp.Db.ExecuteQuery(sql);

            // Manipulate the DataTable here.

            return "";
        }
    }
}

ExecuteNonQuery()

Execute an sql command on a specific datasource. No data is returned.

Signatures

ExecuteNonQuery(string sql);

ExecuteNonQuery(string sql, ref int recordsAffected);

[deprecated]
ExecuteNonQuery(string sql, string dataSourceName);

[deprecated]
ExecuteNonQuery(string sql, string dataSourceName, ref int recordsAffected);

Arguments

dataSourcename
string
call-by-value
Name of desired data source.

recordsAffected
int
call-by-reference
Call-by-reference return value of the number of records affected by the non query.

sql
string
call-by-value
The SQL query.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class ExecuteNonQuerySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string sql = "insert into ccmembers default values;";
            int recordsAffected = 0;

            // Execute the nonquery.
            cp.Db.ExecuteNonQuery(sql, ref recordsAffected);

            // Return the number of records affected by the 
            // nonquery.
            return recordsAffected + " new record was " +
                "added to People.";
        }
    }
}

ExecuteNonQueryAsync()

Execute an sql command on a specific datasource, returning immediately.

Signatures

ExecuteNonQueryAsync(string sql);

[deprecated]
ExecuteNonQueryAsync(string sql, string dataSourceName);

Arguments

dataSourcename
string
call-by-value
Name of desired data source.

sql
string
call-by-value
The SQL query.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class ExecuteNonQueryAsyncSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string sql = "insert into ccmembers default values;";

            // Execute the async nonquery which returns 
            // immediately.
            cp.Db.ExecuteNonQueryAsync(sql);

            // Return the number of records affected by the 
            // nonquery.
            return "The nonquery was executed.";
        }
    }
}

ExecuteQuery()

Execute a query and return a data table.

Signatures

ExecuteQuery(string sql);

ExecuteQuery(string sql, int startRecord);

[deprecated]
ExecuteQuery(string sql, string dataSourceName);

[deprecated]
ExecuteQuery(string sql, string dataSourceName, int startRecord);

[deprecated]
ExecuteQuery(string sql, string dataSourceName, int startRecord, int maxRecords);

Arguments

dataSourcename
string
call-by-value
Name of desired data source.

maxRecord
int
call-by-value
insert description

sql
string
call-by-value
The SQL query.

startRecord
int
call-by-value
insert description

Return

DataTable
Return the resulting DataTable object.

Examples:

using Contensive.BaseClasses;
using System.Data;

namespace Contensive.Samples
{
    public class ExecuteQuerySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Query ccMemberRules for all people that
            // belong to the 'Site Managers' group
            string sql = "select memberid from ccMemberRules where " +
                "groupid = " + cp.Db.EncodeSQLNumber(1);

            // Execute the query.
            DataTable peopleTable = cp.Db.ExecuteQuery(sql);

            // Return the name of person in the first row
            // of the DataTable.
            return "The first person in the list is: " +
                cp.Content.GetRecordName(
                    "People", (int)peopleTable.Rows[0]["memberid"]);
        }
    }
}

ExecuteRemoteQuery()

For internal use. Execute a SQL query stored with getRemoteQueryKey.

Signatures

ExecuteRemoteQuery(string remoteQueryKey);

Arguments

remoteQueryKey
string
call-by-value
The remote query key obtained from Db.GetRemoteQueryKey().

Return

DataTable
Return the resulting DataTable object.

[deprecated] ExecuteSQL()

Convert to datatables and use executeQuery(), executeNonQuery(), or executeNonQueryAsync().

Signatures

ExecuteSQL(string SQL);

ExecuteSQL(string SQL, string DataSourcename);

ExecuteSQL(string SQL, string DataSourcename, string Retries);

ExecuteSQL(string SQL, string DataSourcename, string Retries, string PageSize);

ExecuteSQL(string SQL, string DataSourcename, string Retries, string PageSize, string PageNumber);

Arguments

DataSourcename
string
call-by-value
Name of desired data source.

PageNumber
string
call-by-value
Given the number of records per page, divide that by the total number of records to determine which page will contain the desired records.

PageSize
string
call-by-value
Number of records per page. Use to limit the number of records opened.

Retries
string
call-by-value
insert description

SQL
string
call-by-value
The SQL query.

Return

object
Return an object containing the data table.

GetConnectionString()

Get the connection string in the form of: server=({...});User Id={...};Password={...};Database={...};

Signatures

GetConnectionString();

[deprecated]
GetConnectionString(string dataSourcename);

Arguments

dataSourcename
string
call-by-value
Name of desired data source.

Return

string
Return the connection string.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetConnectionStringSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string connectionString = cp.Db.GetConnectionString();

            // Create your own database instance here.

            return ""; 
        }
    }
}

[deprecated] GetDataSourceType()

Only SQL Server is currently supported.

Signatures

GetDataSourceType(string DataSourcename);

Arguments

DataSourcename
string
call-by-value
Name of desired data source.

Return

int
Return an int referencing the data source type.

GetRemoteQueryKey()

For internal use. To give a remote method the ability to run an arbitrary query, store it as a remote query and executeRemoteQuery(). This key acts as a permission token for when an addon may need to execute a query.

Signatures

GetRemoteQueryKey(string sql);

GetRemoteQueryKey(string sql, int pageSize);

[deprecated]
GetRemoteQueryKey(string sql, string DataSourceName);

[deprecated]
GetRemoteQueryKey(string sql, string DataSourceName, int pageSize);

Arguments

DataSourceName
string
call-by-value
Name of desired data source.

pageSize
int
call-by-value
Number of records per page. Use to limit the number of records opened.

sql
string
call-by-value
The SQL query.

Return

string
Return the remote query key.

[deprecated] GetTableID()

Use CP.Content.GetTableId().

Signatures

GetTableID(string tableName);

Arguments

tableName
string
call-by-value
Name of desired table.

Return

int
Return the table ID number.

IsTable()

Used to test if the specified table is a valid database table in the current application.

Signatures

[deprecated]
IsTable(string dataSourcename, string tableName);

IsTable(string tableName);

Arguments

dataSourcename
string
call-by-value
Name of desired data source.

tableName
string
call-by-value
Name of desired table.

Return

bool
Return true if the given table name is a table, false if not.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class IsTableSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The 'People' content name.
            string tableName = "ccMembers";

            // Check if the table exists
            if(cp.Db.IsTable(tableName))
            {
                return tableName + 
                    " is a table.";
            } else
            {
                return tableName +
                    "is not a table.";
            }
        }
    }
}

IsTableField()

Used to test if the given field is a valid database field in a valid table in the current application

Signatures

[deprecated]
IsTableField(string dataSourcename, string tableName, string fieldName);

IsTableField(string tableName, string fieldName);

Arguments

dataSourcename
string
call-by-value
Name of desired data source.

fieldName
string
call-by-value
Name of desired field inside the table.

tableName
string
call-by-value
Name of desired table.

Return

bool
Return true if the given table is valid and the given field exists in the table.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class IsTableFieldSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The 'People' content name.
            string tableName = "ccMembers";

            // The 'firstname' field in the
            // ccMembers table.
            string fieldName = "firstname";

            // Check if the field exists
            // in the table.
            if (cp.Db.IsTableField
                (tableName, fieldName))
            {
                return fieldName + " is a field in " +
                    tableName + ".";
            }
            else
            {
                return fieldName + " is not a field in " +
                    tableName + ".";
            }
        }
    }
}

CPDocBaseClass


The Doc object handles features related to the document (page) being constructed in the current call.

Properties


Body
string
Body content of document.

public abstract string Body { get; set; }
IsAdminSite
bool
Returns true if current document is the admin site.

public abstract bool IsAdminSite { get; }
NoFollow
bool
Can the page be found by search engines.

public abstract bool NoFollow { get; set; }
PageId
int
Document's page ID.

public abstract int PageId { get; }
PageName
string
Name of page present on the document.

public abstract string PageName { get; }
RefreshQueryString
string
Current value of refresh query string.

public abstract string RefreshQueryString { get; }
StartTime
DateTime
The time and date for when this document was started.

public abstract DateTime StartTime { get; }
TemplateId
int
ID number of current document's template.

public abstract int TemplateId { get; }
Type
string
The docType that is set by the page manager settings.

public abstract string Type { get; }

Methods


AddBodyEnd()

Insert html before the end of the last body tag.

Signatures

AddBodyEnd(string html)

Arguments

html
string
call-by-value
Html to be inserted at the end of the body.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddBodyEndSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // This represents a Google analytics embed link
            string googleAnalyticsEmbed = "embed link";
            cp.Doc.AddBodyEnd(googleAnalyticsEmbed);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

AddHeadJavascript()

Adds Javascript code inside the head of the specified document. Code tags are automatically inserted.

Signatures

AddHeadJavascript(string code)

Arguments

code
string
call-by-value
Javascript code as string.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddHeadJavascriptSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string jsExample = "console.log(\"Hello World!\");";
            cp.Doc.AddHeadJavascript(jsExample);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

AddHeadStyle()

Adds css to the head of the specified document.

Signatures

AddHeadStyle(string styleSheet)

Arguments

styleSheet
string
call-by-value
The actual styles that are added to the page.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddHeadStyleSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string styleSheet = "body { background:green; }";

            cp.Doc.AddHeadStyle(styleSheet);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

AddHeadStyleLink()

Add a link to an external style sheet in the head of the specified document.

Signatures

AddHeadStyleLink(string styleSheetLink)

Arguments

styleSheetLink
string
call-by-value
Link to external style sheet as string.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddHeadStyleLinkSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string styleSheetLink = "https://mystyles.com";

            cp.Doc.AddHeadStyleLink(styleSheetLink);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

AddHeadTag()

Adds an empty html tag inside the head of the specified document.

Signatures

AddHeadTag(string htmlTag)

Arguments

htmlTag
string
call-by-value
The type of html tag to be inserted.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddHeadTagSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string emptyHeadTag = "<meta>";

            cp.Doc.AddHeadTag(emptyHeadTag);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

AddMetaDescription()

Add a meta description to the specified document.

Signatures

AddMetaDescription(string metaDescription)

Arguments

metaDescription
string
call-by-value
The meta description as string.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddMetaDescriptionSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string metaDescription = "Hello World!";

            cp.Doc.AddMetaDescription(metaDescription);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

AddMetaKeywordList()

Add a list of meta keywords to the specified document.

Signatures

AddMetaKeywordList(string metaKeywordList)

Arguments

metaKeywordList
string
call-by-value
Comma delimited meta keyword list as string.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddMetaKeywordListSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string metaKeywordList = "HTML, CSS, XML";

            cp.Doc.AddMetaKeywordList(metaKeywordList);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

AddOnLoadJavascript()

Adds Javascript code that is executed during the onload event.

Signatures

AddOnLoadJavascript(string code)

Arguments

code
string
call-by-value
Javascript code as string.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddOnloadJavascriptSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string jsExample = "console.log(\"Hello World!\");";
            cp.Doc.AddOnLoadJavascript(jsExample);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

AddRefreshQueryString()

Adds a refresh query string to the specified document.

Signatures

AddRefreshQueryString(string key, bool Value)

AddRefreshQueryString(string key, DateTime Value)

AddRefreshQueryString(string key, double Value)

AddRefreshQueryString(string key, int Value)

AddRefreshQueryString(string key, string Value)

Arguments

key
string
call-by-value
Key in a name=value pair.

Value
string, int, double, bool, DateTime
call-by-value
Value in the name=value pair.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddRefreshQueryStringSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "sampleKey";
            string Value = "sampleValue";

            cp.Doc.AddRefreshQueryString(key, Value);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

AddTitle()

Add a title to the specified document.

Signatures

AddTitle(string pageTitle)

Arguments

pageTitle
string
call-by-value
Title to add to document as string.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddTitleSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string pageTitle = "My webpage";

            cp.Doc.AddTitle(pageTitle);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

[deprecated] get_GlobalVar()

Behaves the same as GetText().

Signatures

get_GlobalVar(string Index);

Arguments

Index
string
call-by-value
Index of global variable to get.

Return

string
Return the global var as string.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocGet_GlobalVarSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Prompt the user for text that displays
            // in the body of the web page. Display
            // 'Hello world!' if there is no input.
            // Will need additional JS and
            // html to show the prompt.
            string key = "displayText";

            cp.Doc.Body = cp.Doc.get_GlobalVar(key);

            return "";
        }
    }
}

[deprecated] get_IsGlobalVar()

Check if the specified object is a global var.

Signatures

get_IsGlobalVar(string Index);

Arguments

Index
string
call-by-value
Index of desired content.

Return

bool
Return true if the specified object is a global var.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocIs_GlobalVarSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "totalPageVisits";

            if (cp.Doc.get_IsGlobalVar(key))
            {
                return key + " is a property.";
            }
            else
            {
                return key + " is not a property.";
            }
        }
    }
}

[deprecated] get_IsVar()

Checks if the specified content is a variable. Behaves the same as IsProperty().

Signatures

get_IsVar(string Index);

Arguments

Index
string
call-by-value
Index of specified object.

Return

bool
Return true if the specified object is a variable.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocGet_IsVarSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "headerName";

            if (cp.Doc.get_IsVar(key))
            {
                return key + " is a property.";
            }
            else
            {
                return key + " is not a property.";
            }
        }
    }
}

[deprecated] get_Var()

Get a variable. Behaves the same as GetText().

Signatures

get_Var(string Index);

Arguments

Index
string
call-by-value
Index of specified object.

Return

string
Return the specified variable.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocGet_VarSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Prompt the user for text that displays
            // in the body of the web page. Display
            // 'Hello world!' if there is no input.
            // Will need additional JS and
            // html to show the prompt.
            string key = "displayText";
            string defaultValue = "Hello world!";

            cp.Doc.Body = cp.Doc.get_Var(key, defaultValue);

            return "";
        }
    }
}

GetBoolean()

Get the boolean value from the desired object.

Signatures

GetBoolean(string key);

GetBoolean(string key, bool defaultValue);

[deprecated]
GetBoolean(string key, string defaultValue);

Arguments

defaultValue
bool
call-by-value
Default value of the desired boolean.

key
string
call-by-value
Key of the desired boolean.

Return

bool
Return the value of the desired boolean.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocGetBooleanSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Make a form with a button
            string makeLarge = cp.Html5.CheckBox("largerText", false);
            string makeSmall = cp.Html5.CheckBox("smallerText", false);
            string button = cp.Html5.Button("button", "Submit");

            string form = cp.Html5.Form(makeLarge + "Check " +
                "the box to make the example's text " +
                "larger<br><br>" + makeSmall + "Check " +
                "the box to make the example's text " +
                "smaller<br><br>" + button + "<br>");

            string retVal = cp.Html5.Div(form, "example");

            // Check if the user clicked the Submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the Doc boolean property that is set
                // when the user clicks the Submit button.
                if (cp.Doc.GetBoolean("largerText"))
                {
                    cp.Doc.AddHeadStyle(".example {font-size: 32px;}");

                } else if (cp.Doc.GetBoolean("smallerText"))
                {
                    cp.Doc.AddHeadStyle(".example {font-size: 12px;}");

                }
            }
            // Return the initial form.
            return retVal;
        }
    }
}

GetDate()

Get the date property of the desired key.

Signatures

GetDate(string key);

GetDate(string key, DateTime defaultValue);

[deprecated]
GetDate(string key, string defaultValue);

Arguments

defaultValue
DateTime
call-by-value
Default DateTime value of the desired object.

key
string
call-by-value
Key of the desired object.

Return

DateTime
Return the DateTime of the desired object.

Examples:

using Contensive.BaseClasses;
using System;

namespace Contensive.Samples
{
    public class DocGetDateSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input date field and submit button.
            string date = cp.Html5.InputDate("dateOfBirth");
            string button = cp.Html5.Button("button", "Submit");

            // Add the date field and submit button to the form.
            string innerHtml = "Enter your birthday:<br>" +
                date + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the date they entered.
                DateTime input = cp.Doc.GetDate("dateOfBirth");
                // Display the form along with the user input.
                return form + cp.Html5.P("Your birthday is:<br>" 
                    + input.ToShortDateString());
            }
            // Return the initial form.
            return form;
        }
    }
}

GetInteger()

Get the int value from the desired object.

Signatures

GetInteger(string key);

GetInteger(string key, int defaultValue);

[deprecated]
GetInteger(string key, string defaultValue);

Arguments

defaultValue
int
call-by-value
Int value of the desired object.

key
string
call-by-value
Key of the desired object.

Return

int
Return the int value of the desired object.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocGetIntegerSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The button.
            string button = cp.Html5.Button("button", "Click me!");

            // Add both buttons to the form.
            string form = cp.Html5.Form(button);

            // Check if the user clicked the Surpise1 button.
            if (cp.Doc.GetText("button").Equals("Click me!"))
            {
                cp.Doc.SetProperty("randomInt", 
                    cp.Utils.GetRandomInteger().ToString());
                // Return the form and get the 'randomInt' 
                // Doc property with GetInteger
                return form + cp.Html5.P("Here's a random " +
                    "number: " + cp.Doc.GetInteger("randomInt"));
            }
            // Return the initial form.
            return form;
        }
    }
}

GetNumber()

Get the double value of the desired object.

Signatures

GetNumber(string key);

GetNumber(string key, double defaultValue);

[deprecated]
GetNumber(string key, string defaultValue);

Arguments

defaultValue
double
call-by-value
Default value of the desired object.

key
string
call-by-value
Key of the desired object.

Return

double
Return the double value of the desired object.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocGetNumberSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input text field and submit button.
            string text = cp.Html5.InputText("answer", 50);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = "What is 5.75 - .13?<br>" + text 
                + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the double value they entered with the
                // GetNumber method.
                double input = cp.Doc.GetNumber("answer");
                // Display the form along with the user input.
                if(input == 5.62)
                {
                    return form + cp.Html5.P("Correct!");
                } else
                {
                    return form + cp.Html5.P("Wrong answer!");
                }
            }
            // Return the initial form.
            return form;
        }
    }
}

GetProperty()

Get a CP.Doc property.

Signatures

GetProperty(string key);

GetProperty(string key, string defaultValue);

Arguments

defaultValue
string
call-by-value
Default value of desired property.

key
string
call-by-value
Key of desired property.

Return

string
Returns the desired property as string.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocGetPropertySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input text field and submit button.
            string text = cp.Html5.InputText("textInput", 50);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = "Do you like standing? yes/no<br>" +
                text + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the text they entered using GetProperty().
                if (cp.Doc.GetProperty("textInput").Equals("yes"))
                {
                    return form + cp.Html5.P("Nice!");
                }
                else
                {
                    return form + cp.Html5.P("Sitting is fun too.");
                }
            }
            // Return the initial form.
            return form;
        }
    }
}

GetText()

Get the text from the desired key.

Signatures

GetText(string key);

GetText(string key, string defaultValue);

Arguments

defaultValue
string
call-by-value
Default value of the desired object.

key
string
call-by-value
Key of the desired object.

Return

string
Return the text from the desired object.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocGetTextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input text field and submit button.
            string text = cp.Html5.InputText("textInput", 50);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = "Do you like cars? yes/no<br>" +
                text + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the text they entered using GetText()
                if(cp.Doc.GetText("textInput").Equals("yes"))
                {
                    return form + cp.Html5.P("Nice!");
                } else
                {
                    return form + cp.Html5.P("Walking is fun too.");
                }           
            }
            // Return the initial form.
            return form;
        }
    }
}

IsProperty()

Checks if the specified key is a CP.Doc property.

Signatures

IsProperty(string key);

Arguments

key
string
call-by-value
Desired key to check if it is a property.

Return

bool
Return true if the specified key is a CP.Doc property.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocIsPropertySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "totalPageVisits";

            if (cp.Doc.IsProperty(key))
            {
                return key + " is a property.";
            }
            else
            {
                return key + " is not a property.";
            }
        }
    }
}

[deprecated] set_GlobalVar()

Set the value of a global variable. Behaves the same as SetProperty().

Signatures

set_GlobalVar(string Index, string Value);

Arguments

Index
string
call-by-value
Index of global var.

Value
string
call-by-value
New value for the desired global var.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocSet_GlobalVarSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "pageName";
            string value = "Page #" + cp.Doc.PageId;

            cp.Doc.set_GlobalVar(key, value);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

[deprecated] set_Var()

Set the value of a variable. Behaves the same as SetProperty().

Signatures

set_Var(string Index, string Value);

Arguments

Index
string
call-by-value
Index of the specified object.

Value
string
call-by-value
New value for the specified object.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocSet_VarSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "pageName";
            string value = "Page #" + cp.Doc.PageId;

            cp.Doc.set_Var(key, value);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

SetProperty()

Set a property of the specified document by accessing it via key-value pairs.

Signatures

SetProperty(string key, bool value);

SetProperty(string key, DateTime value);

SetProperty(string key, double value);

SetProperty(string key, int value);

SetProperty(string key, string value);

Arguments

key
string
call-by-value
Desired property's key.

value
string, int, double, bool, DateTime
call-by-value
New value for specified property.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DocSetPropertyExample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "pageName";
            string value = "Page #" + cp.Doc.PageId;

            cp.Doc.SetProperty(key, value);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

CPEmailBaseClass


CP.Email handles sending emails from a Contensive site.

Properties


fromAddressDefault
string
The site's default "from" email address.

public abstract string fromAddressDefault { get; }

Methods


send()

Sends an email to an email address.

Signatures

send(string toAddress, string fromAddress, string subject, 
    string body);

send(string toAddress, string fromAddress, string subject, 
    string body, bool sendImmediately);

send(string toAddress, string fromAddress, string subject, 
    string body, bool sendImmediately, 
    bool bodyIsHTML, ref string userErrorMessage);

send(string toAddress, string fromAddress, string subject, 
    string body, bool sendImmediately, bool bodyIsHTML);

Arguments

body
string
call-by-value
Body content of email.

bodyIsHTML
bool
call-by-value
True if the body content contains html and not just text.

fromAddress
string
call-by-value
Email address of sender.

sendImmediately
bool
call-by-value
Send email immediately if true.

subject
string
call-by-value
Subject line of email.

toAddress
string
call-by-value
Recipient email address.

userErrorMessage
string
call-by-reference
Call-by-reference string that gets updated if an error occurs in sending the email.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SendSample : AddonBaseClass
    {    
        public override object Execute(CPBaseClass cp)
        {
            string toAddress = "them@example.com";
            string fromAddress = "me@contensive.com";

            string subject = "Regarding the recent example";
            string body = "It was great!";

            string userErrorMessage = "Error temp";

            bool sendImmediately = true;
            bool bodyIsHTML = false;

            cp.Email.send(toAddress, fromAddress,
                subject, body, sendImmediately,
                bodyIsHTML, ref userErrorMessage);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

sendForm()

Sends an email that includes all the form elements in the current webpage response.

Signatures

sendForm(string toAddress, string fromAddress, string subject);

sendForm(string toAddress, string fromAddress, string subject, 
    ref string userErrorMessage);

Arguments

fromAddress
string
call-by-value
Email address of sender.

subject
string
call-by-value
Subject line of email.

toAddress
string
call-by-value
Recipient email address.

userErrorMessage
string
call-by-reference
Call-by-reference string that gets updated if an error occurs in sending the email.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SendFormSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string toAddress = "them@example.com";
            string fromAddress = "me@contensive.com";

            string subject = "Send Form Example";

            cp.Email.sendForm(toAddress, fromAddress, subject);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

sendGroup()

Sends an email to everyone in a group list. The list can be of Group Ids or names. Group names in the list can not contain commas.

Signatures

sendGroup(int groupId, string fromAddress, 
    string subject, string body);

sendGroup(int groupId, string fromAddress, string subject, 
    string body, bool sendImmediately);

sendGroup(int groupId, string fromAddress, string subject, 
    string body, bool sendImmediately, bool bodyIsHTML);

sendGroup(int groupId, string fromAddress, string subject, 
    string body, bool sendImmediately, bool bodyIsHTML, 
    ref string userErrorMessage);

sendGroup(List<int> groupIdList, string fromAddress, 
    string subject, string body);

sendGroup(List<int> groupIdList, string fromAddress, 
    string subject, string body, 
    bool sendImmediately, bool bodyIsHTML);

sendGroup(List<int> groupIdList, string fromAddress, 
    string subject, string body, bool sendImmediately);

sendGroup(List<int> groupIdList, string fromAddress, 
    string subject, string body, bool sendImmediately, 
    bool bodyIsHTML, ref string userErrorMessage);

sendGroup(List<string> groupNameList, string fromAddress, 
    string subject, string body);

sendGroup(List<string> groupNameList, string fromAddress, 
    string subject, string body, bool sendImmediately);

sendGroup(List<string> groupNameList, string fromAddress, 
    string subject, string body, bool sendImmediately, 
    bool bodyIsHTML);

sendGroup(List<string> groupNameList, string fromAddress, 
    string subject, string body, bool sendImmediately, 
    bool bodyIsHTML, ref string userErrorMessage);

sendGroup(string groupName, string fromAddress, 
    string subject, string body);

sendGroup(string groupName, string fromAddress, 
    string subject, string body, bool sendImmediately);

sendGroup(string groupName, string fromAddress, 
    string subject, string body, bool sendImmediately, 
    bool bodyIsHTML);

sendGroup(string groupName, string fromAddress, 
    string subject, string body, bool sendImmediately, 
    bool bodyIsHTML, ref string userErrorMessage);

Arguments

body
string
call-by-value
Body content of email.

bodyIsHTML
bool
call-by-value
True if the body content contains html and not just text.

fromAddress
string
call-by-value
Email address of sender.

groupId
int
call-by-value
An ID number of a single group.

groupIdList
List<int>
call-by-value
List of group ID numbers delimited by spaces only.

groupName
string
call-by-value
A single group name.

groupNameList
List<String>
call-by-value
List of group names delimited by spaces only.

sendImmediately
bool
call-by-value
Send email immediately if true.

subject
string
call-by-value
Subject line of email.

userErrorMessage
string
call-by-reference
Call-by-reference string that gets updated if an error occurs in sending the email.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SendGroupSample : AddonBaseClass
    {    
        public override object Execute(CPBaseClass cp)
        {
            int groupId = cp.Group.GetId("Site Managers");
            string fromAddress = "example@contensive.com";

            string subject = "Hello Site Managers";
            string body = cp.Html5.P("You're doing" +
                " a great job!");

            bool sendImmediately = true;
            bool bodyIsHtml = true;


            cp.Email.sendGroup(groupId, fromAddress,
                subject, body, sendImmediately, bodyIsHtml);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

sendPassword()

Send an email to the given address that includes the username and password associated with that address.

Signatures

sendPassword(string userEmailAddress);

sendPassword(string userEmailAddress, 
    ref string userErrorMessage);

Arguments

userEmailAddress
string
call-by-value
Specified user's email address.

userErrorMessage
string
call-by-reference
Call-by-reference string that gets updated if an error occurs in sending the email.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SendPasswordSample : AddonBaseClass
    {    
        public override object Execute(CPBaseClass cp)
        {
            string userEmailAddress = "them@example.com";

            cp.Email.sendPassword(userEmailAddress);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

sendSystem()

Send a system email record. If the EmailIdOrName field contains a number, it is assumed first to be an Id.

Signatures

sendSystem(int emailId);

sendSystem(int emailId, string additionalCopy);

sendSystem(int emailId, string additionalCopy, 
    int additionalUserID);

sendSystem(int emailId, string additionalCopy, 
    int additionalUserID, ref string userErrorMessage);

sendSystem(string emailName);

sendSystem(string emailName, string additionalCopy);

sendSystem(string emailName, string additionalCopy, 
    int additionalUserID);

sendSystem(string emailName, string additionalCopy, 
    int additionalUserID, ref string userErrorMessage);

Arguments

additionalCopy
string
call-by-value
insert description

additionalUserID
int
call-by-value
insert description

emailId
int
call-by-value
Id number of specified email record.

emailName
string
call-by-value
Name of specified email record.

userErrorMessage
string
call-by-reference
Call-by-reference string that gets updated if an error occurs in sending the email.

Return

void

sendUser()

Send an email using the values in a user record.

Signatures

sendUser(int toUserId, string fromAddress, string subject, 
    string body);

sendUser(int toUserId, string fromAddress, string subject, 
    string body, bool sendImmediately);

sendUser(int toUserId, string fromAddress, string subject, 
    string body, bool sendImmediately, bool bodyIsHTML);

sendUser(int toUserId, string fromAddress, string subject, 
    string body, bool sendImmediately, bool bodyIsHTML, 
    ref string userErrorMessage);

[deprecated]
sendUser(string ToUserID, string FromAddress, 
    string Subject, string Body);

[deprecated]
sendUser(string ToUserID, string FromAddress, string Subject, 
    string Body, bool SendImmediately);

[deprecated]
sendUser(string ToUserID, string FromAddress, string Subject, 
    string Body, bool SendImmediately, bool BodyIsHTML);

Arguments

body
string
call-by-value
Body content of email.

bodyIsHTML
bool
call-by-value
True if the body content contains html and not just text.

fromAddress
string
call-by-value
Email address of sender.

sendImmediately
bool
call-by-value
Send email immediately if true.

subject
string
call-by-value
Subject line of email.

toUserId
int
call-by-value
Email recipient found via user ID number.

userErrorMessage
string
call-by-value
Call-by-reference string that gets updated if an error occurs in sending the email.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SendUserSample : AddonBaseClass
    {    
        public override object Execute(CPBaseClass cp)
        {
            int toUserId = 123;
            string fromAddress = cp.User.Email;

            string subject = "Hello Site Managers";
            string body = cp.Html5.P("You're doing " +
                "a great job!");

            cp.Email.sendUser(toUserId, fromAddress,
                subject, body);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

CPFileBaseClass


This class has been deprecated. use cp.File.cdn, cp.File.private, cp.File.appRoot, or cp.File.server instead. Handles file system methods.


Methods


[deprecated] AppendVirtual()

Append content to a text file in the content files. If the file does not exist it will be created.

Signatures

AppendVirtual(string Filename, string FileContent);

Arguments

FileContent
string
call-by-value
A test appended to the file.

Filename
string
call-by-value
The filename of the file to be appended. May include subfolders in the content file area. It should not include a leading slash. Folder slashes should be \.

Return

void

[deprecated] CopyVirtual()

Copies a file in the content file area to another. If the destination does not exist it is created. Filenames may include subfolders but should not include a leading slash.

Signatures

CopyVirtual(string SourceFilename, string DestinationFilename);

Arguments

DestinationFilename
string
call-by-value
Where to copy the file.

SourceFilename
string
call-by-value
File to copy.

Return

void

[deprecated] CreateFolder()

Create a folder given a physical folder path.

Signatures

CreateFolder(string FolderPath);

Arguments

FolderPath
string
call-by-value
The physical folder path.

Return

void

[deprecated] Delete()

Delete a file within the file space.

Signatures

Delete(string Filename);

Arguments

Filename
string
call-by-value
The filename of the file to be deleted. May include subfolders in the content file area. It should not include a leading slash. Folder slashes should be \.

Return

void

[deprecated] DeleteFolder()

Delete a folder within the file space.

Signatures

DeleteFolder(string folderPath);

Arguments

folderPath
string
call-by-value
Folder path within the file space.

Return

void

[deprecated] DeleteVirtual()

Delete a file in the content file area. The filename may contain subfolders and should not begin with a leading slash.

Signatures

DeleteVirtual(string Filename);

Arguments

Filename
string
call-by-value
The file to delete.

Return

void

[deprecated] fileExists()

Returns true if a file exists

Signatures

fileExists(string pathFileName);

Arguments

pathFileName
string
call-by-value
Path of desired file to check for existence.

Return

bool
Return true if file exists.

[deprecated] fileList()

Get a crlf delimited list of files in a given path. Each row is a tab delimited list of attributes for each file. The attributes are: Name, Attributes, DateCreated, DateLastAccessed, and DateLastModified

Signatures

fileList(string folderName);

fileList(string folderName, int pageSize);

fileList(string folderName, int pageSize, int pageNumber);

Arguments

folderName
string
call-by-value
Name of folder to get file list from.

pageNumber
int
call-by-value
Given the number of records per page, divide that by the total number of records to determine which page will contain the desired records.

pageSize
int
call-by-value
Number of records per page. Use to limit the number of records opened.

Return

string
Return a crlf delimited list of files contained within the given directory.

[deprecated] folderExists()

Returns true if a folder exists.

Signatures

folderExists(string folderName);

Arguments

folderName
string
call-by-value
Path of desired folder to check for existence.

Return

bool
Return true if folder exists.

[deprecated] folderList()

Get a crlf delimited list of folders in a given path. Each row is a tab delimited list of attributes for each folder. Attributes: Name, Attributes, DateCreated, DateLastAccessed, DateLastModified, and Type

Signatures

folderList(string folderName);

Arguments

folderName
string
call-by-value
Name of folder to get folder list from.

Return

string
Return a crlf delimited list of folders contained within the given directory.

[deprecated] getVirtualFileLink()

Returns a URL to a file in the File.cdn store.

Signatures

getVirtualFileLink(string virtualFilename);

Arguments

virtualFilename
string
call-by-value
File located in the File.cdn store.

Return

string
Return a URL to a file in the File.cdn store as string.

[deprecated] Read()

Read a text file within the file space.

Signatures

Read(string Filename);

Arguments

Filename
string
call-by-value
File to be read.

Return

string
Return the text contained within the file as string.

[deprecated] ReadVirtual()

Read a text file in the content file area. The filename may contain subfolders and should not begin with a leading slash.

Signatures

ReadVirtual(string Filename);

Arguments

Filename
string
call-by-value
File to be read.

Return

string
Return the text contained within the file as string.

[deprecated] Save()

Save or create a text file within the file space.

Signatures

Save(string Filename, string FileContent);

Arguments

FileContent
string
call-by-value
A test appended to the file.

Filename
string
call-by-value
File to be saved.

Return

void

[deprecated] SaveVirtual()

Save a text file in the content file area. The filename may contain subfolders and should not begin with a leading slash.

Signatures

SaveVirtual(string Filename, string FileContent);

Arguments

FileContent
string
call-by-value
A test appended to the file.

Filename
string
call-by-value
File to be saved.

Return

void

CPFileSystemBaseClass


The current class that handles file system methods. Access multiple file systems through cp.CdnFiles, cp.WwwFiles, cp.TempFiles, and cp.PrivateFiles.

Properties


PhysicalFilePath
string
The physical file path of the local storage for this resource.

public abstract string PhysicalFilePath { get; }

Methods


Append()

Append content to end of a text file.

Signatures

Append(string filename, string fileContent);

Arguments

fileContent
string
call-by-value
Text content to be appended.

filename
string
call-by-value
Target file to append text to.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class FileSystemAppendSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string filename = "ExampleFolder\\ExampleFile.txt";
            string fileContent = "Hello world!";

            cp.TempFiles.Append(filename, fileContent);

            return "";
        }
    }
}

Copy()

Copy a file. This method can copy a file from one location to another in the same file system. A file can also be copied from one file system to another. See the examples for both cases.

Signatures

// Copy a file to a different filesystem.
// (TempFiles, cndFiles, wwwFiles, privateFiles)
Copy(string sourceFilename, string destinationFilename, 
CPFileSystemBaseClass destinationFileSystem);

// Copy a file within the same filesystem.
// (TempFiles, cndFiles, wwwFiles, privateFiles)
Copy(string sourceFilename, string destinationFilename);

Arguments

destinationFilename
string
call-by-value
Name of file to paste the copied file's contents into. Can be just the filename with extension or the filename with a path that does not start with a '\'.

destinationFileSystem
CPFileSystemBaseClass
call-by-value
wwwFiles, cdnFiles, tempFiles, privateFiles, etc.

sourceFilename
string
call-by-value
File to be copied. Can be just the filename with extension or the filename with a path that does not start with a '\'.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DifferentFileSystemCopySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Source name/destination are the same, but
            // the destination will be a different file system.
            string SourceFilename = "TestFolder\\Source.txt";
            string DestinationFileName = "TestFolder\\Source.txt";

            // The destination is in the temp file system.
            CPFileSystemBaseClass destinationFileSystem = cp.TempFiles;

            // Copy the file from the WWW file system to the
            // temp file system.
            cp.WwwFiles.Copy(SourceFilename, DestinationFileName, 
                destinationFileSystem);

            return "";
        }
    }
}
using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SameFileSystemCopySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // 'Source.txt' stays the same, but the 
            // destination directory changes.
            string SourceFilename = "TestFolder\\Source.txt";
            string DestinationFilename = "SampleFolder\\Source.txt";

            // In CdnFiles, copy 'Source.txt' from 'TestFolder' 
            // to 'SampleFolder'. The copied file will remain
            // in CdnFiles.
            cp.CdnFiles.Copy(SourceFilename, DestinationFilename);

            return "";
        }
    }
}

CopyLocalToRemote()

Copy a file from the local storage to its remote store.

Signatures

CopyLocalToRemote(string pathFilename);

Arguments

pathFilename
string
call-by-value
Name and path of the file to copy. Include the dot extension in the filename. If a path needs to be specified, do not start the pathFilename with a '\'.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CopyLocalToRemoteSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string pathFilename = "SamplePath\\Sample.txt";

            cp.WwwFiles.CopyLocalToRemote(pathFilename);

            return "";
        }
    }
}

CopyRemoteToLocal()

Copy a file from the remote storate to its local store.

Signatures

CopyRemoteToLocal(string pathFilename);

Arguments

pathFilename
string
call-by-value
Name and path of the file to copy. Include the dot extension in the filename. If a path needs to be specified, do not start the pathFilename with a '\'.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CopyRemoteToLocalSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string pathFilename = "SamplePath\\Sample.txt";

            cp.CdnFiles.CopyRemoteToLocal(pathFilename);

            return "";
        }
    }
}

CreateFolder

Create a folder in a path. Path arguments should have no leading slash (ex: ParentFolder/NewFolder).

Signatures

CreateFolder(string pathFolder);

Arguments

pathFolder
string
call-by-value
The name of the new folder as well as the path. If a path is included, the pathFolder should not start with a '\'.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class FileSystemCreateFolderSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string FolderPath = "TestPath\\ExamplePath";

            cp.PrivateFiles.CreateFolder(FolderPath);

            return "";
        }
    }
}

DeleteFile()

Delete a file in a path. Path arguments should have no leading slash (ex: ParentFolder/FileToDelete.txt).

Signatures

DeleteFile(string pathFilename);

Arguments

pathFilename
string
call-by-value
Name and path of the file to delete. Include the dot extension in the filename. If a path needs to be specified, do not start the pathFilename with a '\'.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DeleteFileSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string pathFilename = "sample.txt";

            if(cp.CdnFiles.FileExists(pathFilename))
            {
                cp.CdnFiles.DeleteFile(pathFilename);
            }
            return "";
        }
    }
}

DeleteFolder()

Delete a folder and all files and subfolders. Path arguments should have no leading slash (ex ParentFolder/FolderToDelete).

Signatures

DeleteFolder(string folderPath);

Arguments

folderPath
string
call-by-value
The name and path of the folder to delete. If a path is included, the pathFolder should not start with a '\'.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class FileSystemDeleteFolderSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string folderPath = "SamplePath\\ExamplePath";

            cp.WwwFiles.DeleteFolder(folderPath);

            return "";
        }
    }
}

FileExists()

Tests if a file exists in the given path.

Signatures

FileExists(string pathFilename);

Arguments

pathFilename
string
call-by-value
Name and path of the desired file. Include the dot extension in the filename. If a path needs to be specified, do not start the pathFilename with a '\'.

Return

bool
Return true if the file exists, false if otherwsie.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class FileSystemFileExistsSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string Filename = "sample.txt";
            string file = "";

             if (cp.CdnFiles.FileExists(Filename))
             {
                file = cp.CdnFiles.Read(Filename);
             }
            return file;
        }
    }
}

FileList()

Get the details of all files in a folder. Path arguments should have no leading slash (ex: ParentFolder/FolderToDelete).

Signatures

FileList(string folderPath);

FileList(string folderPath, int pageSize);

FileList(string folderPath, int pageSize, int pageNumber);

Arguments

folderPath
string
call-by-value
The name and path of the desired folder. If a path is included, the pathFolder should not start with a '\'.

pageNumber
int
call-by-value
Given the number of records per page, divide that by the total number of records to determine which page will contain the desired records.

pageSize
int
call-by-value
Number of records per page. Use to limit the number of records opened.

Return

List<FileDetail>
Return a list object containing the file details of all files in the given folder.

Examples:

using Contensive.BaseClasses;
using System.Collections.Generic;

namespace Contensive.Samples
{
    public class FileSystemFileListSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string folderName = "SamplePath";

            List<cpfilesystembaseclass.filedetail> list = 
                cp.PrivateFiles.FileList(folderName);

            return "";
        }
    }
}

FolderExists()

Tests if a folder exists in the given path

Signatures

FolderExists(string folderName);

Arguments

folderName
string
call-by-value
The name and path of the desired folder. If a path is included, the pathFolder should not start with a '\'.

Return

bool
Return true if the folder exists, false if otherwise.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class FileSystemFolderExistsSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string folderName = "SamplePath\\ExamplePath";

            if (cp.WwwFiles.FolderExists(folderName))
            {
            return folderName + " exists.";
            }
            else
            {
            return folderName + " does not exist.";
            }
        }
    }
}

FolderList()

Get the details of all folders in a path. Path arguments should have no leading slash (ex: ParentFolder).

Signatures

FolderList(string folderPath);

Arguments

folderPath
string
call-by-value
The name and path of the desired directory. If a path is included, the pathFolder should not start with a '\'.

Return

List<FolderDetail>
Return a list object containing folder details of all folders in the given directory.

Read()

Read a text file. Path arguments should have no leading slash (ex: ParentFolder/FileToRead.txt).

Signatures

Read(string pathFilename);

Arguments

pathFilename
string
call-by-value
Name and path of the file to read. Include the dot extension in the filename. If a path needs to be specified, do not start the pathFilename with a '\'.

Return

string
Return the contents of the text file.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class FileSystemReadSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string sample = "";
            // Ensure that the file exists before it is read.
            if (cp.CdnFiles.FileExists("ExamplePath\\sample.txt"))
            { 
                sample = cp.CdnFiles.Read("ExamplePath\\sample.txt");
            }

            // Manipulate the text file here before returning it.

            return sample;
        }
    }
}

ReadBinary()

Read a file to a byte array. Path arguments should have no leading slash (ex: ParentFolder/FileToRead.bin).

Signatures

ReadBinary(string pathFilename);

Arguments

pathFilename
string
call-by-value
Name and path of the file to be read into a byte array. Include the dot extension in the filename. If a path needs to be specified, do not start the pathFilename with a '\'.

Return

byte[]
Return the byte array read from the file.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class ReadBinarySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Converting image files to a .bin file 
            // is a common usage of this method.
            string pathFilename = "SampleImage\\Image.png";
            // Ensure that the path and image exist.
            // SampleImage\Image.png is made up for 
            // the example.
            byte[] file = cp.WwwFiles.ReadBinary(pathFilename);

            return "";
        }
    }
}

Save()

Save content to a text file. Path arguments should have no leading slash (ex: ParentFolder/FileToSave.txt).

Signatures

Save(string pathFilename, string fileContent);

Arguments

fileContent
string
call-by-value
Content to save to the new text file.

pathFilename
string
call-by-value
Name and path of the file to save. Include the dot extension in the filename. If a path needs to be specified, do not start the pathFilename with a '\'.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class FileSystemSaveSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Given path in 'pathFilename' will be
            // created upon saving if it does not 
            // already exist.
            string pathFilename = "TestPath\\Text.txt";
            string fileContent = "Hello world!";

            cp.TempFiles.Save(pathFilename, fileContent);

            return "";
        }
    }
}

SaveBinary()

Save a byte array to a file. Path arguments should have no leading slash (ex: ParentFolder/FileToSave.bin).

Signatures

SaveBinary(string pathFilename, byte[] fileContent);

Arguments

fileContent
byte[]
call-by-value
The byte array to be saved in the new file.

pathFilename
string
call-by-value
Name and path of the file to save. Include the dot extension in the filename. If a path needs to be specified, do not start the pathFilename with a '\'.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SaveBinarySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Converting image files to a .bin file 
            // is a common usage of this method.
            string pathFilename = "SampleImage\\Image.png";
            // Ensure that the path and image exist.
            // SampleImage\Image.png is made up for 
            // the example.
            byte[] file = cp.WwwFiles.ReadBinary(pathFilename);
            
            // Do any manipulation to the binary array here
            // before it is saved to the file system.
            cp.TempFiles.SaveBinary("Sample.bin", file);

            return "";
        }
    }
}

SaveUpload()

Handle a file upload from a submitted post.

Signatures

SaveUpload(string htmlformName, ref string returnFilename);

SaveUpload(string htmlFormName, string folderPath, ref string returnFilename);

Arguments

folderPath
string
call-by-value
Directory of where to save the uploaded file. The folderPath should not start with a '\'.

htmlformName
string
call-by-value
Name of the HTML form with the submitted form.

returnFilename
string
call-by-reference
File that will contain the upload if the save is successful.

Return

bool
Return true if the upload was saved successfully, false if otherwise.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SaveUploadSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // This is the name attribute that acts as the 
            // key to access the uploaded file.
            string htmlFormName = "inputFile";

            // Use our form name for the actual file input box.
            string fileInput = cp.Html5.InputFile(htmlFormName);
            string submitButton = cp.Html5.Button("button", "Submit");

            // Put both the input file box and the submit button inside
            // the form.
            string innerHtml = fileInput + "<br><br>" + 
                submitButton + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // String that will hold the name of the file that 
            // is uploaded.
            string returnFilename = "";

            // If the user presses the submit button... 
            // The value of 'button' will be set to 
            // 'Submit' if it is clicked.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Using the call to SaveUpload as a conditional
                // handles the case in which no file is 
                // inputted before clicking the 'Submit' button.
                if (cp.TempFiles.SaveUpload(htmlFormName, 
                    ref returnFilename))
                {
                    return form + "Upload of the following file " +
                        "was successful: " + returnFilename;
                }
            }
            // Return the form at first. The above conditional
            // will be executed again once a file is inputted 
            // and the 'Submit' button is clicked.
            return form;
        }
    }
}

CPGroupBaseClass


The Group Object accesses group features. Group Features generally associate people and roles.


Methods


Add()

Add a new group.

Signatures

Add(string groupName);

Add(string groupName, string groupCaption);

Arguments

groupCaption
string
call-by-value
Caption for new group.

groupName
string
call-by-value
Name of new group.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddGroupSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string groupName = "Content Devs";

            cp.Group.Add(groupName);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

AddUser()

Add a user to a group.

Signatures

// Add a specified user to a group
AddUser(int groupId, int userId);

// Add a specified user to a group
AddUser(int groupId, int userId, DateTime dateExpires);

// Add a specified user to a group
AddUser(string groupNameIdOrGuid, int userId);

// Add a specified user to a group
AddUser(string groupNameIdOrGuid, int userId, 
    DateTime dateExpires);

// Add the current user to a group.
AddUser(int groupId);

// Add the current user to a group. 
AddUser(string groupNameIdOrGuid);

Arguments

dateExpires
DateTime
call-by-value
User will be removed from the group on this date.

groupId
int
call-by-value
ID number of specified group.

groupNameIdOrGuid
string
call-by-value
If argument is numeric, record is referenced by Id. If argument is guid, record is referenced by ccGuid. Otherwise argument is name.

userId
int
call-by-value
ID number of specified user.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddUserSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string groupNameIdOrGuid = "5";
            int userId = 123;

            System.DateTime dateExpires = new System.DateTime();

            cp.Group.AddUser(groupNameIdOrGuid, userId, dateExpires);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

Delete()

Delete a group.

Signatures

Delete(int groupId);

Delete(string groupNameIdOrGuid);

Arguments

groupId
int
call-by-value
ID number of specified group.

groupNameIdOrGuid
string
call-by-value
If argument is numeric, record is referenced by Id. If argument is guid, record is referenced by ccGuid. Otherwise argument is name.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class DeleteGroupSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {

            int groupId = 3;

            cp.Group.Delete(groupId);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

GetId()

Get a group Id.

Signatures

GetId(string groupNameOrGuid);

Arguments

groupNameOrGuid
string
call-by-value
If argument is guid, record is referenced by ccGuid. Otherwise argument is name.

Return

int
The group ID number.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetGroupIdSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {

            int groupId = cp.Group.GetId("Site Managers");

            // Add current user to Site Managers
            cp.Group.AddUser(groupId);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

GetName()

Get a group name.

Signatures

GetName(int groupId);

GetName(string GroupIdOrGuid);

Arguments

groupId
int
call-by-value
ID number of specified group.

GroupIdOrGuid
string
call-by-value
If argument is numeric, record is referenced by Id. Otherwise record is referenced by ccGuid.

Return

string
The group name.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetGroupNameSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            int groupId = 1;

            string groupName = cp.Group.GetName(groupId);

            cp.Group.AddUser(groupName);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

RemoveUser()

Remove a user from a group.

Signatures

// Remove a specified user from a group
RemoveUser(string groupNameIdOrGuid, int userId);

// Remove the current user from a group
RemoveUser(string groupNameIdOrGuid);

Arguments

groupNameIdOrGuid
string
call-by-value
If argument is numeric, record is referenced by Id. If argument is guid, record is referenced by ccGuid. Otherwise argument is name.

userId
int
call-by-value
Specified user ID number.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class RemoveUserSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            int userId = 123;
            string groupNameIdOrGuid = "Site Managers";

            cp.Group.RemoveUser(groupNameIdOrGuid, userId);

            // Return value is arbitrary for this
            // example because nothing needs to be 
            // explicitly returned to the user.
            return "";
        }
    }
}

CPHtml5BaseClass


The HTML5 class handles functions used to read and produce HTML elements. It is a newer version of the HTML class.


Methods


AdminHint()

Get HTML code for an admin hint.

Signatures

AdminHint(string innerHtml);

Arguments

innerHtml
string
call-by-value
The inner HTML.

Return

string
Return the admin hint.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5AdminHintSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {          
            string innerHtml = "Study the API docs!";

            string hint = cp.Html5.AdminHint(innerHtml);

            return hint;
        }
    }
}

Button()

Get HTML code for a button.

Signatures

Button(string htmlName);

Button(string htmlName, string htmlValue);

Button(string htmlName, string htmlValue, string htmlClass);

Button(string htmlName, string htmlValue, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
The value of the button.

Return

string
Return the button.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5ButtonSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The buttons.
            string button1 = cp.Html5.Button("button", "Surprise1");
            string button2 = cp.Html5.Button("button", "Surprise2");

            // Add both buttons to the form.
            string innerHtml = button1 + "<br><br>" + button2 + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the Surpise1 button.
            if (cp.Doc.GetText("button").Equals("Surprise1"))
            {
                return form + cp.Html5.P("Wow!");

            // Check if the user clicked the Surpise2 button.
            } else if (cp.Doc.GetText("button").Equals("Surprise2"))
            {
                return form + cp.Html5.P("Woah!");
            }
            // Return the initial form.
            return form;
        }
    }
}

CheckBox()

Get HTML code for a check box.

Signatures

CheckBox(string htmlName);

CheckBox(string htmlName);

CheckBox(string htmlName, bool htmlValue);

CheckBox(string htmlName, bool htmlValue, string htmlClass);

CheckBox(string htmlName, bool htmlValue, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
bool
call-by-value
The boolean value of the check box.

Return

string
Return the check box.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5CheckBoxSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Key that holds the boolean value.
            string htmlName = "exampleQuestion";
            string checkBox = cp.Html5.CheckBox(htmlName);

            string button = cp.Html5.Button("button", "Submit");

            // Add the checkbox, a message next to it, and
            // a submit button.
            string form = cp.Html5.Form(checkBox + "Click the box if " +
                "you like examples." + "<br>" + button + "<br><br>");

            // Check if the user clicked the submit button.
            if(cp.Doc.GetText("button").Equals("Submit"))
            {
                // If they clicked the checkbox.
                if(cp.Doc.GetBoolean("exampleQuestion"))
                {
                    return form + "We like them too! :)";
                } else // If they didn't click it.
                {
                    return form + "That's too bad! :(";
                }
            }
            // Return the initial form.
            return form;
        }
    }
}

CheckList()

Get HTML code for a check list.

Signatures

1. CheckList(string htmlName, string primaryContentName, int primaryRecordId, string secondaryContentName, string rulesContentName, string rulesPrimaryFieldname, string rulesSecondaryFieldName);

2. CheckList(string htmlName, string primaryContentName, int primaryRecordId, string secondaryContentName, string rulesContentName, string rulesPrimaryFieldname, string rulesSecondaryFieldName, string secondaryContentSelectSQLCriteria);

3. CheckList({All arguments from previous signature}, string captionFieldName);

4. CheckList({All arguments from previous signature}, bool isReadOnly);

5. CheckList({All arguments from previous signature}, string htmlClass);

6. CheckList({All arguments from previous signature}, string htmlId);

Arguments

captionFieldName
string
call-by-value
Name of the check list's caption field.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

isReadOnly
bool
call-by-value
If true, the check list will be read-only.

primaryContentName
string
call-by-value
The table being presented. ex. a list of groups that a person may join, this is the People content.

primaryRecordId
int
call-by-value
The id of the record in the primary content. ex. a list of groups that a person may join, this is the person's id.

rulesContentName
string
call-by-value
The table holding the relationship in a many to many connection. ex. a list of groups that a person may join, this is a table with a personid and a groupId.

rulesPrimaryFieldname
string
call-by-value
The field in the relationship table that identifies the record in the primary content. ex. a list of groups that a person may join, this the field in the raltionship table that points to the person record, like personId.

rulesSecondaryFieldName
string
call-by-value
The field in the relationship table that identifies the record in the secondary content. ex. a list of groups that a person may join, this the field in the raltionship table that points to the group record, like groupId.

secondaryContentName
string
call-by-value
The table being related. ex. a list of groups that a person may join, this is the group content.

secondaryContentSelectSQLCriteria
string
call-by-value
The checklist includes all the possible rlationships of the secondary content to the primary. This is the criteria part of a query (where clause) that limits the selection.

Return

string
Return the check list.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5CheckListSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string htmlName = "memberCheckList";

            // This is the content table we want to
            // act as our primary table. 
            string primaryContentName = "People";

            // The user will check on groups 
            // in the checklist they belong to.
            int primaryRecordId = cp.User.Id;

            // Each record in the 'Groups' 
            // content table will appear in the 
            // checklist.
            string secondaryContentName = "Groups";

            // The rules content table that exists
            // between both 'Groups' and 'People'. 
            // It has two fields that hold the 
            // primary content records and the 
            // secondary content records. 
            string rulesContentName = "Member Rules";
            string rulesPrimaryFieldName = "memberId";
            string rulesSecondaryFieldName = "groupId";

            // Add everything to the checkList
            string checkList = cp.Html5.CheckList(htmlName, 
                primaryContentName, primaryRecordId, 
                secondaryContentName, rulesContentName, 
                rulesPrimaryFieldName, rulesSecondaryFieldName);

            // Make a submit button
            string button = cp.Html5.Button("button", "Submit");

            // Add the checklist and submit button to the form.
            string innerHtml = "Select the groups you want to " +
                "be in:<br>" + checkList + "<br><br>" + button;

            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                cp.Html5.ProcessCheckList(htmlName, primaryContentName,
                    primaryRecordId.ToString(), secondaryContentName, rulesContentName,
                    rulesPrimaryFieldName, rulesSecondaryFieldName);

                return form + "Thank you";
            }
            // Return the initial form.
            return form;
        }
    }
}

Div()

Get HTML code for a div tag.

Signatures

Div(string innerHtml);

Div(string innerHtml, string htmlClass);

Div(string innerHtml, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

innerHtml
string
call-by-value
HTML inside the div tag.

Return

string
Return the div tag.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5DivSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string innerHtml = "Hello world!";
            string htmlClass = "exampleClass";

            string div = cp.Html5.Div(innerHtml, htmlClass);

            return div;
        }
    }
}

Form()

Get HTML code for a form.

Signatures

Form(string innerHtml);

Form(string innerHtml, string htmlName);

Form(string innerHtml, string htmlName, string htmlClass);

Form(string innerHtml, string htmlName, string htmlClass, string htmlId);

Form(string innerHtml, string htmlName, string htmlClass, string htmlId, string actionQueryString);

Form(string innerHtml, string htmlName, string htmlClass, string htmlId, string actionQueryString, string method);

Arguments

actionQueryString
string
call-by-value
The HTML form's action query string that dictates where the data from submitted fields are stored.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute that acts as a key to the data from the submitted fields.

innerHtml
string
call-by-value
HTML inside the form.

method
string
call-by-value
Choices are 'get' or 'post'. 'get' is the default method of requesting form-data in which the data is appended as key=value pairs in the URL's query string. 'post' is used to send the form-data as an HTTP POST.

Return

string
Return the form.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5FormSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input text field and submit button.
            string text = cp.Html5.InputText("textInput", 50);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = text + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if(cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the text they entered.
                string input = cp.Doc.GetText("textInput");
                // Display the form along with the user input.
                return form + cp.Html5.P("You entered:<br>" + input);
            }
            // Return the initial form.
            return form;
        }
    }
}

H1()

Get HTML code for a h1 tag.

Signatures

H1(string innerHtml);

H1(string innerHtml, string htmlClass);

H1(string innerHtml, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

innerHtml
string
call-by-value
HTML inside the h1 tag.

Return

string
Return the h1 tag.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5H1Sample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string innerHtml = "Hello World!";

            string H1 = cp.Html5.H1(innerHtml);

            return H1;
        }
    }
}

H2()

Get HTML code for a h2 tag.

Signatures

H2(string innerHtml);

H2(string innerHtml, string htmlClass);

H2(string innerHtml, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

innerHtml
string
call-by-value
HTML inside the h2 tag.

Return

string
Return the h2 tag.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5H2Sample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string innerHtml = "Hello World!";

            string H2 = cp.Html5.H2(innerHtml);

            return H2;
        }
    }
}

H3()

Get HTML code for a h3 tag.

Signatures

H3(string innerHtml);

H3(string innerHtml, string htmlClass);

H3(string innerHtml, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

innerHtml
string
call-by-value
HTML inside the h3 tag.

Return

string
Return the h3 tag.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5H3Sample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string innerHtml = "Hello World!";

            string H3 = cp.Html5.H3(innerHtml);

            return H3;
        }
    }
}

H4()

Get HTML code for a h4 tag.

Signatures

H4(string innerHtml);

H4(string innerHtml, string htmlClass);

H4(string innerHtml, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlid
string
call-by-value
The ID attribute.

innerHtml
string
call-by-value
HTML inside the h4 tag.

Return

string
Return the h4 tag.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5H4Sample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string innerHtml = "Hello World!";

            string H4 = cp.Html5.H4(innerHtml);

            return H4;
        }
    }
}

H5()

Get HTML code for a h5 tag.

Signatures

H5(string innerHtml);

H5(string innerHtml, string htmlClass);

H5(string innerHtml, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

innerHtml
string
call-by-value
HTML inside the h5 tag.

Return

string
Return the h5 tag.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5H5Sample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string innerHtml = "Hello World!";

            string H5 = cp.Html5.H5(innerHtml);

            return H5;
        }
    }
}

H6()

Get HTML code for a h6 tag.

Signatures

H6(string innerHtml);

H6(string innerHtml);

H6(string innerHtml, string htmlClass);

H6(string innerHtml, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

innerHtml
string
call-by-value
HTML inside the h6 tag.

Return

string
Return the h6 tag.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5H6Sample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string innerHtml = "Hello World!";

            string H6 = cp.Html5.H6(innerHtml);

            return H6;
        }
    }
}

Hidden()

Get the HTML code for a hidden element that is commonly used for getting data while not being seen by the user.

Signatures

Hidden(string htmlName, bool htmlValue);

Hidden(string htmlName, bool htmlValue, string htmlClass);

Hidden(string htmlName, bool htmlValue, string htmlClass, string htmlId);

Hidden(string htmlName, DateTime htmlValue);

Hidden(string htmlName, DateTime htmlValue, string htmlClass);

Hidden(string htmlName, DateTime htmlValue, string htmlClass, string htmlId);

Hidden(string htmlName, double htmlValue);

Hidden(string htmlName, double htmlValue, string htmlClass);

Hidden(string htmlName, double htmlValue, string htmlClass, string htmlId);

Hidden(string htmlName, int htmlValue);

Hidden(string htmlName, int htmlValue, string htmlClass);

Hidden(string htmlName, int htmlValue, string htmlClass, string htmlId);

Hidden(string htmlName, string htmlValue);

Hidden(string htmlName, string htmlValue, string htmlClass);

Hidden(string htmlName, string htmlValue, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string, int, double, bool, DateTime
call-by-value
The value of the desired HTML content.

Return

string
Return the hidden element.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5HiddenSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string htmlName = "sampleNumber";

            int htmlValue = cp.User.Id;

            string hiddenElement = cp.Html5.Hidden(htmlName, htmlValue);

            return hiddenElement;
        }
    }
}

InputDate()

Get HTML code for an input date field.

Signatures

InputDate(string htmlName);

InputDate(string htmlName, DateTime htmlValue);

InputDate(string htmlName, DateTime htmlValue, string htmlClass);

InputDate(string htmlName, DateTime htmlValue, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
DateTime
call-by-value
The inputted DateTime value.

Return

string
Return an HTML field to input a DateTime value.

Examples:

using Contensive.BaseClasses;
using System;

namespace Contensive.Samples
{
    public class Html5InputDateSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input date field and submit button.
            string date = cp.Html5.InputDate("dateInput");
            string button = cp.Html5.Button("button", "Submit");

            // Add the date field and submit button to the form.
            string innerHtml = date + "<br><br>" + 
                button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the date they entered.
                DateTime input = cp.Doc.GetDate("dateInput");
                // Display the form along with the user input.
                return form + cp.Html5.P("You entered:<br>" + input);
            }
            // Return the initial form.
            return form;
        }
    }
}

InputFile()

Get HTML code for an input file field.

Signatures

InputFile(string htmlName);

InputFile(string htmlName, string HtmlClass);

InputFile(string htmlName, string HtmlClass, string HtmlId);

Arguments

HtmlClass
string
call-by-value
The class attribute.

HtmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

Return

string
Return an HTML field to input a file.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5InputFileSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input text file and submit button.
            string file = cp.Html5.InputFile("fileInput");
            string button = cp.Html5.Button("button", "Submit");

            // Add the file field and submit button to the form.
            string innerHtml = file + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the name of the file they entered.
                string input = cp.Doc.GetText("fileInput");
                // Display the form along with the file name.
                return form + cp.Html5.P("You entered:<br>" + input);
            }
            // Return the initial form.
            return form;
        }
    }
}

InputHtml()

Get HTML code for an input HTML wysiwyg field.

Signatures

InputHtml(string htmlName, int maxLength);

InputHtml(string htmlName, int maxLength, string htmlValue);

InputHtml(string htmlName, int maxLength, string htmlValue, string htmlClass);

InputHtml(string htmlName, int maxLength, string htmlValue, string htmlClass, string htmlId);

InputHtml(string htmlName, int maxLength, string htmlValue, string htmlClass, string htmlId, bool viewAsHtmlCode);

InputHtml(string htmlName, int maxLength, string htmlValue, string htmlClass, string htmlId, EditorContentType contentType);

InputHtml(string htmlName, int maxLength, string htmlValue, string htmlClass, string htmlId, List<SimplestDataModel> addonList);

Arguments

addonList
List<SimplestDataModel>
call-by-value
A list of data model objects that contain an addon's name, ID, and ccGuid as public properties.

contentType
EditorContentType
call-by-value
Enumeration type indicating the type of content that can be edited in this HTML input field. See EditorContentType for more info.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
The value of the HTML input as text.

maxLength
int
call-by-value
Max character length of the text input.

viewAsHtmlCode
bool
call-by-value
True by default. If true, the user input will be executed as HTML code. If false, the user input will be treated as text.

Return

string
Return an HTML field to input HTML code.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5InputHtmlSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input HTML field and submit button.
            string html = cp.Html5.InputHtml("htmlInput", 500);
            string button = cp.Html5.Button("button", "Submit");

            // Add the HTML field and submit button to the form.
            string innerHtml = html + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the HTML they entered.
                string input = cp.Doc.GetText("htmlInput");
                // Display the form along with the user input.
                return form + cp.Html5.P("Your HTML:<br><div " +
                    "style=\"border-style:solid;\">" + 
                    input + "</div>");
            }
            // Return the initial form.
            return form;
        }
    }
}

InputPassword()

Get HTML code for an input password field.

Signatures

InputPassword(string htmlName, int maxLength);

InputPassword(string htmlName, int maxLength, string htmlValue);

InputPassword(string htmlName, int maxLength, string htmlValue, string htmlClass);

InputPassword(string htmlName, int maxLength, string htmlValue, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
The value of the password input as text.

maxLength
int
call-by-value
Max character length of the text input.

Return

string
Return an HTML field to input a password.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5InputPasswordSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input password field and submit button.
            string password = cp.Html5.InputPassword("passwordInput", 20);
            string button = cp.Html5.Button("button", "Submit");

            // Add the password field and submit button to the form.
            string innerHtml = "Input password:<br>" + password +
                "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the password they entered.
                string input = cp.Doc.GetText("passwordInput");
                string hiddenInput = input.Substring(0, 3);

                // Display the first 3 characters of the 
                // password with the rest as stars as
                // an example.
                for(int i = 0; i < input.Length - 3; i++)
                {
                    hiddenInput += "*";
                }

                // Display the form along with the user input.
                return form + cp.Html5.P("You entered:<br>" +
                    hiddenInput);
            }
            // Return the initial form.
            return form;
        }
    }
}

InputText()

Get HTML code for an input text field.

Signatures

InputText(string htmlName, int maxLength);

InputText(string htmlName, int maxLength, string htmlValue);

InputText(string htmlName, int maxLength, string htmlValue, string htmlClass);

InputText(string htmlName, int maxLength, string htmlValue, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
The value of the text input.

maxLength
int
call-by-value
Max character length of the text input.

Return

string
Return an HTML field to input text.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5InputTextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input text field and submit button.
            string text = cp.Html5.InputText("textInput", 50);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = text + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the text they entered.
                string input = cp.Doc.GetText("textInput");
                // Display the form along with the user input.
                return form + cp.Html5.P("You entered:<br>" + input);
            }
            // Return the initial form.
            return form;
        }
    }
}

InputTextArea()

Get HTML code for an input text area field.

Signatures

InputTextArea(string htmlName, int maxLength);

InputTextArea(string htmlName, int maxLength, string htmlValue);

InputTextArea(string htmlName, int maxLength, string htmlValue, string htmlClass);

InputTextArea(string htmlName, int maxLength, string htmlValue, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
The value of the text input.

maxLength
int
call-by-value
Max character length of the text input.

Return

string
Return an HTML text area field to input text.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5InputTextAreaSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input text area field and submit button.
            string text = cp.Html5.InputTextArea("textInput", 100);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = text + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the text they entered.
                string input = cp.Doc.GetText("textInput");
                // Display the form along with the user input.
                return form + cp.Html5.P("You entered:<br>" + input);
            }
            // Return the initial form.
            return form;
        }
    }
}

Li()

Get HTML code for an li tag.

Signatures

Li(string innerHtml);

Li(string innerHtml, string HtmlClass);

Li(string innerHtml, string HtmlClass, string HtmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

innerHtml
string
call-by-value
HTML inside the div tag.

Return

string
Return the list tag.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5LiSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Make a few list elements to put 
            // inside an unordered list.
            string li1 = cp.Html5.Li("Sample1");
            string li2 = cp.Html5.Li("Sample2");
            string li3 = cp.Html5.Li("Sample3");

            // Concatenate the list elements
            // together for the unordered list.
            string innerHtml = li1 + li2 + li3;
            string list = cp.Html5.Ul(innerHtml);

            return list;
        }
    }
}

Ol()

Get HTML code for an ol tag.

Signatures

Ol(string innerHtml);

Ol(string innerHtml);

Ol(string innerHtml, string htmlClass);

Ol(string innerHtml, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

innerHtml
string
call-by-value
HTML inside the div tag.

Return

string
Return the ol tag.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5OlSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Make a few list elements to put 
            // inside an ordered list.
            string li1 = cp.Html5.Li("Sample1");
            string li2 = cp.Html5.Li("Sample2");
            string li3 = cp.Html5.Li("Sample3");

            // Concatenate the list elements
            // together for the ordered list.
            string innerHtml = li1 + li2 + li3;
            string orderedList = cp.Html5.Ol(innerHtml);

            return orderedList;
        }
    }
}

P()

Get HTML code for an p tag.

Signatures

P(string innerHtml);

P(string innerHtml, string htmlClass);

P(string innerHtml, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

intterHtml
string
call-by-value
HTML inside the paragraph tag.

Return

string
Return the paragraph tag.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5PSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string innerHtml = "Hello world!";
            string htmlClass = "exampleClass";

            string paragraph = cp.Html5.P(innerHtml, htmlClass);

            return paragraph;
        }
    }
}

ProcessCheckList()

Use this method along with CheckList(). It will update the content tables according to the user input. The arguments must stay the same as the call to CheckList().

Signatures

ProcessCheckList(string htmlName, string primaryContentName, string primaryRecordID, string secondaryContentName, string rulesContentName, string rulesPrimaryFieldname, string rulesSecondaryFieldName);

Arguments

htmlName
string
call-by-value
The name attribute.

primaryContentName
string
call-by-value
The table being presented.

primaryRecordId
int
call-by-value
The id of the record in the primary content. ex. a list of groups that a person may join, this is the person's id.

rulesContentName
string
call-by-value
The table holding the relationship in a many to many connection. ex. a list of groups that a person may join, this is a table with a personid and a groupId.

rulesPrimaryFieldname
string
call-by-value
The field in the relationship table that identifies the record in the primary content. ex. a list of groups that a person may join, this the field in the raltionship table that points to the person record, like personId.

rulesSecondaryFieldName
string
call-by-value
The field in the relationship table that identifies the record in the secondary content. ex. a list of groups that a person may join, this the field in the raltionship table that points to the group record, like groupId.

secondaryContentName
string
call-by-value
The table being related. ex. a list of groups that a person may join, this is the group content.

Return

void

Examples:

// See the CheckList() example.

RadioBox()

Get HTML code for a radio box.

Signatures

RadioBox(string htmlName, bool htmlValue, bool currentValue);

RadioBox(string htmlName, bool htmlValue, bool currentValue, string htmlClass);

RadioBox(string htmlName, bool htmlValue, bool currentValue, string htmlClass, string htmlId);

RadioBox(string htmlName, DateTime htmlValue, DateTime currentValue);

RadioBox(string htmlName, DateTime htmlValue, DateTime currentValue, string htmlClass);

RadioBox(string htmlName, DateTime htmlValue, DateTime currentValue, string htmlClass, string htmlId);

RadioBox(string htmlName, double htmlValue, double currentValue);

RadioBox(string htmlName, double htmlValue, double currentValue, string htmlClass);

RadioBox(string htmlName, double htmlValue, double currentValue, string htmlClass, string htmlId);

RadioBox(string htmlName, int htmlValue, int currentValue);

RadioBox(string htmlName, int htmlValue, int currentValue, string htmlClass);

RadioBox(string htmlName, int htmlValue, int currentValue, string htmlClass, string htmlId);

RadioBox(string htmlName, string htmlValue, string currentValue);

RadioBox(string htmlName, string htmlValue, string currentValue, string htmlClass);

RadioBox(string htmlName, string htmlValue, string currentValue, string htmlClass, string htmlId);

Arguments

currentValue
string, int, double, bool, DateTime
call-by-value
The current value of the radio box.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string, int, double, bool, DateTime
call-by-value
The value of the radio box.

Return

string
Return the radio box.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5RadioBoxSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create the radio buttons and the form elements. These
            // buttons use strings so we can use cp.Doc.GetText() to
            // distinguish between which one was selected.
            string radio1 = cp.Html5.RadioBox("radioBox", "fish", "");
            string radio2 = cp.Html5.RadioBox("radioBox", "dog", "");
            string radio3 = cp.Html5.RadioBox("radioBox", "cat", "");
            string button = cp.Html5.Button("button", "Submit");

            // Add the HTML field and submit button to the form.
            string innerHtml = "Choose your favorite type of pet:<br>" +
                radio1 + "Goldfish<br>" + radio2 + "Dog<br>" +
                radio3 + "Cat<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Conditional statements that determine
                // which radiobox was checked.
                if(cp.Doc.GetText("radioBox").Equals("fish"))
                {
                    return form + "Fish are cool.";
                } else if (cp.Doc.GetText("radioBox").Equals("dog"))
                {
                    return form + "I like dogs too.";
                } else if (cp.Doc.GetText("radioBox").Equals("cat"))
                {
                    return form + "Cats are soft.";
                } else
                {
                    return form + "I can't pick a favorite either.";
                }
            }
            // Return the initial form.
            return form;
        }
    }
}

SelectContent()

Get HTML code for a drop-down select content field.

Signatures

SelectContent(string htmlName, string htmlValue, string contentName);

SelectContent(string htmlName, string htmlValue, string contentName, string sqlCriteria);

SelectContent(string htmlName, string htmlValue, string contentName, string sqlCriteria, string noneCaption);

SelectContent(string htmlName, string htmlValue, string contentName, string sqlCriteria, string noneCaption, string htmlClass);

SelectContent(string htmlName, string htmlValue, string contentName, string sqlCriteria, string noneCaption, string htmlClass, string htmlId);

Arguments

contentName
string
call-by-value
The desired content's contentName field.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
Value of the desired content.

noneCaption
string
call-by-value
Caption displayed if no content records are found.

sqlCriteria
string
call-by-value
The query criteria.

Return

string
Return the select content field.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5SelectContentSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Make the select content box and submit button.
            string selectBox = cp.Html5.SelectContent("contentInput", "", "People");
            string button = cp.Html5.Button("button", "Submit");

            // Add the select content box and submit button to the form.
            string innerHtml = "Choose your favorite person:<br>" + 
                selectBox + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the record they selected.
                string input = cp.Doc.GetText("contentInput");
                // Display the form along with the user input.
                return form + "Thank you!";
            }
            // Return the initial form.
            return form;
        }
    }
}

SelectList()

Get HTML code for a drop-down select field.

Signatures

SelectList(string htmlName, string htmlValue, string optionList);

SelectList(string htmlName, string htmlValue, string optionList, string noneCaption);

SelectList(string htmlName, string htmlValue, string optionList, string noneCaption, string htmlClass);

SelectList(string htmlName, string htmlValue, string optionList, string noneCaption, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
The value of the desired list.

noneCaption
string
call-by-value
Caption displayed if no content records are found.

optionList
string
call-by-value
A comma delimited list of options. A common way of determining which option was selected is to split the optionList into an array. The option selected will be splitArray[i - 1] because the method's return starts at 1.

Return

string
Return the select list field.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5SelectListSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Make the option list a constant
            const string optionList = "A,B,C,D,F";
            // Split the list into an array because 
            // the user's selection will return an index.
            string[] list = optionList.Split(',');

            // Make the select list box and submit button.
            string selectBox = cp.Html5.SelectList("listInput", "", optionList);
            string button = cp.Html5.Button("button", "Submit");

            // Add the select content box and submit button to the form.
            string innerHtml = "How would you grade this example:<br>" +
                selectBox + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the grade they selected.
                int i = cp.Doc.GetInteger("listInput");

                string grade = "You must select a grade.";

                // Make sure they selected a grade because
                // the indexing starts at 1.
                if(i > 0)
                {
                    grade = "You gave this example a(n) " +
                    list[i - 1] + ".";
                }
                // Display the form along with the user input.
                return form + grade;
            }
            // Return the initial form.
            return form;
        }
    }
}

SelectUser()

Get HTML code for a drop-down select user field.

Signatures

SelectUser(string htmlName, int htmlValue, int groupId);

SelectUser(string htmlName, int htmlValue, int groupId, string noneCaption);

SelectUser(string htmlName, int htmlValue, int groupId, string noneCaption, string htmlClass);

SelectUser(string htmlName, int htmlValue, int groupId, string noneCaption, string htmlClass, string htmlId);

Arguments

groupId
int
call-by-value
Group ID number.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
int
call-by-value
The value attribute will hold the ID number of the selected user.

noneCaption
string
call-by-value
Caption displayed if no content records are found.

Return

string
Return the select user field.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5SelectUserSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Make the select user box and submit button.
            // ID #1 is 'Site Managers'.
            string selectBox = cp.Html5.SelectUser("userInput", 0, 1, 
                "You must select a user.");
            string button = cp.Html5.Button("button", "Submit");

            // Add the select user box and submit button to the form.
            string innerHtml = "Select a user from Site Managers:<br>" +
                selectBox + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the user they selected.
                string input = cp.Doc.GetText("userInput");
                // Display the form along with the user input.
                return form + "Thank you!";
            }
            // Return the initial form.
            return form;
        }
    }
}

Ul()

Get HTML code for a ul tag.

Signatures

Ul(string innerHtml);

Ul(string innerHtml, string htmlClass);

Ul(string innerHtml, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

innerHtml
string
call-by-value
HTML inside the div tag.

Return

string
Return the ul tag.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class Html5UlSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Make a few list elements to put 
            // inside a list.
            string li1 = cp.Html5.Li("Sample1");
            string li2 = cp.Html5.Li("Sample2");
            string li3 = cp.Html5.Li("Sample3");

            // Concatenate the list elements
            // together for the list.
            string innerHtml = li1 + li2 + li3;
            string unorderedList = cp.Html5.Ul(innerHtml);

            return unorderedList;
        }
    }
}

Enums


EditorContentType

The type of content being edited with the HTML editor. Used to determine types of addons that can be included.

Types

contentTypeWeb = 1


cp.Html5.EditorContentType.contentTypeWeb
contentTypeEmail = 2


cp.Html5.EditorContentType.contentTypeEmail
contentTypeWebTemplate = 3


cp.Html5.EditorContentType.contentTypeWebTemplate
contentTypeEmailTemplate = 4


cp.Html5.EditorContentType.contentTypeEmailTemplate

EditorUserRole

The role of the user.

Types

Developer = 1
				


cp.Html5.EditorUserRole.Developer
Administrator = 2


cp.Html5.EditorUserRole.Administrator
ContentManager = 3


cp.Html5.EditorUserRole.ContentManager
PublicUser = 4


cp.Html5.EditorUserRole.PublicUser
CurrentUser = 5


cp.Html5.EditorUserRole.CurrentUser

CPHtmlBaseClass


The HTML class handles functions used to read and produce HTML elements.


Methods


AddEvent()

Add a DOM event.

Signatures

AddEvent(string htmlId, string domEvent, string javaScript);

Arguments

domEvent
string
call-by-value
insert description

htmlId
string
call-by-value
The ID attribute.

javaScript
string
call-by-value
The event's Javascript as string.

Return

void

adminHint()

Get HTML code for an admin hint.

Signatures

adminHint(string innerHtml);

Arguments

innerHtml
string
call-by-value
The inner HTML.

Return

string
Return the admin hint.

Button()

Get HTML code for a button.

Signatures

Button(string htmlName);

Button(string htmlName, string htmlValue);

Button(string htmlName, string htmlValue, string htmlClass);

Button(string htmlName, string htmlValue, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
The value of the button.

Return

string
Return the button.

CheckBox()

Get HTML code for a check box.

Signatures

CheckBox(string htmlName);

CheckBox(string htmlName, bool htmlValue);

CheckBox(string htmlName, bool htmlValue, string htmlClass);

CheckBox(string htmlName, bool htmlValue, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
bool
call-by-value
The boolean value of the check box.

Return

string
Return the check box.

CheckList()

Get HTML code for a check list.

Signatures

1. CheckList(string htmlName, string primaryContentName, int primaryRecordId, string secondaryContentName, string rulesContentName, string rulesPrimaryFieldname, string rulesSecondaryFieldName);

2. CheckList(string htmlName, string primaryContentName, int primaryRecordId, string secondaryContentName, string rulesContentName, string rulesPrimaryFieldname, string rulesSecondaryFieldName, string secondaryContentSelectSQLCriteria);

3. CheckList({All arguments from previous signature}, string captionFieldName);

4. CheckList({All arguments from previous signature}, bool isReadOnly);

5. CheckList({All arguments from previous signature}, string htmlClass);

6. CheckList({All arguments from previous signature}, string htmlId);

Arguments

captionFieldName
string
call-by-value
Name of the check list's caption field.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
bool
call-by-value
The value property. Checked or unchecked.

isReadOnly
bool
call-by-value
If true, the check list will be read-only.

primaryContentName
string
call-by-value
The table being presented. ex. a list of groups that a person may join, this is the People content.

primaryRecordId
int
call-by-value
The id of the record in the primary content. ex. a list of groups that a person may join, this is the person's id.

rulesContentName
string
call-by-value
The table holding the relationship in a many to many connection. ex. a list of groups that a person may join, this is a table with a personid and a groupId.

rulesPrimaryFieldname
string
call-by-value
The field in the relationship table that identifies the record in the primary content. ex. a list of groups that a person may join, this the field in the raltionship table that points to the person record, like personId.

rulesSecondaryFieldName
string
call-by-value
The field in the relationship table that identifies the record in the secondary content. ex. a list of groups that a person may join, this the field in the raltionship table that points to the group record, like groupId.

secondaryContentName
string
call-by-value
The table being related. ex. a list of groups that a person may join, this is the group content.

secondaryContentSelectSQLCriteria
string
call-by-value
The checklist includes all the possible rlationships of the secondary content to the primary. This is the criteria part of a query (where clause) that limits the selection.

Return

string
Return the check list.

div()

Get HTML code for a div tag.

Signatures

div(string innerHtml);

div(string innerHtml, string htmlName);

div(string innerHtml, string htmlName, string htmlClass);

div(string innerHtml, string htmlName, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

innerHtml
string
call-by-value
HTML inside the div tag.

Return

string
Return the div tag.

Form()

Get HTML code for a form.

Signatures

Form(string innerHtml);

Form(string innerHtml, string htmlName);

Form(string innerHtml, string htmlName, string htmlClass);

Form(string innerHtml, string htmlName, string htmlClass, string htmlId);

Form(string innerHtml, string htmlName, string htmlClass, string htmlId, string actionQueryString);

Form(string innerHtml, string htmlName, string htmlClass, string htmlId, string actionQueryString, string method);

Arguments

actionQueryString
string
call-by-value
The form action's query string.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

innerHtml
string
call-by-value
HTML inside the form.

method
string
call-by-value
insert description

Return

string
Return the form.

h1()

Get HTML code for a h1 tag.

Signatures

h1(string innerHtml);

h1(string innerHtml, string htmlName);

h1(string innerHtml, string htmlName, string htmlClass);

h1(string innerHtml, string htmlName, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

innerHtml
string
call-by-value
HTML inside the h1 tag.

Return

string
Return the h1 tag.

h2()

Get HTML code for a h2 tag.

Signatures

h2(string innerHtml);

h2(string innerHtml, string htmlName);

h2(string innerHtml, string htmlName, string htmlClass);

h2(string innerHtml, string htmlName, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

innerHtml
string
call-by-value
HTML inside the h2 tag.

Return

string
Return the h2 tag.

h3()

Get HTML code for a h3 tag.

Signatures

h3(string innerHtml);

h3(string innerHtml, string htmlName);

h3(string innerHtml, string htmlName, string htmlClass);

h3(string innerHtml, string htmlName, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

innerHtml
string
call-by-value
HTML inside the h3 tag.

Return

string
Return the h3 tag.

h4()

Get HTML code for a h4 tag.

Signatures

h4(string innerHtml);

h4(string innerHtml, string htmlName);

h4(string innerHtml, string htmlName, string htmlClass);

h4(string innerHtml, string htmlName, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlid
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

innerHtml
string
call-by-value
HTML inside the h4 tag.

Return

string
Return the h4 tag.

h5()

Get HTML code for a h5 tag.

Signatures

h5(string innerHtml);

h5(string innerHtml, string htmlName);

h5(string innerHtml, string htmlName, string htmlClass);

h5(string innerHtml, string htmlName, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

innerHtml
string
call-by-value
HTML inside the h5 tag.

Return

string
Return the h5 tag.

h6()

Get HTML code for a h6 tag.

Signatures

h6(string innerHtml);

h6(string innerHtml, string htmlName);

h6(string innerHtml, string htmlName, string htmlClass);

h6(string innerHtml, string htmlName, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

innerHtml
string
call-by-value
HTML inside the h6 tag.


Hidden()

Get the HTML code for a hidden element that is commonly used for getting data while not being seen by the user.

Signatures

[deprecated]
Hidden(string HtmlName, bool HtmlValue);

[deprecated]
Hidden(string HtmlName, bool HtmlValue, string HtmlClass);

[deprecated]
Hidden(string HtmlName, bool HtmlValue, string HtmlClass, string HtmlId = "");

[deprecated]
Hidden(string HtmlName, DateTime HtmlValue);

[deprecated]
Hidden(string HtmlName, DateTime HtmlValue, string HtmlClass);

[deprecated]
Hidden(string HtmlName, DateTime HtmlValue, string HtmlClass, string HtmlId = "");

[deprecated]
Hidden(string HtmlName, int HtmlValue);

[deprecated]
Hidden(string HtmlName, int HtmlValue, string HtmlClass);

[deprecated]
Hidden(string HtmlName, int HtmlValue, string HtmlClass, string HtmlId = "");

Hidden(string htmlName, string htmlValue);

Hidden(string htmlName, string htmlValue, string htmlClass);

Hidden(string htmlName, string htmlValue, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string, int, bool, DateTime
call-by-value
The value of the desired HTML content.

Return

string
Return the hidden element.

Indent()

Used to indent text.

Signatures

Indent(string sourceHtml);

Indent(string sourceHtml, int tabCnt);

Arguments

sourceHtml
string
call-by-value
The source HTML to indent.

tabCnt
int
call-by-value
Number of tabs to indent the HTML.

Return

string
Return the indented HTML.

InputDate()

Get HTML code for an input date field.

Signatures

InputDate(string htmlName);

InputDate(string htmlName, DateTime htmlValue);

InputDate(string htmlName, DateTime htmlValue, int maxLength);

InputDate(string htmlName, DateTime htmlValue, int maxLength, string htmlClass);

InputDate(string htmlName, DateTime htmlValue, int maxLength, string htmlClass, string htmlId);

[deprecated]
InputDate(string HtmlName, string HtmlValue = "", string Width = "", string HtmlClass = "", string HtmlId = "");

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
DateTime
call-by-value
The inputted DateTime value.

maxLength
int
call-by-value
Max character length of the input.

Return

string
Return an HTML field to input a DateTime value.

InputFile()

Get HTML code for an input file field.

Signatures

InputFile(string htmlName);

InputFile(string htmlName, string HtmlClass);

InputFile(string htmlName, string HtmlClass, string HtmlId);

Arguments

HtmlClass
string
call-by-value
The class attribute.

HtmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

Return

string
Return an HTML field to input a file.

InputText()

Get HTML code for an input text field.

Signatures

InputText(string htmlName);

InputText(string htmlName, string htmlValue);

InputText(string htmlName, string htmlValue, int maxLength);

InputText(string htmlName, string htmlValue, int maxLength, string htmlClass);

InputText(string htmlName, string htmlValue, int maxLength, string htmlClass, string htmlId);

[deprecated]
InputText(string HtmlName, string HtmlValue, string Height);

[deprecated]
InputText(string HtmlName, string HtmlValue, string Height, string Width);

[deprecated]
InputText(string HtmlName, string HtmlValue, string Height, string Width, bool IsPassword);

[deprecated]
InputText(string HtmlName, string HtmlValue, string Height, string Width, bool IsPassword, string HtmlClass);

[deprecated]
InputText(string HtmlName, string HtmlValue, string Height, string Width, bool IsPassword, string HtmlClass, string HtmlId);

Arguments

Height
string
call-by-value
Height in pixels.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
The value of the text input.

IsPassword
bool
call-by-value
Set to true if the input text is a password.

maxLength
int
call-by-value
Max character length of the text input.

Width
string
call-by-value
Width in pixels.

Return

string
Return an HTML field to input text.

InputTextExpandable()

Get HTML code for an expandable input text field.

Signatures

InputTextExpandable(string htmlName);

InputTextExpandable(string htmlName, string htmlValue);

InputTextExpandable(string htmlName, string htmlValue, int rows);

InputTextExpandable(string htmlName, string htmlValue, int rows, string styleWidth);

InputTextExpandable(string htmlName, string htmlValue, int rows, string styleWidth, bool isPassword);

InputTextExpandable(string htmlName, string htmlValue, int rows, string styleWidth, bool isPassword, string htmlClass);

InputTextExpandable(string htmlName, string htmlValue, int rows, string styleWidth, bool isPassword, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
The expandable text input value.

isPassword
bool
call-by-value
Set to true if the input text is a password.

rows
int
call-by-value
The number of rows allowed in the expandable text input.

styleWidth
string
call-by-value
The width in common forms like 'px' or '%' or 'em'.

Return

string
Return an HTML expandable text field to input text.

InputWysiwyg()

Get HTML code for a wysiwyg input field.

Signatures

InputWysiwyg(string htmlName, string htmlValue, EditorUserScope userScope);

InputWysiwyg(string htmlName, string htmlValue, EditorUserScope userScope, EditorContentScope contentScope);

InputWysiwyg(string htmlName, string htmlValue, EditorUserScope userScope, EditorContentScope contentScope, string height);

InputWysiwyg(string htmlName, string htmlValue, EditorUserScope userScope, EditorContentScope contentScope, string height, string width);

InputWysiwyg(string htmlName, string htmlValue, EditorUserScope userScope, EditorContentScope contentScope, string height, string width, string htmlClass);

InputWysiwyg(string htmlName, string htmlValue, EditorUserScope userScope, EditorContentScope contentScope, string height, string width, string htmlClass, string htmlId);

Arguments

contentScope
EditorContentScope
call-by-value
insert description

height
int
call-by-value
Height of the wysiwyg editor in pixels.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
int
call-by-value
The name attribute.

htmlValue
int
call-by-value
The value of the wysiwyg input.

htmlValue
int
call-by-value
The value of the wysiwyg input.

userScope
EditorUserScope
call-by-value
insert description

width
int
call-by-value
Width of the wysiwyg editor in pixels.

Return

string
Return the HTML for the wysiwyg editor.

li()

Get HTML code for an li tag.

Signatures

li(string innerHtml);

li(string innerHtml, string htmlName);

li(string innerHtml, string htmlName, string HtmlClass);

li(string innerHtml, string htmlName, string HtmlClass, string HtmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

innerHtml
string
call-by-value
HTML inside the div tag.

Return

string
Return the list tag.

ol()

Get HTML code for an ol tag.

Signatures

ol(string innerHtml);

ol(string innerHtml, string htmlName);

ol(string innerHtml, string htmlName, string htmlClass);

ol(string innerHtml, string htmlName, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

innerHtml
string
call-by-value
HTML inside the div tag.

Return

string
Return the ol tag.

p()

Get HTML code for an p tag.

Signatures

p(string innerHtml);

p(string innerHtml, string htmlName);

p(string innerHtml, string htmlName, string htmlClass);

p(string innerHtml, string htmlName, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

intterHtml
string
call-by-value
HTML inside the paragraph tag.

Return

string
Return the paragraph tag.

ProcessCheckList()

Use this method along with CheckList(). It will update the content tables according to the user input. The arguments must stay the same as the call to CheckList().

Signatures

ProcessCheckList(string htmlName, string primaryContentName, string primaryRecordID, string secondaryContentName, string rulesContentName, string rulesPrimaryFieldname, string rulesSecondaryFieldName);

Arguments

htmlName
string
call-by-value
The name attribute.

primaryContentName
string
call-by-value
The table being presented. ex. a list of groups that a person may join, this is the People content.

primaryRecordID
string
call-by-value
The id of the record in the primary content. ex. a list of groups that a person may join, this is the person's id.

rulesContentName
string
call-by-value
The table holding the relationship in a many to many connection.

rulesPrimaryFieldname
string
call-by-value
The field in the relationship table that identifies the record in the primary content.

rulesSecondaryFieldName
string
call-by-value
The field in the relationship table that identifies the record in the secondary content.

secondaryContentName
string
call-by-value
The table being related. ex. a list of groups that a person may join, this is the group content.

Return

void

ProcessInputFile()

Use this method with InputFile(). It will process the inputted file.

Signatures

ProcessInputFile(string HtmlName);

ProcessInputFile(string HtmlName, string VirtualFilePath);

Arguments

HtmlName
string
call-by-value
Name of the HTML content.

VirtualFilePath
string
call-by-value
The virtual file path containing the source HTML.

Return

void

RadioBox()

Get HTML code for a radio box.

Signatures

[deprecated]
RadioBox(string HtmlName, int HtmlValue, int CurrentValue, string HtmlClass = "", string HtmlId = "");

RadioBox(string htmlName, string htmlValue, string currentValue);

RadioBox(string htmlName, string htmlValue, string currentValue, string htmlClass);

RadioBox(string htmlName, string htmlValue, string currentValue, string htmlClass, string htmlId);

Arguments

currentValue
string
call-by-value
The current value of the radio box.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
The value of the radio box.

Return

string
Return the radio box.

SelectContent()

Get HTML code for a drop-down select content field.

Signatures

SelectContent(string htmlName, string htmlValue, string contentName);

SelectContent(string htmlName, string htmlValue, string contentName, string sqlCriteria);

SelectContent(string htmlName, string htmlValue, string contentName, string sqlCriteria, string noneCaption);

SelectContent(string htmlName, string htmlValue, string contentName, string sqlCriteria, string noneCaption, string htmlClass);

SelectContent(string htmlName, string htmlValue, string contentName, string sqlCriteria, string noneCaption, string htmlClass, string htmlId);

Arguments

contentName
string
call-by-value
The desired content's contentName field.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
Value of the desired content.

noneCaption
string
call-by-value
Caption displayed if no content records are found.

sqlCriteria
string
call-by-value
The query criteria.

Return

string
Return the select content field.

SelectList()

Get HTML code for a drop-down select field.

Signatures

SelectList(string htmlName, string htmlValue, string optionList);

SelectList(string htmlName, string htmlValue, string optionList, string noneCaption);

SelectList(string htmlName, string htmlValue, string optionList, string noneCaption, string htmlClass);

SelectList(string htmlName, string htmlValue, string optionList, string noneCaption, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
string
call-by-value
The value of the desired list.

noneCaption
string
call-by-value
Caption displayed if no content records are found.

optionList
string
call-by-value
A comma delimited list of options. A common way of determining which option was selected is to split the optionList into an array. The option selected will be splitArray[i - 1] because the method's return starts at 1.

Return

string
Return the select list field.

SelectUser()

Get HTML code for a drop-down select user field.

Signatures

SelectUser(string htmlName, int htmlValue, int groupId);

SelectUser(string htmlName, int htmlValue, int groupId, string noneCaption);

SelectUser(string htmlName, int htmlValue, int groupId, string noneCaption, string htmlClass);

SelectUser(string htmlName, int htmlValue, int groupId, string noneCaption, string htmlClass, string htmlId);

Arguments

groupId
int
call-by-value
Group ID number.

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

htmlValue
int
call-by-value
The value attribute will hold the ID number of the selected user.

noneCaption
string
call-by-value
Caption displayed if no content records are found.

Return

string
Return the select user field.

ul()

Get HTML code for an ul tag.

Signatures

ul(string innerHtml);

ul(string innerHtml, string htmlName);

ul(string innerHtml, string htmlName, string htmlClass);

ul(string innerHtml, string htmlName, string htmlClass, string htmlId);

Arguments

htmlClass
string
call-by-value
The class attribute.

htmlId
string
call-by-value
The ID attribute.

htmlName
string
call-by-value
The name attribute.

innerHtml
string
call-by-value
HTML inside the div tag.

Return

string
Return the ul tag.

Enums


EditorContentScope

The type of content being edited with the html editor. Used to determine types of addons that can be included.

Types

Page = 1


cp.Html.EditorContentScope.Page
Email = 2


cp.Html.EditorContentScope.Email
PageTemplate = 3


cp.Html.EditorContentScope.PageTemplate
EmailTemplate = 4


cp.Html.EditorContentScope.EmailTemplate

EditorUserScope

The role of the user.

Types

Developer = 1


cp.Html.EditorUserScope.Develoer
Administrator = 2


cp.Html.EditorUserScope.Administrator
ContentManager = 3


cp.Html.EditorUserScope.ContentManager
PublicUser = 4


cp.Html.EditorUserScope.PublicUser
CurrentUser = 5


cp.Html.EditorUserScope.CurrentUser

CPRequestBaseClass


The Request object handles data associated with the request from the visitor.

Properties


Body
string
The body of the entire request entity. Use when iis does not parse the body into form elements, such as application/json.

public abstract string Body { get; }
Browser
string
The browser string of the request.

public abstract string Browser { get; }
BrowserIsMobile
bool
True if the browser is a mobile device.

public abstract bool BrowserIsMobile { get; }
ContentType
string
The content type of the request.

public abstract string ContentType { get; }
CookieString
string
Full cookie list from the browser.

public abstract string CookieString { get; }
Form
string
Full key=value list for the form submitted.

public abstract string Form { get; }
FormAction
string
Request verb.

public abstract string FormAction { get; }
Host
string
The requested domain.

public abstract string Host { get; }
HTTPAccept
string
The requested accept type.

public abstract string HTTPAccept { get; }
HTTPAcceptCharset
string
The requested accect character set.

public abstract string HTTPAcceptCharset { get; }
HTTPProfile
string
insert description

public abstract string HTTPProfile { get; }
HTTPXWapProfile
string
insert description

public abstract string HTTPXWapProfile { get; }
Language
string
The requested language.

public abstract string Language { get; }
Link
string
The requested link.

public abstract string Link { get; }
LinkForwardSource
string
insert description

public abstract string LinkForwardSource { get; }
LinkSource
string
insert description

public abstract string LinkSource { get; }
Page
string
The left-most segment of the url. The page for website urls.

public abstract string Page { get; }
Path
string
The url segment between the page and the domain.

public abstract string Path { get; }
PathPage
string
The path and page segments of the url.

public abstract string PathPage { get; }
Protocol
string
The request protocol (http, https, etc).

public abstract string Protocol { get; }
QueryString
string
The request querystring (segment following the question mark).

public abstract string QueryString { get; }
Referer
string
The refering url from the browser.

public abstract string Referer { get; }
RemoteIP
string
The IP of the request.

public abstract string RemoteIP { get; }
Secure
bool
True if the request is https.

public abstract bool Secure { get; }

Methods


Cookie()

Gets a cookie by name.

Signatures

Cookie(string cookieName);

Arguments

cookieName
string
call-by-value
Name of cookie.

Return

string
Return the value of the cookie

GetBoolean()

Return a value for a key=value pair.

Signatures

GetBoolean(string key);

Arguments

key
string
call-by-value
Key corresponding to request property.

Return

bool
The property corresponding to the key.

GetDate()

Return a value for a key=value pair.

Signatures

GetDate(string key);

Arguments

key
string
call-by-value
Key corresponding to request property.

Return

DateTime
The property corresponding to the key.

GetInteger()

Return a value for a key=value pair.

Signatures

GetInteger(string key);

Arguments

key
string
call-by-value
Key corresponding to request property.

Return

int
The property corresponding to the key.

GetNumber()

Return a value for a key=value pair.

Signatures

GetNumber(string key);

Arguments

key
string
call-by-value
Key corresponding to request property.

Return

double
The property corresponding to the key.

GetText()

Return a value for a key=value pair.

Signatures

GetText(string key);

Arguments

key
string
call-by-value
Key corresponding to request property.

Return

string
The property corresponding to the key.

OK()

insert description

Signatures

OK(string RequestName);

Arguments

RequestName
string
call-by-value
Name of the request.

Return

bool
Return true if the request is OK.

CPResponseBaseClass


The Response object handles the stream of data back to the visitor.

Properties


ContentType
string
The content type of the response.

public abstract string ContentType { get; set; }
Cookies
string
A key=value pair string of all cookies being sent in the response.

public abstract string Cookies { get; }
Header
string
The response header.

public abstract string Header { get; }
isOpen
bool
Is the response object available to write. False during background processes and after the html response has ended. For instance, when a remote method is returned the response is closed meaning no other data should be added to the output.

public abstract bool isOpen { get; }

Methods


AddHeader()

Adds a key=value pair to the HTTP header.

Signatures

AddHeader(string key, string value);

Arguments

key
string
call-by-value
Key that refers to the value in the header.

value
string
call-by-value
The value linked to the key.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class AddHeaderSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Add a header containing the charset.
            cp.Response.AddHeader("Text-encoding", 
                cp.Site.GetText("SITE CHARACTER ENCODING"));

            return "";
        }
    }
}

Clear()

Clear all response output.

Signatures

Clear();

Arguments

No arguments.


Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class ResponseClearSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            cp.Response.Clear();

            return "Response output has been cleared.";
        }
    }
}

Close()

Optional method used to finalize the response.

Signatures

Close();

Arguments

No arguments.


Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class ResponseCloseSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            cp.Response.Close();

            return "The response has been closed.";
        }
    }
}

Flush()

Clear the response.

Signatures

Flush();

Arguments

No arguments.


Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class FlushSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            cp.Response.Flush();

            return "The response has been flushed.";
        }
    }
}

Redirect()

Sets the response redirect.

Signatures

Redirect(string link);

Arguments

link
string
call-by-value
Link to redirect as string.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class RedirectSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Redirect to the current domain.
            cp.Response.Redirect(cp.Site.Domain);

            return "";
        }
    }
}

SetBuffer()

insert description

Signatures

SetBuffer(bool bufferOn);

Arguments

bufferOn
bool
call-by-value
Set to true to activate the buffer.

Return

void

SetCookie()

Set the response cookie.

Signatures

SetCookie(string key, string value);

SetCookie(string key, string value, DateTime dateExpires);

SetCookie(string key, string value, DateTime dateExpires, 
    string domain);

SetCookie(string key, string value, DateTime dateExpires, 
    string domain, string path);

SetCookie(string key, string value, DateTime dateExpires, 
    string domain, string path, bool secure);

Arguments

dateExpires
DateTime
call-by-value
Date of when cookie expires.

domain
string
call-by-value
Domain assigned to the cookie. The domain will default to the site's domain if it is left out. Explicitly setting the domain is useful for setting a cookie for a different domain.

key
string
call-by-value
The key to a data element stored in the cookie.

path
string
call-by-value
Used to set a specific path in the domain that accesses this cookie instead the cookie applying to every path.

secure
bool
call-by-value
True if response is HTTPS.

value
string
call-by-value
A data element stored in the cookie.

Return

void

Examples:

using Contensive.BaseClasses;
using System;

namespace Contensive.Samples
{
    public class SetCookieSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Authenticate the user for one hour.
            string key = "birthday";

            // Input date field and submit button.
            string date = cp.Html5.InputDate("dateInput");
            string button = cp.Html5.Button("button", "Submit");

            // Add the date field and submit button to the form.
            string innerHtml = "Enter your birthday:<br>" +
                date + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Get the date they entered.
                DateTime value = cp.Doc.GetDate("dateInput");
                // Set expiration to MaxValue so the cookie 
                // never expires.
                cp.Response.SetCookie(key, value.ToString(), 
                    DateTime.MaxValue);
                // Display the form along with the user input.
                return form + "Thank you!";
            }
            // Return the initial form.
            return form;
        }
    }
}

SetStatus()

Set the HTTP response. For example: 200 Success.

Signatures

SetStatus(string status);

Arguments

status
string
call-by-value
The status to set.

Return

void

SetTimeout()

Set the response timeout limit.

Signatures

SetTimeout(string timeoutSeconds);

Arguments

timeoutSeconds
string
call-by-value
Number of seconds until timeout.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SetTimeoutSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string timeoutSeconds = "15";

            cp.Response.SetTimeout(timeoutSeconds);

            return "The response timeout is now " +
                timeoutSeconds + " seconds.";
        }
    }
}

SetType()

Set the response type.

Signatures

SetType(string contentType);

Arguments

contentType
string
call-by-value
insert description

Return

void

[deprecated] Write()

Write to the response.

Signatures

Write(string content);

Arguments

content
string
call-by-value
Content to write to the response.

Return

void

CPSiteBaseClass


The Site Class handles features related to the current site.

Properties


Domain
string
This is the current domain used for a web page hit, otherwise it is the primary domain.

public abstract string Domain { get; }
DomainList
string
A complete list of all domains supported.

public abstract string DomainList { get; }
DomainPrimary
string
The primary domain name for the application. Used for email links, monitoring, etc.

public abstract string DomainPrimary { get; }
FilePath
string
The prefixed used with database file field types to create a cdn file link.

public abstract string FilePath { get; }
Name
string
The application name.

public abstract string Name { get; }
PageDefault
string
For websites, the default script page.

public abstract string PageDefault { get; }

Methods


AddLinkAlias()

Add a link alias to the site.

Signatures

AddLinkAlias(string linkAlias, int pageId);

[deprecated]
addLinkAlias(string linkAlias, int pageId, string queryStringSuffix = "");

AddLinkAlias(string linkAlias, int pageId, string queryStringSuffix);

Arguments

linkAlias
string
call-by-value
The link alias to add to the application.

pageId
int
call-by-value
Page ID for the link alias.

queryStringSuffix
int
call-by-value
The query string suffix.

Return

void

[deprecated] EncodeAppRootPath()

Use CP.Utils.EncodeAppRootPath().

Signatures

EncodeAppRootPath(string link);

Arguments

link
string
call-by-value
Link to encode.

Return

string
Return the encoded app root path as string.

ErrorReport()

Report an error, logging it and sending notifications as the app is confirgured. Does not rethrow the error.

Signatures

ErrorReport(string message);

ErrorReport(System.Exception Ex);

ErrorReport(System.Exception Ex, string message);

Arguments

Ex
System.Exception
call-by-value
The system exception.

message
string
call-by-value
Error message to log.

Return

void

GetBoolean()

Read a site property as a boolean.

Signatures

GetBoolean(string key);

GetBoolean(string key, bool defaultValue);

[deprecated]
GetBoolean(string key, string defaultValue);

Arguments

defaultValue
bool, string
call-by-value
New default value for site property.

key
string
call-by-value
Key corresponding to site property.

Return

bool
Return the property as boolean.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SiteGetBoolean : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            if(cp.Site.GetBoolean("ALLOWAUTORECOGNIZE"))
            {
                return "Auto recognize is enabled";
            } else
            {
                return "Auto recognize is disabled";
            }
        }
    }
}

GetDate()

Read a site property as a date.

Signatures

GetDate(string key);

GetDate(string key, DateTime defaultValue);

[deprecated]
GetDate(string key, string defaultValue);

Arguments

defaultValue
DateTime, string
call-by-value
New default value for site property.

key
string
call-by-value
Key corresponding to site property.

Return

DateTime
Return the property as a DateTime value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SiteGetDateSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Get the site property that records the 
            // date and time of the last Housekeeping
            // checks.
            return "The date and time of the last" +
                " check was " + cp.Site.GetDate(
                    "HOUSEKEEP, LAST CHECK");
        }
    }
}

GetInteger()

Read a site property as an integer.

Signatures

GetInteger(string key);

GetInteger(string key, int defaultValue);

[deprecated]
GetInteger(string key, string defaultValue);

Arguments

defaultValue
DateTime, string
call-by-value
New default value for site property.

key
string
call-by-value
Key corresponding to site property.

Return

int
Return the property as an integer value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SiteGetIntegerSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Get the site property that dictates the 
            // allowed number of login attempts.
            return "The maximum ammount of login attempts" +
                "is: " + cp.Site.GetInteger(
                    "MAXVISITLOGINATTEMPTS") + " attempts.";
        }
    }
}

GetNumber()

Read a site property as a double.

Signatures

GetNumber(string key);

GetNumber(string key, double defaultValue);

[deprecated]
GetNumber(string key, string defaultValue);

Arguments

defaultValue
double, string
call-by-value
New default value for site property.

key
string
call-by-value
Key corresponding to site property.

Return

double
Return the property as a double value.

[deprecated] GetProperty()

Use GetText().

Signatures

GetProperty(string key);

[deprecated]
GetProperty(string key, string value);





GetText()

Read a site property as a string.

Signatures

GetText(string key);

GetText(string key, string defaultValue);

Arguments

defaultValue
string
call-by-value
New default value for site property.

key
string
call-by-value
Key corresponding to site property.

Return

string
Return the property as string.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SiteGetTextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Get the Site property that holds the 
            // site's character encoding.
            return "The site's character encoding is " +
                cp.Site.GetText("SITE CHARACTER ENCODING");
        }
    }
}

[deprecated] installCollectionFile()

Install a collection file to the application.

Signatures

installCollectionFile(string privatePathFilename, ref string returnUserError);

Arguments

privatePathFilename
string
call-by-value
Name of file in the private path.

returnUserError
string
call-by-reference
Call-by-reference string that gets updated if an error occurs while installing the collection.

Return

bool
Return true if the collection was installed successfully, false if otherwise.

[deprecated] installCollectionFromLibrary()

Use CP.Addon.InstallCollectionFromLibrary(). Install a collection from a library to the application.

Signatures

installCollectionFromLibrary(string collectionGuid, ref string returnUserError);

Arguments

collectionGuid
string
call-by-value
Desired collection's GUID.

returnUserError
string
call-by-reference
Call-by-reference string that gets updated if an error occurs while installing the collection.


[deprecated] IsTesting()

insert description

Signatures

IsTesting();

Arguments

No arguments.



[deprecated] LandingPageId()

insert description

Signatures

LandingPageId();

LandingPageId(string domainName);

Arguments

domainName
string
call-by-value
Domain name of the landing page.

Return

int
Return the landing page ID number as int.

LogActivity()

Log a user activity to the activity log.

Signatures

LogActivity(string message, int userID, int organizationId);

Arguments

message
string
call-by-value
The log message.

organizationId
int
call-by-value
Organization ID number.

userID
int
call-by-value
User ID number.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class LogActivitySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Create a log when a user is editing 
            // the content box.
            if(cp.User.IsQuickEditing("contentBox"))
            {
                string message = "User is editing content box.";
                int userID = cp.User.Id;
                int organizationId = cp.User.OrganizationID;

                cp.Site.LogActivity(message, userID, organizationId);
            }

            return "";
        }
    }
}

LogAlarm()

insert description

Signatures

LogAlarm(string cause);

Arguments

cause
string
call-by-value
Cause of alarm log message.

Return

void

LogWarning()

Log a warning message.

Signatures

LogWarning(string name, string description, string typeOfWarningKey, string instanceKey);

Arguments

description
string
call-by-value
Description of warning.

instanceKey
string
call-by-value
Key that references the instance in which the warning occurred.

name
string
call-by-value
Name of warning.

typeOfWarningKey
string
call-by-value
Key that indicates the type of the warning.

Return

void

[deprecated] RequestTask()

Use CP.Utils.ExportCsv()

Signatures

RequestTask(string command, string SQL, string exportName, string filename);

Arguments

command
string
call-by-value
Command type as string.

exportName
string
call-by-value
The name of the task's export.

filename
string
call-by-value
Name and path of where to save the result. Include the dot extension in the filename. If a path needs to be specified, do not start the pathFilename with a '\'.

SQL
string
call-by-value
The SQL query.

Return

void

SetProperty()

Set a site-wide property. Read back with cp.site.GetText(), cp.site.getBoolean(), etc.

Signatures

SetProperty(string key, bool value);

SetProperty(string key, DateTime value);

SetProperty(string key, double value);

SetProperty(string key, int value);

SetProperty(string key, string value);

Arguments

key
string
call-by-value
Key corresponding to site property.

value
string, int, double, bool, DateTime
call-by-value
New value for specified property.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class SiteSetPropertySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Set the site property 'ALLOWAUTOLOGIN' 
            // to true to enable auto-login.
            cp.Site.SetProperty("ALLOWAUTOLOGIN", "True");

            return "Auto-login is now enabled";
        }
    }
}

TestPoint()

When debugging is true, add this message and timestamp to the debug trace.

Signatures

TestPoint(string message);

Arguments

message
string
call-by-value
Message to add to the debug trace.

Return

void

Examples:

using Contensive.BaseClasses;
using System;

namespace Contensive.Samples
{
    public class TestPointSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            cp.Site.TestPoint("Test point was hit at" +
                DateTime.Now);

            return "";
        }
    }
}

ThrowEvent()

Event that handles an exception being thrown.

Signatures

ThrowEvent(string eventNameIdOrGuid);

Arguments

eventNameIdOrGuid
string
call-by-value
Name of event or GUID that threw the exception.

Return

void

CPUserBaseClass


The CPUserBaseClass contains properties and methods that relate to the current user's identity.

Properties


Email
string
This is the email address of the current user.

public abstract string Email { get; }
Id
int
This is the Id number of the current user.

public abstract int Id { get; }
IsAdmin
bool
True if the user is an authenticated admin.

public abstract bool IsAdmin { get; }
IsAuthenticated
bool
True if the user is authenticated.

public abstract bool IsAuthenticated { get; }
IsDeveloper
bool
True if the user is an authenticated developer.

public abstract bool IsDeveloper { get; }
IsEditingAnything
bool
True if the user is editing any content.

public abstract bool IsEditingAnything { get; }
IsGuest
bool
True if the user is not authenticated and not recognized.

public abstract bool IsGuest  { get; }
IsNew
bool
True if the user is new.

public abstract bool IsNew  { get; }
IsRecoginzed
bool
True if the current user is recognized from their visitor record, but has not logged in as that identity.

public abstract bool IsRecoginzed  { get; }
IsTemplateEditing
bool
When true, the user has enabled Template Editing mode, where they see only template related edit features

public abstract bool IsTemplateEditing { get; }
Language
string
The language relfected in the browser metadata.

public abstract string Language  { get; }
LanguageID
int
The id of the language relfected in the browser metadata.

public abstract int LanguageID  { get; }
Name
string
Gets the name of the current user if they are authenticated.

public abstract string Name  { get; }
OrganizationID
int
Gets the organization ID of the current user if they are authenticated.

public abstract int OrganizationID { get; }
Username
string
Gets the username of the current user if they are authenticated.

public abstract string Username  { get; }

Methods


GetBoolean()

Read a user property as a boolean.

Signatures

GetBoolean(string key);

GetBoolean(string key, bool defaultValue);

[deprecated]
GetBoolean(string key, string defaultValue);

Arguments

defaultValue
bool, string
call-by-value
New default value for user property.

key
string
call-by-value
Key of the desired boolean.

Return

bool
The property corresponding to the key or the defaultValue if a value was not found.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class UserGetBooleanSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The button.
            string button1 = cp.Html5.Button("button1",
                "Click me if you drink coffee");
            string button2 = cp.Html5.Button("button2",
                "Click me if you don't drink coffee");

            // Add both buttons to the form.
            string innerHtml = button1 + "<br>" + button2 +
                "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the button.
            if (cp.Doc.GetText("button1").Equals(
                "Click me if you drink coffee"))
            {
                // Set the user property
                cp.User.SetProperty("likesCoffee", true);

            } else if (cp.Doc.GetText("button2").Equals(
                "Click me if you don't drink coffee"))
            {
                // Set the user property
                cp.User.SetProperty("likesCoffee", false);
            }

            // Get the property using User.GetBoolean()
            bool opinion = cp.User.GetBoolean("likesCoffee");

            // Return the form.
            return form + cp.Html5.P(cp.User.Name +
                    " likes coffee?<br>" + opinion);
        }
    }
}

GetDate()

Read a user property as a date.

Signatures

GetDate(string key);

GetDate(string key, DateTime defaultValue);

[deprecated]
GetDate(string key, string defaultValue);

Arguments

defaultValue
DateTime, string
call-by-value
New default value for user property.

key
string
call-by-value
Key of the desired object.

Return

DateTime
The property corresponding to the key or the defaultValue if a value was not found.

Examples:

using Contensive.BaseClasses;
using System;

namespace Contensive.Samples
{
    public class UserGetDateSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input date field and submit button.
            string date = cp.Html5.InputDate("dateOfBirth");
            string button = cp.Html5.Button("button", "Submit");

            // Add the date field and submit button to the form.
            string innerHtml = "Enter your birthday:<br>" +
                date + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Set the user property.
                cp.User.SetProperty("DOB", cp.Doc.GetDate("dateOfBirth"));

                // Get the property using User.GetDate()
                DateTime birthday = cp.User.GetDate("DOB");

                // Display the form along with the user input.
                return form + cp.Html5.P("Your birthday is:<br>"
                    + birthday.ToShortDateString());
            }
            // Return the initial form.
            return form;
        }
    }
}

GetIdByLogin()

Get a user's id from their username and password.

Signatures

GetIdByLogin(string username, string password);

Arguments

usernameOrEmail
string
call-by-value
Username or email inputted by user.

password
string
call-by-value
Password inputted by user.

Return

int
Returns the user's ID number.

Examples:

using Contensive.BaseClasses;

namespace Samples
{
    public class GetIdByLoginSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string username = "root";
            string password = "Contensive";

            int localMemberId = cp.User.GetIdByLogin(username, password);

            if(localMemberId != 0)
            {
                return "The requested user ID number is " + localMemberId;
            } else
            {
                // return 0 if ID number is not found
                return "Could not find the requested user ID"
                    + " or does not exist in the system.";
            }
        }
    }
}

GetInteger()

Read a user property as an integer.

Signatures

GetInteger(string key);

GetInteger(string key, int defaultValue);

[deprecated]
GetInteger(string key, string defaultValue);

Arguments

defaultValue
int, string
call-by-value
New default value for user property.

key
string
call-by-value
Key of the desired object.

Return

int
The property corresponding to the key or the defaultValue if a value was not found.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class UserGetIntegerSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input text field and submit button.
            string ageInput = cp.Html5.InputText("age", 3);
            string button = cp.Html5.Button("button", "Submit");

            // Add the date field and submit button to the form.
            string innerHtml = "Enter your age:<br>" +
                ageInput + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Set the user property.
                cp.User.SetProperty("age", cp.Doc.GetInteger("age"));

                // Get the property using User.GetInteger().
                int age = cp.User.GetInteger("age");

                // Display the form along with the user input.
                return form + cp.Html5.P("Your age is:<br>"
                    + age);
            }
            // Return the initial form.
            return form;
        }
    }
}

GetNumber()

Read a user property as a double.

Signatures

GetNumber(string key);

GetNumber(string key, double defaultValue);

[deprecated]
GetNumber(string key, string defaultValue);

Arguments

defaultValue
double, string
call-by-value
New default value for user property.

key
string
call-by-value
Key of the desired object.

Return

double
The property corresponding to the key or the defaultValue if a value was not found.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class UserGetNumberSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input text field and submit button.
            string balance = cp.Html5.InputText("balance", 15);
            string button = cp.Html5.Button("button", "Submit");

            // Add the date field and submit button to the form.
            string innerHtml = "Enter your current balance" +
                " as numbers only (ex: 50.21):<br>" +
                balance + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Set the user property.
                cp.User.SetProperty("currentBalance",
                    cp.Doc.GetNumber("balance"));

                // Get the property using User.GetNumber().
                double currentBalance = cp.User.GetNumber(
                    "currentBalance");

                // Display the form along with the user input.
                return form + cp.Html5.P("Your current balance" +
                    " is:<br>$" + currentBalance);
            }
            // Return the initial form.
            return form;
        }
    }
}

GetObject

Read a user property as an object.

                        





[deprecated] GetProperty()

User User.Get of correct type. Get a CP.User property.

Signatures

GetProperty(string key);

GetProperty(string key, string defaultValue);

GetProperty(string key, string defaultValue, 
    int targetVisitId);

Arguments

defaultValue
string
call-by-value
Default value of desired property.

key
string
call-by-value
Key of desired property.

targetVisitId
int
call-by-value
The target visit ID to get the property from.

Return

string
The property corresponding to the key or the defaultValue if a value was not found.

GetText()

Read a user property as a string.

Signatures

GetText(string key);

GetText(string key, string defaultValue);

Arguments

defaultValue
string
call-by-value
Default value of the desired object.

key
string
call-by-value
Key of the desired object.

Return

string
The property corresponding to the key or the defaultValue if a value was not found.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class UserGetTextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Input text area field and submit button.
            string text = cp.Html5.InputTextArea("bio", 100);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = "Enter a short bio about yourself:" +
                "<br>" + text + "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Set the user property
                cp.User.SetProperty("userBio", cp.Doc.GetText("bio"));

                // Use User.GetText() to get the property.
                string bio = cp.User.GetText("userBio");

                // Display the form along with the user input.
                return form + cp.Html5.P("Your profile:<br>" + 
                    "<b>" + cp.User.Name + "</b><br>" +
                    bio);
            }
            // Return the initial form.
            return form;
        }
    }
}

IsAdvancedEditing()

Checks if the user advanced editing any content or the indicated content.

Signatures

IsAdvancedEditing();

IsAdvancedEditing(string contentName);

Arguments

contentName
string
call-by-value
Name of content to check if the user is advanced editing.

Return

bool
Returns true if the user is advanced editing any content or the indicated content.

Examples:

using Contensive.BaseClasses;

namespace Samples
{
    public class IsAdvancedEditingSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string contentName = "Content Box";

            if (cp.User.IsAdvancedEditing(contentName))
            {
                return cp.User.Name + " is advanced editing the "
                    + contentName;
            } else
            {
                return cp.User.Name + " is not advanced editing the "
                    + contentName;
            }
        }
    }
}

[deprecated] IsAuthoring()

Use IsEditing(). Behavior is the same.

Signatures

IsAuthoring(string contentName);

Arguments

contentName
string
call-by-value
Name of content to check if current user is authoring.

Return

bool
Returns true if the user is authoring the specified content.

Examples:

using Contensive.BaseClasses;

namespace Samples
{
    public class IsAuthoringSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string contentName = "Content Box";

            if (cp.User.IsAuthoring(contentName))
            {
                return cp.User.Name + " is authoring the " 
                    + contentName;
            }
            else
            {
                return cp.User.Name + " is not authoring the " 
                    + contentName;
            }

        }
    }
}

IsContentManager()

True if the current user is authenticated and their identity is a content manager role (in a content manager group).

Signatures

[deprecated]
IsContentManager();

IsContentManager(string contentName);

Arguments

contentName
string
call-by-value
Name of content to check if current user is a content manager of.

Return

bool
Returns true if the user is a content manager of the specified content.

Examples:

using Contensive.BaseClasses;

namespace Samples
{
    public class IsContentManagerSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string contentName = "Content Box";

            if (cp.User.IsContentManager(contentName))
            {
                return cp.User.Name + " is a content "
                    + "manager of " + contentName;
            } else
            {
                return cp.User.Name + " is not a content "
                   + "manager of " + contentName;
            }
        }
    }
}

IsEditing()

Checks if the user editing the indicated content.

Signatures

IsEditing(string contentName);

Arguments

contentName
string
call-by-value
Name of content to check if the user is editing.

Return

bool
Returns true if the user is editing the indicated content.

Examples:

using Contensive.BaseClasses;

namespace Samples
{
    public class IsEditingSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string contentName = "Content Box";

            if(cp.User.IsEditing(contentName))
            {
                return cp.User.Name + " is editing the " + contentName;
            } else
            {
                return cp.User.Name + " is not editing the " + contentName;
            }
            
        }
    }
}

IsInGroup()

True if the current or specified user is authenticted and in the specified group.

Signatures

IsInGroup(string groupName);

IsInGroup(string groupName, int userId);

Arguments

groupName
string
call-by-value
Name of specified group.

userId
int
call-by-value
User ID of specified user.

Return

bool
Returns true if the current or specified user is authenticated and belongs to the specified group.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class IsInGroupSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Specified group ID number
            string groupName = "1";
            int userId = cp.User.Id;

            if( cp.User.IsInGroup(groupName, userId))
            {
                return cp.User.Name + " belongs to the specified group";
            } else
            {
                return cp.User.Name + " does not belong to the " 
                    + "specified group";
            }
        }
    }
}

IsInGroupList()

True if the current or specified user is authenticted and in at least one of the specified groups.

Signatures

IsInGroupList(string groupIdCommaList);

IsInGroupList(string groupIdCommaList, int checkUserID);

Arguments

checkUserId
int
call-by-value
User ID of specified user.

groupIdCommaList
string
call-by-value
A comma delimited list of one or more group Ids.

Return

bool
Returns true if the current or specified user is authenticated and belongs to at least one of the specified groups.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class IsInGroupListSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // List of group ID numbers
            string groupIdCommaList = "1,2,3";
            int userId = cp.User.Id;

            if(cp.User.IsInGroupList(groupIdCommaList, userId))
            {
                return cp.User.Name + " belongs to one or more"
                    + " of the listed groups.";
            } else
            {
                return cp.User.Name + " does not belongs to any"
                    + " of the listed groups.";
            }
        }
    }
}

IsNewLoginOK()

Returns true if the credentials are valid and not present in user.

Signatures

IsNewLoginOK(string username, string password);

Arguments

password
string
call-by-value
Password inputted by user.

username
string
call-by-value
Username inputted by user.

Return

bool
Returns true if the credentials are valid and not present in user.

Examples:

using Contensive.BaseClasses;

namespace Samples
{
    public class IsNewLoginOkSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Username and password are typically 
            // retrieved from a login form.
            string usernameOrEmail = "newUser";
            string password = "newPassword";

            if(cp.User.IsNewLoginOK(usernameOrEmail, password))
            {
                return "Provided credentials are valid"
                    + " and do not exist in user database.";
            } else
            {
                return "Credentials are not valid"
                    + " or they already exist in the system.";
            }
        }
    }
}

IsQuickEditing()

Checks if the user quick editing the indicated content.

Signatures

IsQuickEditing(string contentName);

Arguments

contentName
string
call-by-value
Name of content to check if the user is quick editing.

Return

bool
Returns true if the user is quick editing the indicated content.

Examples:

using Contensive.BaseClasses;

namespace Samples
{
    public class IsQuickEditingSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string contentName = "Content Box";

            if (cp.User.IsAdvancedEditing(contentName))
            {
                return cp.User.Name + " is quick editing the "
                    + contentName;
            }
            else
            {
                return cp.User.Name + " is not quick editing the "
                    + contentName;
            }
        }
    }
}

Login()

This method handles user login.

Signatures

Login(string usernameOrEmail, string password);

Login(string usernameOrEmail, string password, 
    bool setAutoLogin);

Arguments

password
string
call-by-value
Password inputted by user.

setAutoLogin
bool
call-by-value
Option for user to activate auto-login on their device.

usernameOrEmail
string
call-by-value
Username or email inputted by user.

Return

bool
Returns true if authentication was successful, false if otherwise.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class LoginSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Username and password are typically 
            // retrieved from a login form.
            string username = "root";
            string password = "Contesive";

            if( cp.User.Login(username, password))
            {
                return "Welcome " + cp.User.Name;
            } else
            {
                return "Please try again.";
            }
        }
    }
}

LoginByID()

Autheticate the current user to the identity ID provided. If the site property AllowEmailLogin is true, this method treats the first argument as either email or username. Duplicates and email=username matches are not allowed.

Signatures

LoginByID(int recordId);

[deprecated]
LoginByID(string recordId, bool setAutoLogin = false);

Arguments

recordId
int
call-by-value
Record ID number associated with the user's account.

recordId
string
call-by-value
Record ID number associated with the user's account.

setAutoLogin
bool
call-by-value
Option for user to activate auto-login on their device.

Return

bool
Returns true if authentication was successful, false if otherwise.

Examples:

using Contensive.BaseClasses;

namespace Samples
{
    public class LoginByIdSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Use cp.User.Id to get the ID property 
            // associated with a user's account
            int recordId = 123;

            if ( cp.User.LoginByID(recordId))
            {
                return "Welcome " + cp.User.Name; ;
            } else
            {
                return "Invalid User Id.";
            }
            
        }
    }
}

LoginIsOK()

Returns true if the credentials provided are valid for a user in the system.

Signatures

LoginIsOK(string usernameOrEmail, string password);

Arguments

password
string
call-by-value
Password inputted by user.

usernameOrEmail
string
call-by-value
Username inputted by user.

Return

bool
Returns true if the credentials provided are valid for a user in the system.

Examples:

using Contensive.BaseClasses;

namespace Samples
{
    public class LoginByIdSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Username and password are typically 
            // retrieved from a login form.
            string usernameOrEmail = "root@contensive.com";
            string password = "Contensive";

            if(cp.User.LoginIsOK(usernameOrEmail, password))
            {
                return "Login is OK.";
            } else
            {
                return "Login is invalid.";
            }
        }
    }
}

Logout()

Logout the current user.

Signatures

Logout();

Arguments

N/A


Return

void

Examples:

using Contensive.BaseClasses;

namespace Samples
{
    public class LogoutSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            cp.User.Logout();

            return "You have been logged out";
        }
    }
}

Recognize()

Leaves the current user unauthenticated, but associate the current visit session to the visitor session. This changes the user's properties to isRecognized=true, isGuest=false, and isAuthenticated=false.

Signatures

Recognize(int userID);

Arguments

userId
int
call-by-value
User ID of specified user.

Return

bool
Returns true if the current user is recognized from their their visit record but has not yet logged in. The properties must be successfully updated as well.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class IsInGroupListSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // List of group ID numbers
            string groupIdCommaList = "1,2,3";
            int userId = cp.User.Id;

            if(cp.User.IsInGroupList(groupIdCommaList, userId))
            {
                return cp.User.Name + " belongs to one or more"
                    + " of the listed groups.";
            } else
            {
                return cp.User.Name + " does not belongs to any"
                    + " of the listed groups.";
            }
        }
    }
}

SetProperty()

Set a user property. Read back with cp.user.GetText(), cp.user.getBoolean(), etc.

Signatures

SetProperty(string key, bool value);

SetProperty(string key, DateTime value);

SetProperty(string key, double value);

SetProperty(string key, int value);

SetProperty(string key, string value);

[deprecated]
SetProperty(string key, string value, int userId);

Arguments

key
string
call-by-value
Desired property's key.

userId
int
call-by-value
ID number of the user to set the property to.

value
string, int, double, bool, DateTime
call-by-value
New value for specified property.

Return

void

Examples:

// See the User.Get{type}() samples for 
// examples of User.SetProperty()

CPUserErrorBaseClass


Used to accumulate user errors during a distinct process.


Methods


Add()

Add an error to the error list.

Signatures

Add(string message);

Arguments

message
string
call-by-value
The error message.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class UserErrorAddSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            if(cp.User.Username == null)
            {
                cp.UserError.Add("Username of current user is null.");
                return "Error occurred.";
            } else
            {
                // Return value is arbitrary for this
                // example because nothing needs to be 
                // explicitly returned to the user.
                return "";
            }
        }
    }
}

GetList()

Get the error list.

Signatures

GetList()

Arguments

No arguments.


Return

string
Return the error list as string.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class UserErrorGetListSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string errorList = cp.UserError.GetList();

            return errorList;
        }
    }
}

OK()

Return true if there are no errors.

Signatures

OK();

Arguments

No arguments.


Return

bool
Return true if there are no errors.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class UserErrorOKSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            if(cp.UserError.OK())
            {
                return "There are no errors.";
            } else
            {
                return cp.UserError.GetList();
            }
        }
    }
}

CPUtilsBaseClass


The Utils class handles basic utilities and other features that are not classified.


Methods


AppendLog()

Create a log entry type "Log".

Signatures

AppendLog(string logText);

[deprecated]
AppendLog(string pathFilename, string logText);

Arguments

logText
string
call-by-value
The log text to append.

logText
string
call-by-value
Contents of the new log file.

pathFilename
string
call-by-value
Name and path of the new log file. Include the dot extension in the filename. If a path needs to be specified, do not start the pathFilename with a '\'.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class UtilsAppendLogSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string logText = "This example is going " +
                "really well.";

            cp.Utils.AppendLog(logText);

            return "";
        }
    }
}

[deprecated] AppendLogFile()

Use AppendLog.

Signatures

AppendLogFile(string Text);

Arguments

Text
string
call-by-value
Text to append to the log file.

Return

void

ConvertHTML2Text()

Get a text approximation of HTML content.

Signatures

ConvertHTML2Text(string Source);

Arguments

logText
string
call-by-value
Source HTML to convert.

Return

string
Return the text approximation.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class ConvertHTML2TextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string source = cp.Html5.Div("Hello world!");

            string text = cp.Utils.ConvertHTML2Text(source);

            return text;
        }
    }
}

[deprecated] ConvertLinkToShortLink()

Shorten a link.

Signatures

ConvertLinkToShortLink(string URL, string ServerHost, string ServerVirtualPath);

ConvertLinkToShortLink(string URL, string ServerHost, string ServerVirtualPath);

Arguments

ServerHost
string
call-by-value
insert description

ServerVirtualPath
string
call-by-value
insert description

URL
string
call-by-value
The full URL to convert.

Return

string
Return the short link.

[deprecated] ConvertShortLinkToLink()

Convert a shortened link to a full link.

Signatures

ConvertShortLinkToLink(string URL, string PathPagePrefix);

Arguments

PathPagePrefix
string
call-by-value
insert description

URL
string
call-by-value
The shortened URL to convert.

Return

string
Return the link.

ConvertText2HTML()

Get an HTML approximation of text content.

Signatures

ConvertText2HTML(string source);

Arguments

source
string
call-by-value
Source text to convert.

Return

string
Return the text approximation.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class ConvertText2HTMLSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string source = "Hello world!";

            string HTML = cp.Utils.ConvertText2HTML(source);

            return HTML;
        }
    }
}

CreateGuid()

Return a new guid in system's format {...}.

Signatures

CreateGuid();

Arguments

No arguments.


Return

string
Return the GUID as string.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class CreateGuidSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The buttons.
            string button1 = cp.Html5.Button("button", "Press Me");

            // Add both buttons to the form.
            string innerHtml = "Click here to create a GUID:<br>" +
                button1 + "<br><br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the Surpise1 button.
            if (cp.Doc.GetText("button").Equals("Press Me"))
            {
                // Return the new GUID.
                return form + cp.Utils.CreateGuid();
            }
            // Return the initial form.
            return form;
        }
    }
}

[deprecated] DecodeGMTDate()

Use native methods to convert date formats.

Signatures

DecodeGMTDate(string GMTDate);

Arguments

GMTDate
string
call-by-value
The GMT date to decode.

Return

DateTime
Return the decoded GMT date as a DateTime value.

[deprecated] DecodeHTML()

Use System.Net.WebUtility.HtmlDecode().

Signatures

DecodeHTML(string source);

Arguments

source
string
call-by-value
The source HTML to be decoded.

Return

string
Return the decoded HTML as string.

DecodeHtmlFromWysiwygEditor()

HTML content can be stored with embedded addons. Use this routine to prepare the content returned from a wysiwyg editor (addons converted to images).

Signatures

DecodeHtmlFromWysiwygEditor(string source);

Arguments

source
string
call-by-value
The source HTML to be decoded.

Return

string
Return the decoded HTML as string.

DecodeResponseVariable()

Decodes a querystring response argument (key or value) you would expect to see within a querystring (key1=value1&key2=value2).

Signatures

DecodeResponseVariable(string source);

Arguments

source
string
call-by-value
The querystring response argument (key or value) to be decoded.

Return

string
Return the decoded querystring as string.

[deprecated] DecodeUrl()

Use System.Net.WebUtility.UrlDecode().

Signatures

DecodeUrl(string Url);

Arguments

Url
string
call-by-value
The URL to be decoded.

Return

string
Return the decoded URL as string.

EncodeAppRootPath()

Convert a file link (like /ccLibraryFiles/imageFilename/000001/this.png) to a full URL.

Signatures

EncodeAppRootPath(string link);

Arguments

link
string
call-by-value
The file link to be encoded.

Return

string
Return the full URL.

EncodeBoolean()

Convert to boolean. If no valid rendition exists, returns false (accepts true, yes, on, any +number).

Signatures

EncodeBoolean(object expression);

Arguments

expression
object
call-by-value
Common expressions that refer to booleans.

Return

bool
Return the encoded boolean value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class EncodeBooleanSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The text field for the boolean expression.
            string text = cp.Html5.InputText("boolExpression", 10);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = "Input a boolean expression like " +
                "true, false, yes, no, 0, 1, etc:<br>" + text + 
                "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Encode the expression the user entered.
                string input = cp.Doc.GetText("boolExpression");
                bool expression = cp.Utils.EncodeBoolean(input);
                // Display the form along with the boolean
                return form + cp.Html5.P("The expression encoded " +
                    "to:<br>" + expression);
            }
            // Return the initial form.
            return form;
        }
    }
}    }
}

EncodeContentForWeb()

HTML content can be stored with embedded addons. This routine renders the content for display on a website.

Signatures

EncodeContentForWeb(string source, string contextContentName = "", int contextRecordID = 0, int wrapperID = 0);

Arguments

contextContentName
string
call-by-value
Content name of which the addon will be placed on. Empty by default.

contextRecordID
int
call-by-value
The record ID of the content that the addon will be used with.

source
string
call-by-value
Source HTML to be encoded.

wrapperID
int
call-by-value
Id number of the wrapper.

Return

string
Return the rendered content.

EncodeDate()

Convert to DateTime. If no valid rendition exists, returns default( DateTime ) = 1/1/0001 12:00:00AM.

Signatures

EncodeDate(object expression);

Arguments

expression
object
call-by-value
The date expression to be encoded.

Return

DateTime
Return the encoded DateTime value.

Examples:

using Contensive.BaseClasses;
using System;

namespace Contensive.Samples
{
    public class EncodeDateSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The text field for the date expression.
            string text = cp.Html5.InputText("dateExpression", 50);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = "Input a date expression like " +
                "March 1, 2019, 03/17/2018, etc:<br>" + text +
                "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Encode the expression the user entered.
                string input = cp.Doc.GetText("dateExpression");
                DateTime expression = cp.Utils.EncodeDate(input);
                // Display the form along with the date
                return form + cp.Html5.P("The expression encoded " +
                    "to:<br>" + expression);
            }
            // Return the initial form.
            return form;
        }
    }
}

[deprecated] EncodeHTML()

Use System.Net.WebUtility.HtmlEncode().

Signatures

EncodeHTML(string source);

Arguments

source
string
call-by-value
The source HTML to be encoded.

Return

string
Return the encoded HTML.

EncodeHtmlForWysiwygEditor()

HTML content can be stored with embedded addons. Use this routine to prepare the content for a wysiwyg editor (addons converted to images).

Signatures

EncodeHtmlForWysiwygEditor(string source);

Arguments

source
string
call-by-value
The source HTML to be encoded.

Return

string
Return the encoded HTML that is prepared for a wysiwyg editor.

EncodeInteger()

Convert to integer. If no valid rendition exists, returns 0.

Signatures

EncodeInteger(object expression);

Arguments

expression
object
call-by-value
The integer expression to be encoded.

Return

int
Return the encoded integer value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class EncodeIntegerSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The text field for the integer expression.
            string text = cp.Html5.InputText("intExpression", 50);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = "Input an integer expression like " +
                "1, 2, 55, etc:<br>" + text +
                "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Encode the expression the user entered.
                string input = cp.Doc.GetText("intExpression");
                int expression = cp.Utils.EncodeInteger(input);
                // Display the form along with the int
                return form + cp.Html5.P("The expression encoded " +
                    "to:<br>" + expression);
            }
            // Return the initial form.
            return form;
        }
    }
}

[deprecated] EncodeJavascript()

Use System.Net.HttpUtility.JavaScriptStringEncode().

Signatures

EncodeJavascript(string source);

Arguments

source
string
call-by-value
The source Javascript to be encoded.

Return

string
Return the encoded Javascript as string.

EncodeNumber()

Convert to double. If no valid rendition exists, returns 0.

Signatures

EncodeNumber(object expression);

Arguments

expression
object
call-by-value
The double expression to be encoded.

Return

double
Return the encoded double value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class EncodeNumberSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The text field for the double expression.
            string text = cp.Html5.InputText("doubleExpression", 50);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = "Input a double expression like " +
                "1, 2.0, 55.4, etc:<br>" + text +
                "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Encode the expression the user entered.
                string input = cp.Doc.GetText("doubleExpression");
                double expression = cp.Utils.EncodeNumber(input);
                // Display the form along with the double
                return form + cp.Html5.P("The expression encoded " +
                    "to:<br>" + expression);
            }
            // Return the initial form.
            return form;
        }
    }
}

[deprecated] EncodeQueryString()

Encode each key value first with EncodeResponseVariable(), then assemble them into the querystring.

Signatures

EncodeQueryString(string Source);

Arguments

source
string
call-by-value
The source querystring to be encoded.

Return

string
Return the encoded querystring as string.

EncodeRequestVariable()

Encodes a querystring response argument (key or value) you would expect to see within a querystring (key1=value1&key2=value2).

Signatures

EncodeRequestVariable(string Source);

Arguments

Source
string
call-by-value
The querystring response argument (key or value) to be encoded.

Return

string
Return the encoded querystring response argument.

EncodeText()

Convert to string. If no valid rendition exists, returns empty.

Signatures

EncodeText(object expression);

Arguments

expression
object
call-by-value
The text expression to be encoded.

Return

string
Return the encoded text.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class EncodeTextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The text field for the text expression.
            string text = cp.Html5.InputText("textExpression", 50);
            string button = cp.Html5.Button("button", "Submit");

            // Add the text field and submit button to the form.
            string innerHtml = "Input a text expression like " +
                "'Hello world!', etc:<br>" + text +
                "<br><br>" + button + "<br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the submit button.
            if (cp.Doc.GetText("button").Equals("Submit"))
            {
                // Encode the expression the user entered.
                string input = cp.Utils.EncodeText(cp.Doc.GetText("textExpression"));
                // Display the form along with the text
                return form + cp.Html5.P("The expression encoded " +
                    "to:<br>" + input);
            }
            // Return the initial form.
            return form;
        }
    }
}

[deprecated] EncodeUrl()

Use System.Net.WebUtility.UrlEncode().

Signatures

EncodeUrl(string source);

Arguments

Url
string
call-by-value
The URL to be encoded.

Return

string
Return the encoded URL as string.

[deprecated] ExecuteAddon()

Use cp.addon.execute().

Signatures

ExecuteAddon(string idGuidOrName);

ExecuteAddon(string IdGuidOrName, addonContext context);

ExecuteAddon(string IdGuidOrName, int WrapperId);

Arguments

context
addonContext
call-by-value
The enumeration value of the addon's context. See the addonContext enum for the info.

idGuidOrName
string
call-by-value
The addon's ID number, GUID, or name.

WrapperId
int
call-by-value
Addon wrapper's ID number.

Return

string
Return the result of the addon's execution.

[deprecated] ExecuteAddonAsProcess()

Use cp.addon.executeAsync().

Signatures

ExecuteAddonAsProcess(string IdGuidOrName);

Arguments

IdGuidOrName
string
call-by-value
The addon's ID number, GUID, or name.

Return

string
Return the result of the addon's execution.

ExportCsv()

Run an SQL query on the default datasource and save the data in a CSV file in the filename provided to a record in the downloads table.

Signatures

ExportCsv(string SQL, string exportName, string filename);

Arguments

exportName
string
call-by-value
The name of the export data, used in the downloads table.

filename
string
call-by-value
The filename for the export, saved in the downloads table.

SQL
string
call-by-value
The query to run, selecting the data to be exported.

Return

void

GetArgument()

Get a value from a key=value delimited string. ex) keyValueDelimitedString (a=b&c=4), keys ( a and c ), delimiter ( & ), values ( b and 4 ).

Signatures

GetArgument(string key, string keyValueDelimitedString);

GetArgument(string key, string keyValueDelimitedString, string defaultValue);

GetArgument(string key, string keyValueDelimitedString, string defaultValue, string delimiter);

Arguments

defaultValue
string
call-by-value
The argument's new value if it does not have one.

delimiter
string
call-by-value
Key value pair delimiter.

key
string
call-by-value
Argument's key.

keyValueDelimitedString
string
call-by-value
Key value pairs of the argument.

Return

string
Return the value from the argument's key=value pair.

GetFilename()

Return the filename part of a path (after the left-most slash), either Unix or Dos.

Signatures

GetFilename(string pathFilename);

Arguments

pathFilename
string
call-by-value
Name of file to get. Include the dot extension in the filename. If a path needs to be specified, do not start the pathFilename with a '\'.

Return

string
Return the filename part of a path.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class UtilsGetFilenameSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string pathFilename = "SamplePath\\example.txt";
            string filename = cp.Utils.GetFilename(pathFilename);

            return "The filename is: " + filename;
        }
    }
}

[deprecated] GetFirstNonZeroDate()

Get the first non-zero DateTime value.

Signatures

GetFirstNonZeroDate(DateTime Date0, DateTime Date1);

Arguments

Date0
DateTime
call-by-value
insert description

Date1
DateTime
call-by-value
insert description

Return

DateTime
Return the first non-zero DateTime value.

[deprecated] GetFirstNonZeroInteger()

Get the first non-zero integer value.

Signatures

GetFirstNonZeroInteger(int Integer0, int Integer1);

Arguments

Integer0
int
call-by-value
insert description

Integer1
int
call-by-value
insert description

Return

int
Return the first non-zero integer value.

[deprecated] GetIntegerString()

Use string.PadRight() and string.PadLeft().

Signatures

GetIntegerString(int Value, int DigitCount);

Arguments

DigitCount
int
call-by-value
Number of digits in the integer value.

Value
int
call-by-value
The integer value.

Return

string
Return the integer value as string.

[deprecated] GetLine()

Use new StringReader(str).ReadLine().

Signatures

GetLine(string Body);

Arguments

Body
string
call-by-value
The body text.

Return

string
Return the line as string.

GetListIndex()

Returns a 1-based index into the comma delimited ListOfItems where Item is found.

Signatures

GetListIndex(string itemToFind, string commaDelimitedListOfItems);

Arguments

commaDelimitedListOfItems
string
call-by-value
A comma delimited list of items that may contain the itemToFind.

itemToFind
string
call-by-value
Which item to find.

Return

int
Return the 1-based index of where the itemToFind is in the delimited list.

[deprecated] GetPleaseWaitEnd()

insert description

Signatures

GetPleaseWaitEnd();

Arguments

No arguments.


Return

string
insert description

[deprecated] GetPleaseWaitStart()

insert description

Signatures

GetPleaseWaitStart();

Arguments

No arguments.


Return

string
insert description

[deprecated] GetProcessID()

Use Process.GetCurrentProcess().Id.

Signatures

GetProcessID();

Arguments

No arguments.


Return

int
Return the process ID number.

GetRandomInteger()

Return a random integer.

Signatures

GetRandomInteger();

Arguments

No arguments.


Return

int
Return the random integer value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class GetRandomIntegerSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The buttons.
            string button1 = cp.Html5.Button("button", "Press Me");

            // Add both buttons to the form.
            string innerHtml = "Click here to get a random number:<br>" +
                button1 + "<br><br>";
            string form = cp.Html5.Form(innerHtml);

            // Check if the user clicked the Surpise1 button.
            if (cp.Doc.GetText("button").Equals("Press Me"))
            {
                // Return the new GUID.
                return form + cp.Utils.GetRandomInteger();
            }
            // Return the initial form.
            return form;
        }
    }
}

[deprecated] hashMd5()

Deprecated, some server audits fail if Md5 use detected.

Signatures

hashMd5(string source);

Arguments

source
string
call-by-reference
The source string to hash with MD5.

Return

string
Return the hashed object as string.

IISReset()

For websites, run an iisreset. Call from a remote method that detects the server restoration and recovers.

Signatures

IISReset();

Arguments

No arguments.


Return

void

[deprecated] installCollectionFromFile()

Use CP.Addon.InstallCollectionFile(). Install an addon collection file asynchronously. The task is queued and the taskId is returned. Use cp.tasks.getTaskStatus() to determine status.

Signatures

installCollectionFromFile(string privateFile);

Arguments

privateFile
string
call-by-reference
Name of the private file to be installed. Include the dot extension in the filename. If a path needs to be specified, do not start the privateFile with a '\'.

Return

int
Return the ID number of the collection.

[deprecated] installCollectionFromLibrary()

Use CP.Addon.InstallCollectionFromLibrary(). Install an addon collections from the collection library asynchronously. The task is queued and the taskId is returned. Use cp.tasks.getTaskStatus() to determine status.

Signatures

installCollectionFromLibrary(string collectionGuid);

Arguments

collectionGuid
string
call-by-reference
The GUID of the collection to install.

Return

int
Return the ID number of the collection.

[deprecated] installCollectionFromLink()

Use CP.Addon.InstallCollectionFromLink(). Install an addon collections from an endpoint asynchronously. The task is queued and the taskId is returned. Use cp.tasks.getTaskStatus() to determine status.

Signatures

installCollectionFromLink(string link);

Arguments

link
string
call-by-reference
The link of the collection to install.

Return

int
Return the ID number of the collection.

[deprecated] installCollectionsFromFolder()

Use CP.Addon.InstallCollectionFolder(). Install all addon collections in a folder asynchronously. Optionally delete the folder. The task is queued and the taskId is returned. Use cp.tasks.getTaskStatus() to determine status.

Signatures

installCollectionsFromFolder(string privateFolder);

installCollectionsFromFolder(string privateFolder, bool deleteFolderWhenDone);

Arguments

deleteFolderWhenDone
bool
call-by-reference
If true, the folder will be deleted upon successful installation.

privateFolder
string
call-by-reference
Name of folder to get. If a path needs to be specified, do not start the privateFolder with a '\'.

Return

int
Return the ID number of the collection.

isGuid()

Returns true if the string is a GUID (start/end with brace, char count, check dashes).

Signatures

isGuid(string guid);

Arguments

guid
string
call-by-value
The GUID to check.

Return

bool
True if the inputted GUID is a GUID, false if not.

IsInDelimitedString()

Return true if the item to find is in the delimited string.

Signatures

IsInDelimitedString(string delimitedString, string itemToFind, string delimiter);

Arguments

delimitedString
string
call-by-value
Delimited string that may contain the item to find.

delimiter
string
call-by-value
The delimiter of items in the delimited string.

itemToFind
string
call-by-value
The item to find the the delimited string.

Return

bool
Return true if the itemToFind is in the delimited string.

ModifyLinkQueryString()

Update or add a key=value pair within a url like "/path/page?key=value&key=value".

Signatures

ModifyLinkQueryString(string url, string key, string value, bool addIfMissing = true);

Arguments

addIfMissing
bool
call-by-value
If true, the key value pair will be added if it is missing.True by default.

key
string
call-by-value
The key to add.

url
string
call-by-value
The URL to add the key value pair.

value
string
call-by-value
The value to add.

Return

string
Return the updated link querystring.

ModifyQueryString()

Update or add a key=value pair within key value pair string like "key=value&key=value".

Signatures

ModifyQueryString(string WorkingQuery, string QueryName, string QueryValue, bool AddIfMissing = true);

Arguments

AddIfMissing
bool
call-by-value
If true, the key value pair will be added to the query if it is missing. True by default.

QueryName
string
call-by-value
The key to add.

QueryValue
string
call-by-value
The value to add.

WorkingQuery
string
call-by-value
The query to add the key value pair to.

Return

string
Return the updated query.

[deprecated] ParseURL()

Use SeparateUrl().

Signatures

ParseURL(string SourceURL, ref string Protocol, ref string Host, ref string Port, ref string Path, ref string Page, ref string QueryString);

Arguments

Host
string
call-by-reference
The URL's host as a call-by-reference string.

Page
string
call-by-reference
The URL's page as a call-by-reference string.

Path
string
call-by-reference
The URL's path as a call-by-reference string.

Port
string
call-by-reference
The URL's port as a call-by-reference string.

Protocol
string
call-by-reference
The URL's protocol as a call-by-reference string.

QueryString
string
call-by-reference
The URL's querystring as a call-by-reference string.

SourceURL
string
call-by-value
The source URL to be parsed.

Return

void

SeparateURL()

Get the components of a URL.

Signatures

SeparateURL(string url, ref string return_protocol, ref string return_domain, ref string return_path, ref string return_page, ref string return_queryString);

SeparateURL(string url, ref string return_protocol, ref string return_domain, ref string return_port, ref string return_path, ref string return_page, ref string return_queryString);

Arguments

return_domain
string
call-by-reference
The URL's return domain as a call-by-reference string.

return_page
string
call-by-reference
The URL's return page as a call-by-reference string.

return_path
string
call-by-reference
The URL's return path as a call-by-reference string.

return_port
string
call-by-reference
The URL's return port as a call-by-reference string.

return_protocol
string
call-by-reference
The URL's return protocol as a call-by-reference string.

return_queryString
string
call-by-reference
The URL's return querystring as a call-by-reference string.

url
string
call-by-value
The URL to separate.

Return

void

[deprecated] Sleep()

Use System.Threading.Thread.Sleep().

Signatures

Sleep(int timeMSec);

Arguments

timeMSec()
string
call-by-reference
Time in milliseconds for a routine to sleep.

Return

void

SplitDelimited()

Gets the result of a Split, except it honors quoted text, if a quote is found, it is assumed to also be a delimiter ( 'this"that"theother' = 'this "that" theother' ).

Signatures

SplitDelimited(string wordList, string delimiter);

Arguments

delimiter
string
call-by-value
The word list's delimiter.

delimiter
string
call-by-value
The word list's delimiter.

wordList
string
call-by-value
The delimited word list to be split.

Return

object
Return the result of the split.

[deprecated] Upgrade()

Installation upgrade through the cp interface is deprecated. Please use the command line tool.

Signatures

Upgrade(bool isNewApp);

Arguments

isNewApp
bool
call-by-value
True if the application is new, false if the application exists on an old version of Contensive.

Return

void

Upgrade51ConvertDirectoryInfoArrayToParseString()

Used to convert application data from DotNet DirectoryInfo object to internal legacy 4.1 Parse string.

Signatures

Upgrade51ConvertDirectoryInfoArrayToParseString(List<CPFileSystemBaseClass.FolderDetail> DirectoryInfo);

Arguments

DirectoryInfo
List<CPFileSystemBaseClass.FolderDetail>
call-by-value
The DotNet DirectoryInfo object that holds the application info.

Return

string
Return the internal legacy 4.1 parse string.

Upgrade51ConvertFileInfoArrayToParseString()

Used to convert application data from DotNet DirectoryInfo object to internal legacy 4.1 Parse string.

Signatures

Upgrade51ConvertFileInfoArrayToParseString(List<CPFileSystemBaseClass.FileDetail> DirectoryInfo);

Arguments

DirectoryInfo
List<CPFileSystemBaseClass.FileDetail>
call-by-value
The DotNet DirectoryInfo object that holds the file info.

Return

string
Return the internal legacy 4.1 parse string.

Enums


addonContext

Enumerations that relate to the context of which an addon is used.

Types

// Addon placed on a page.
ContextPage = 1


cp.Utils.addonContext.ContextPage
// Addon run by the admin site addon, to be displayed in the dashboard space.
ContextAdmin = 2


cp.Utils.addonContext.ContextAdmin
// Addon placed on a template.
ContextTemplate = 3


cp.Utils.addonContext.ContextTemplate
// Addon executed when an email is being rendered for an individual.
ContextEmail = 4


cp.Utils.addonContext.ContextEmail
// Addon executed as a remote method and
// is expected to return html (as opposed to JSON).
ContextRemoteMethodHtml = 5


cp.Utils.addonContext.ContextRemoteMethodHtml
// Addon executed because when a new visit is created. The return is ignored.
ContextOnNewVisit = 6


cp.Utils.addonContext.ContextOnNewVisit
// Addon executed right before the body end html tag.
// The return is placed in the html.
ContextOnPageEnd = 7


cp.Utils.addonContext.ContextOnPageEnd
// Addon executed right after the open body tag.
// The return is placed in the html.
ContextOnPageStart = 8


cp.Utils.addonContext.ContextOnPageStart
// Addon executed because it is set as the editor for a content field type.
// It reads details from the doc and creates an html edit tag(s).
ContextEditor = 9


cp.Utils.addonContext.ContextEditor
[deprecated]
ContextHelpUser = 10


cp.Utils.addonContext.ContextHelpUser
[deprecated]
ContextHelpAdmin = 11


cp.Utils.addonContext.ContextHelpAdmin
[deprecated]
ContextHelpDeveloper = 12


cp.Utils.addonContext.ContextHelpDeveloper
[deprecated]
ContextOnContentPage = 13


cp.Utils.addonContext.ContextOnContentChange
[deprecated]
ContextFilter = 14


cp.Utils.addonContext.ContextFilter
[deprecated]
ContextSimple = 15


cp.Utils.addonContext.ContextSimple
[deprecated]
ContextOnBodyStart = 16


cp.Utils.addonContext.ContextOnBodyStart
[deprecated]
ContextOnBodyEnd = 17


cp.Utils.addonContext.ContextOnBodyEnd
[deprecated]
ContextRemoteMethodJson = 18


cp.Utils.addonContext.ContextRemoteMethodJson

CPVisitBaseClass


Handles the properties containing information on each visit to the site.

Properties


CookieSupport
bool
True if the visit supports cookies.

public abstract bool CookieSupport { get; }
Id
int
The visit ID number.

public abstract int Id { get; }
LastTime
DateTime
The time of the last hit.

public abstract DateTime LastTime { get; }
LoginAttempts
int
The number of login attempts.

public abstract int LoginAttempts { get; }
Name
string
The name of the visit.

public abstract string Name { get; }
Pages
int
The number of hits to the application.

public abstract int Pages { get; }
Referer
string
The referer for the visit.

public abstract string Referer { get; set; }
StartDateValue
int
The date when the visit started.

public abstract int StartDateValue { get; }
StartTime
DateTime
The time when the visit started.

public abstract DateTime StartTime { get; }

Methods


GetBoolean()

Get the visit property that matches the key. If not found, sets and returns the default value.

Signatures

GetBoolean(string key);

GetBoolean(string key, bool defaultValue);

Arguments

defaultValue
bool
call-by-value
New default value for visit property.

key
string
call-by-value
Key corresponding to visit property.

Return

bool
The property corresponding to the key or the defaultValue if a value was not found.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitGetBooleanSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The user is editing if the visit property
            // 'AllowEditing' is true.
            if(cp.Visit.GetBoolean("AllowEditing"))
            {
                return "We know you are editing!";
            }
            else
            {
                return "Hello, " + cp.User.Name + "!";
            }
        }
    }
}

GetDate()

Get the visit property that matches the key. If not found sets and returns the default value.

Signatures

GetDate(string key);

GetDate(string key, DateTime defaultValue);

Arguments

defaultValue
DateTime
call-by-value
New default value for visit property.

key
string
call-by-value
Key corresponding to visit property.

Return

DateTime
The property corresponding to the key or the defaultValue if a value was not found.

Examples:

using Contensive.BaseClasses;
using System;

namespace Contensive.Samples
{
    public class VisitGetDateSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Made up Visit property that stores the date of
            // the first hit to the application.
            DateTime firstHitDate = cp.Visit.GetDate("firstHit");

            return "The date of the first hit was " + firstHitDate;
        }
    }
}

GetInteger()

Get the visit property that matches the key. If not found, sets and returns the default value.

Signatures

GetInteger(string key);

GetInteger(string key, int defaultValue);

Arguments

defaultValue
int
call-by-value
New default value for visit property.

key
string
call-by-value
Key corresponding to visit property.

Return

int
The property corresponding to the key or the defaultValue if a value was not found.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitGetIntegerSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The button.
            string button = cp.Html5.Button("button", "Click me!");

            // Add both buttons to the form.
            string form = cp.Html5.Form(button);

            // Check if the user clicked the button.
            if (cp.Doc.GetText("button").Equals("Click me!"))
            {
                cp.Visit.SetProperty("timesClicked", 
                    cp.Visit.GetInteger( "timesClicked") + 1);

                return form + cp.Html5.P("You've clicked" +
                    " the button " + cp.Visit.GetInteger(
                        "timesClicked") + " times.");
            }
            // Return the initial form.
            return form;
        }
    }
}

GetNumber()

Get the visit property that matches the key. If not found sets and returns the default value.

Signatures

GetNumber(string key);

GetNumber(string key, double defaultValue);

Arguments

defaultValue
double
call-by-value
New default value for visit property.

key
string
call-by-value
Key corresponding to visit property.

Return

double
The property corresponding to the key or the defaultValue if a value was not found.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitGetNumberSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Made up Visit property that tallies the total 
            // number of hits to the application into a 
            // double value that represents a percentage to 
            // 1,000,000.
            double hitsGoalPercentage = cp.Visit.GetNumber("goalPercentage");

            return "Our goal of reaching 1,000,000 total hits is " +
                hitsGoalPercentage + "% complete.";
        }
    }
}

[deprecated] GetProperty()

Get desired property. User should now use get of desired type.

Signatures

GetProperty(string key);

GetProperty(string key, string defaultValue);

GetProperty(string key, string defaultValue, 
    int targetVisitId);

Arguments

defaultValue
string
call-by-value
New default value for visit property.

key
string
call-by-value
Key corresponding to visit property.

targetVisitId
int
call-by-value
Desired visit ID number. User should only set and get the current visit.

Return

string
The property corresponding to the key or the defaultValue if a value was not found.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitGetPropertySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // The user is editing if the visit property
            // 'AllowEditing' is true.
            if(cp.Visit.GetProperty("AllowEditing").Equals("false"))
            {
                return "We know you are editing!";
            }
            else
            {
                return "Hello, " + cp.User.Name + "!";
            }
        }
    }
}

GetText()

Get the visit property that matches the key. If not found, sets and returns the default value.

Signatures

GetText(string key);

GetText(string key, string defaultValue);

Arguments

defaultValue
int
call-by-value
New default value for visit property.

key
string
call-by-value
Key corresponding to visit property.

Return

string
The property corresponding to the key or the defaultValue if a value was not found.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitGetTextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            string key = "displayText";
            string defaultValue = "Hello world!";

            return cp.Visit.GetText(key, defaultValue);
        }
    }
}

SetProperty()

Set a key value for the visit.

Signatures

SetProperty(string key, bool value);

SetProperty(string key, DateTime value);

SetProperty(string key, double value);

SetProperty(string key, int value);

[deprecated]
SetProperty(string key, string value, int targetVisitId);

Arguments

key
string
call-by-value
Key corresponding to visit property.

targetVisitId
int
call-by-value
Desired visit ID number. User should only set and get the current visit.

value
string, int, double, bool, DateTime
call-by-value
New visit property value.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitSetPropertySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Example code taken from design block of this page.
            // See ApiPageClass.cs in the Contensive/Samples repo.
            if( cp.Doc.GetBoolean("publish"))
            {
                // The properties that enable editing are
                // boolean cp.Visit properties, so setting them
                // to false will allow changes to be published
                // without edit tags.
                cp.Visit.SetProperty("AllowDebugging", false);
                cp.Visit.SetProperty("AllowAdvancedEditor", false);
                cp.Visit.SetProperty("AllowEditing", false);
                // Delete the current cached file.
                cp.CdnFiles.DeleteFile("ExamplePage/ExamplePage.html");
            }
            cp.CdnFiles.Save("ExamplePage/ExamplePage.html",
                cp.Html.div("Hello world!"));

            return "";
        }
    }
}

CPVisitorBaseClass


Handles the properties containing information on each visitor to the site.

Properties


ForceBrowserMobile
bool
Sets the visit property to force the mobile state to true or false.

public abstract bool ForceBrowserMobile { get; set; }
Id
int
The visitor Id.

public abstract int Id { get; }
IsNew
bool
True if this is a new visitor.

public abstract bool IsNew { get; }
UserId
int
The id of the last user authenticated to this visitor.

public abstract int UserId { get; }

Methods


GetBoolean()

Get the visitor property that matches the key. If not found, sets and returns the default value.

Signatures

GetBoolean(string key);

GetBoolean(string key, bool defaultValue);

[deprecated]
GetBoolean(string key, string defaultValue);

Arguments

defaultValue
bool, string
call-by-value
New default value for visitor property.

key
string
call-by-value
Key corresponding to visitor property.

Return

bool
Return the property as boolean.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitorGetBoolean : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // If the Visitor property 'isLockedAccountTab'
            // is true, then the 'Account' tab will stay on 
            // the screen as opposed to it being hidden until
            // moused over.
            if(cp.Visitor.GetBoolean("isLockedAccountTab"))
            {
                return "The account tab is locked.";
            } else
            {
                return "";
            }
        }
    }
}

GetDate()

Get the visitor property that matches the key. If not found sets and returns the default value.

Signatures

GetDate(string key);

GetDate(string key, DateTime defaultValue);

[deprecated]
GetDate(string key, string defaultValue);

Arguments

defaultValue
DateTime, string
call-by-value
New default value for visitor property.

key
DateTime, string
call-by-value
Key corresponding to visitor property.

Return

DateTime
Return the property as a DateTime value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitorGetDateSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Display a made up Visitor property that
            // records the date each visitor visitted.
            return "The last visitor was here on " +
                cp.Visitor.GetDate("lastVisitorDate") + ".";
        }
    }
}

GetInteger()

Get the visitor property that matches the key. If not found, sets and returns the default value.

Signatures

GetInteger(string key);

GetInteger(string key, int defaultValue);

[deprecated]
GetInteger(string key, string defaultValue);

Arguments

defaultValue
int, string
call-by-value
New default value for visitor property.

key
string
call-by-value
Key corresponding to visitor property.

Return

int
Return the property as an integer value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitorGetInteger : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // If the Visitor property 'AllowAdminTabs'
            // is true, then the current visitor is an
            // authenticated admin.
            if(cp.Visitor.GetInteger("AllowAdminTabs") == 1)
            {
                return "Edit wisely, " + cp.User.Name + ".";
            } else
            {
                return "";
            }
        }
    }
}

GetNumber()

Get the visitor property that matches the key. If not found sets and returns the default value.

Signatures

GetNumber(string key);

GetNumber(string key, double defaultValue);

[deprecated]
GetNumber(string key, string defaultValue);

Arguments

defaultValue
double, string
call-by-value
New default value for visitor property.

key
string
call-by-value
Key corresponding to visitor property.

Return

double
Return the property as a double value.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitorGetNumberSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Return a made up Visitor property that 
            // records a percentage of profile completeness.
            return "Your profile is " +
                cp.Visitor.GetNumber(
                    "profileCompletionPercentage") +
                "% complete";
        }
    }
}

GetObject

Read a visitor property as an object.

                        





[deprecated] GetProperty()

Get desired property. User should now use get of desired type.

Signatures

GetProperty(string key);

GetProperty(string key, string defaultValue);

GetProperty(string key, string defaultValue, 
    int targetVisitId);

Arguments

defaultValue
string
call-by-value
New default value for visitor property.

key
string
call-by-value
Key corresponding to visitor property.

targetVisitorId
int
call-by-value
The target visitor ID to get the property from as opposed to the current visitor.

Return

string
Return the property as string.

Examples:

using Contensive.BaseClasses;

namespace Samples
{
    public class VisitorGetPropertySample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // If the Visitor property 'isLockedAccountTab'
            // is true, then the 'Account' tab will stay on 
            // the screen as opposed to it being hidden until
            // moused over.
            if (cp.Visitor.GetProperty("isLockedAccountTab").Equals("True"))
            {
                return "The account tab is locked.";
            }
            else
            {
                return "";
            }
        }
    }
}

GetText()

Get the visitor property that matches the key. If not found, sets and returns the default value.

Signatures

GetText(string key);

GetText(string key, string defaultValue);

Arguments

defaultValue
string
call-by-value
New default value for visitor property.

key
string
call-by-value
Key corresponding to visitor property.

Return

string
Return the property as string.

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitorGetTextSample : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // Display made up visitor text properties to users
            // on a desktop or mobile.
            if(cp.Visitor.ForceBrowserMobile)
            {
                return cp.Visitor.GetText("mobileDisplayMessage",
                    "Hello, mobile user!");
            } else
            {
                return cp.Visitor.GetText("browserDisplayMessage",
                    "Hello, desktop user!");
            }
        }
    }
}

SetProperty()

Set a key value for the visitor.

Signatures

SetProperty(string key, bool value);

SetProperty(string key, DateTime value);

SetProperty(string key, double value);

SetProperty(string key, double value);

SetProperty(string key, int value);

SetProperty(string key, string value);

[deprecated]
SetProperty(string key, string value, int targetVisitorid);

Arguments

key
string
call-by-value
Key corresponding to visitor property.

targetVisitorid
int
call-by-value
The target visitor ID to get the property from as opposed to the current visitor.

value
string, int, double, bool, DateTime
call-by-value
New value for specified property.

Return

void

Examples:

using Contensive.BaseClasses;

namespace Contensive.Samples
{
    public class VisitorSetProperty : AddonBaseClass
    {
        public override object Execute(CPBaseClass cp)
        {
            // If the user is new, set the made up Visitor 
            // property 'profileCompletionPercentage' 
            // to 0.0%.
            if(cp.Visitor.IsNew) {
                cp.Visitor.SetProperty(
                    "profileCompletionPercentage", 0.0);
            }
            return "";
        }
    }
}

FileSystem.FileDetail


Class belonging to CPFileSystemBaseClass. Contains argument details for file and folder methods.

Properties


Attributes
int
The file attributes.

public int Attributes { get; set; }
DateCreated
DateTime
Date the file was created.

public DateTime DateCreated { get; set; }
DateLastAccessed
DateTime
The date the file was last accessed.

public DateTime DateLastAccessed { get; set; }
DateLastModified
DateTime
The date the file was last modified.

public DateTime DateLastModified { get; set; }
Extension
string
The file's dot extension.

public string Extension { get; }
Name
string
The file name.

public string Name { get; set; }
Size
long
Size of the file in bytes. insert description

public long Size { get; set; }
Type
string
The file type. insert description

public string Type { get; set; }

FileSystem.FolderDetail


Class belonging to CPFileSystemBaseClass. Contains argument details for file and folder methods.

Properties


Attributes
int
The folder attributes. insert description

public int Attributes { get; set; }
DateCreated
DateTime
The date the folder was created.

public DateTime DateCreated { get; set; }
DateLastAccessed
DateTime
The date the folder was last accessed.

public DateTime DateLastAccessed { get; set; }
DateLastModified
DateTime
The date the folder was last modified.

public DateTime DateLastModified { get; set; }
Name
string
The folder name.

public string Name { get; set; }
Type
DateTime
The type of the folder.

public abstract DateTime Type { get; set; }

Utils .addonExecuteHostRecordContext


insert description

Properties


contentName
string
Name of desired content table.

public string contentName;  
fieldName
string
Name of desired field in the content table.

public string fieldName;  
recordId
int
Id number of record in desired content table.

public int recordId;  

Utils.addonExecuteContext


Class contained within CPUtilsBaseClass. Contains properties that relate to the context in which an addon is executed.

Properties


addonType
addonExecuteHostRecordContext
Selects the enumeration option that describes the environment in which the addon is being executed (in an email, on a page, as a remote method, etc).

public addonExecuteHostRecordContext addonType { get; set; } = addonContext.ContextSimple;
argumentKeyValuePairs
Dictionary<string, string>
Optional. Name value pairs added to the document environment during execution so they be read by addon programming during and after execution with cp.doc.getText(), etc.

public Dictionary<string, string> argumentKeyValuePairs { get; set; } = new Dictionary<string, string>();
backgroundProcess
bool
When true, the environment is run from the task subsystem, without a UI. Assemblies from base collection run from program files. Addon return is ignored.

public bool backgroundProcess { get; set; } = false;
cssContainerClass
string
Optional. If included, the addon will be wrapped with a div and this will be the html class value of the div. May be used to customize the resulting html styles.

public string cssContainerClass { get; set; } = "";
cssContainerId
string
Optional. If included, the addon will be wrapped with a div and this will be the html Id value of the div. May be used to customize the resulting html styles.

public string cssContainerId { get; set; } = "";
errorContextMessage
string
This caption is used if the addon cannot be executed.

public string errorContextMessage { get; set; }
forceHtmlDocument
bool
Optional. If set true, the addon being called will be delivered as ah html document, with head, body and html tags. This forces the addon's htmlDocument setting.

public bool forceHtmlDocument { get; set; } = false;
forceJavascriptToHead
bool
When true, an addon's javascript will be put in the head. This also forces javascript for all dependant addons to the head.

public bool forceJavascriptToHead { get; set; } = false;
hostRecord
addonExecuteHostRecordContext
Optional. If this addon is run automatically because it was included in content, this is the contentName, recordId and fieldName of the record that held that content.

public addonExecuteHostRecordContext hostRecord { get; set; } = new addonExecuteHostRecordContext();
instanceGuid
string
Optional. If the addon is run from a page, it includes an instanceGuid which can be used by addon programming to locate date for this instance.

public string instanceGuid { get; set; } = "";
isIncludeAddon
bool
Optional. If true, this addon is called because it was a dependancy, and can only be called once within a document.

public bool isIncludeAddon { get; set; } = false;
wrapperID
int
Optional. If included, this is the id value of a record in the Wrappers content and that wrapper will be added to the addon return result.

public int wrapperID { get; set; } = 0;

v1912201816