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(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
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
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(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
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
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
Clear()
Clear the contents of the current block.
Signatures
Arguments
Return
Dispose()
Support IDisposable.
Signatures
Arguments
Return
GetHtml()
Return the entire html of the current block.
Signatures
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
Load()
Load the block with an HTML string.
Signatures
Arguments
-
htmlString
string
call-by-value
-
The HTML string to load.
Return
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
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
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
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
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
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
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
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
Arguments
Return
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
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
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
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
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
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
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
Arguments
-
key
string
call-by-value
-
Cache object referenced by key.
Return
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
Arguments
Return
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
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
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
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
[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
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
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
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
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
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
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
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, 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
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
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
Enums
fileTypeIdEnum
File types that indicate the type of a content field upon creation.
Types
cp.Content.fileTypeIdEnum.Integer
cp.Content.fileTypeIdEnum.Text
cp.Content.fileTypeIdEnum.LongText
cp.Content.fileTypeIdEnum.Boolean
cp.Content.fileTypeIdEnum.Date
cp.Content.fileTypeIdEnum.File
cp.Content.fileTypeIdEnum.Lookup
cp.Content.fileTypeIdEnum.Redirect
cp.Content.fileTypeIdEnum.Currency
cp.Content.fileTypeIdEnum.FileText
cp.Content.fileTypeIdEnum.FileImage
cp.Content.fileTypeIdEnum.Float
cp.Content.fileTypeIdEnum.AutoIdIncrement
cp.Content.fileTypeIdEnum.ManyToMany
cp.Content.fileTypeIdEnum.MemberSelect
cp.Content.fileTypeIdEnum.FileCSS
cp.Content.fileTypeIdEnum.FileXML
cp.Content.fileTypeIdEnum.FileJavascript
cp.Content.fileTypeIdEnum.Link
cp.Content.fileTypeIdEnum.ResourceLink
cp.Content.fileTypeIdEnum.HTML
cp.Content.fileTypeIdEnum.FileHTML
GoogleVisualizationStatusEnum
The status codes outputted by Google Visualization.
Types
cp.Content.GoogleVisualizationStatusEnum.OK
cp.Content.GoogleVisualizationStatusEnum.warning
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
Arguments
Return
Delete()
Deletes the current row.
Signatures
Arguments
Return
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
Arguments
Return
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(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(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
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
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
Arguments
Return
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
Arguments
Return
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
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
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, 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, 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
Arguments
Return
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
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
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
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
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
Arguments
Return
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
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
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, 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
[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
Arguments
-
html
string
call-by-value
-
Html to be inserted at the end of the body.
Return
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
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
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
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
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
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
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
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
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
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
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
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, 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, 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, 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, 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, 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, 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
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
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
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
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
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
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
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
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, 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
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
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
[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
[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
[deprecated] Delete()
Delete a file within the file space.
Signatures
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
[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
[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
[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
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.