#1 April 10, 2012 3:04pm

Farnsworth
Member
Registered: March 30, 2012
Posts: 13

Basic PHP for your Templates

Here are the BigTree functions most frequently used when creating templates.
Generic
Items in this list can be included in your template files by placing them inside php echo tags:
Page Resources

Page resources are pieces of content created in BigTree. Any page resource can be included in your tamplates by appending a dolar-symbol $ to the beginning of the resource id.
For example:


$page

Displays attributes from the current page. For example, $page["title"] would display the page title, as set in BigTree's "page properties" screen. Some frequently-used attributes include:

  • id

  • title

  • meta_keywords

  • meta_description

$www_root

Your site's URL.
$cms->
The BigTreeCMS class does most of the heavy-lifting for the front-end of your site. To access BigTreeCMS in your templates, use $cms-> before the function.
getLink()

Gets the full URL when given a page id (which can be found in the BigTree admin).
will give the full URL to page 2.
getSetting() and getSettings()

$cms->getSetting() to get the content of a single setting. For example, if you stored a contact email address as a setting, you might access it with $cms->getSetting("contact_email").
If you need to access multiple settings in a single template, use $cms->getSettings(), like this:$settings = $cms->getSettings(array(
    "contact_email",
    "contact_phone"
));

Use these settings in your template:

getNavByParent()

Use $cms->getNavByParent() to create your site's nav menus. See the Navigation documentation for more information.

BigTree::
The BigTree class contains many functions useful throughout the front and back of your BigTree site. To access this class in your templates, use BigTree:: folowed by the name of the function.
trimLength()

Control the length of content with BigTree::trimLength(). The function is smart enough not to count html tags against the length of your content.
For example: BigTree::trimLength($string, 150)

would trim the value of $string to 150 characters, appending an ellipsis to the end of the output.
prefixFile()

When you use BigTree to create prefixed crops or thumbnails of an image, you'll need BigTree::prefixFile() to access the resulting images. Pass in the file name or URL, and the desired prefix:
For example, to get prefix_image.png from http://example.com/images/image.png as $file:BigTree::prefixFile($file, "prefix_")

BigTreeModule->
Use the BigTreeModule to help work with your site's database. All modules you create will inherit from this class. So if you have a class BTXNews, access BigTreeModule functions by first instantiating BTXNews
$newsMod = new BTXNews; then using $newsMod-> followed by the function name.
getAll()

Get all entries from the given module. $newsMod->getAll() would give all entries from our news module.
getAllPositioned()

Get all module items ordered based on their position.
getApproved()

Get all approved module entries.
getFeatured()

Get all module entries that have been marked as featured.
getUpcoming()

Get all module entries with a date attribute greater than the current date.

Offline

#2 July 24, 2012 12:05pm

benplum
Administrator
Registered: March 30, 2012
Posts: 54

Re: Basic PHP for your Templates

Remember that the $config variable has be deprecated. Please use $bigtree["config"] instead.

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.