B class is the heart of Bildy. It processes a Bildy block that may contain all kinds of B tags.
B class also contains many static methods that are used to handle different aspects in Bildy.
Functions
capitalize
Converts first letters from all words to uppercase.
Description
Converts first letters from all words to uppercase.
Use this method instead of PHP's own function since this one is UTF-8 safe.
Parameters
- str
- The string to capitalize.
Return Values
Converted string.create
Creates a new API_CreateData object.
Description
This is a convenience method to create an API_CreateData object.
Parameters
- datamodel
- Either B_Datamodel or a string name of data model.
Return Values
A new API_CreateData object.formListener
Registers a form listener
Description
Registers a form listener function that gets fired when a form with a given trigger field is sent.
The function is triggered after the page has been parsed and before it has been output.
Parameters
- trigger
- Form field to listen.
- function
- The name of the listener function.
Return Values
No value is returned.get
Creates a new API_GetData object.
Description
This is a convenience method to create an API_GetData object.
Parameters
- datamodel
- Data model from which to get contents.
- cached(optional, default: true)
Used internally by Bildy to define when to clear cache for the shown page. This is always safe to be left to TRUE, but it can also be set to FALSE if using this function inside non-cached PHP for slightly more sticky caching in some cases.
Do not set this to FALSE in cached PHP mode or you might end up having cache invalidation problems.
Return Values
A new API_GetData object.getContent
Gets a B_Content object.
Description
This method should always be used when a B_Content object is needed. Bildy creates only one B_Content object for each content, and this method is the way to get that object.
If a B_Content object is created directly, it is possible to have multiple objects for a single content which adds unnecessary overhead.
Parameters
- datamodel
If id isn't defined, datamodel should be a path to the content.
If id is defined, datamodel should be name of the data model of the content.
Return Values
B_Content object.getContentPath
Returns a content path that can be used to define the content location to Bildy.
Description
Returns a path that can be used to define content location to Bildy.
To get the URL that is usable in links for a content even if the site is not in the root of the domain, use B::getContentUrl().
Parameters
- datamodel
Data model of the content.
- id
- The id of content.
Return Values
Bildy path of the content.getContentUrl
Returns a content URL that can be used in links.
Description
Returns a URL that is usable in links for a content even if the site is not in the root of the domain.
To get the path that can be used to define content location to Bildy, use B::getContentPath().
Parameters
- datamodel
If id isn't defined, datamodel should be a path to the content.
If id is defined, datamodel should be name of the data model of the content.
- id(optional, default: null)
- The id of content. Define only if datamodel is set to a data model name.
Return Values
URL to the content (without protocol and domain part).getDatamodel
Returns B_Datamodel instance for a data model
Description
Return Values
An instance of B_Datamodel.getField
Returns the value of a field from the results of b:get tag.
Description
You can use this function inside a b:get block to get a value from the b:get tag results. This is useful when you want to handle the value in PHP before outputting it.
Parameters
- get
- The name attribute of the b:get block to get field from.
- field
- The field's name where to get value from.
- parameters(optional, default: array())
The optional parameters parameter allows specifying parameters to the field just like you would pass attributes to a B tag.
You can pass parameters as a string, for example width="100" height="80" or as an array with keys as attribute names and values as attribute values.
Return Values
Output from the field.
includeTemplate
Includes a template and returns the output.
Description
Includes a template just like b:include tag, but returns the output instead of outputting it.
Parameters
- file
- File name of the template to include. Templates can only be included from the templates directory under the Bildy's system directory.
Return Values
Output generated from the template found in the given file name.preventFastCache
Prevents fast caching
Description
Calling this function will tell Bildy not to create a fast cache file for currently running page. This needs to be done if there is something on the page that needs to be executed on each page load.
Please note that you do not need to call this when using PHP without caching since Bildy knows not to use the fast cache if non-cached PHP is used.
This method is necessary only when developing modules (currently undocumented feature).
Return Values
No value is returned.remove
Removes a content from the site.
Description
With this method removing a single content is fast and easy.
There's no way to cancel the action, so be careful.
Parameters
- datamodel
If id isn't defined, datamodel should be a path to the content.
If id is defined, datamodel should be name of the data model of the content.
- id(optional, default: null)
- The id of content. Define only if datamodel is set to a data model name.
Return Values
The Response object returned contains information that is mostly useful to Bildy Editor. You can however use the Response::hasErrors() method to see if there was an error.
strtolower
Converts all letters to lowercase.
Description
Converts all letters to lowercase.
Use this method instead of PHP's own function since this one is UTF-8 safe.
Parameters
- str
- The string to convert to lowercase.
Return Values
String with all letters in lowercase.strtoupper
Converts all letters to uppercase.
Description
Converts all letters to uppercase.
Use this method instead of PHP's own function since this one is UTF-8 safe.
Parameters
- str
- The string to convert to uppercase.
Return Values
String with all letters in uppercase.structure
Creates a new API_GetStructure object.
Description
This is a convenience method to create an API_GetStructure object.
Return Values
A new API_GetStructure object.update
Creates a new API_UpdateData object.
Description
This is a convenience method to create an API_UpdateData object.
Parameters
- datamodel
If id isn't defined, datamodel should be a path to the content.
If id is defined, datamodel should be name of the data model of the content.
- id(optional, default: null)
- The id of content. Define only if datamodel is set to a data model name.
Return Values
A new API_UpdateData object.urllevel
Returns a slice from given URL.
Description
This method cuts a relative URL into the length given.
Parameters
- url
- The URL to slice.
- level
If level is positive, URL will have at most that many levels.
If level is negative, URL will stop that many levels from the end of the URL.
Return Values
Sliced URL.value
Gets or sets a Bildy value
Description
You can get or set values set by this function or by b:value tag. b:value tag also gets the values set by this function.
Parameters
- key
- The value to get or set.
- value(optional, default: null)
- If value is set, it will be stored to Bildy values.
- showerror(optional, default: false)
If a value is not set and showerror is set to TRUE, Bildy will trigger a warning.
Defaults to FALSE.
- default(optional, default: null)
Sets a default value to return if there is no value set with value name set in key.
If this is set, showerror has no effect since the default value is returned instead of triggering a warning.

