PyroCMS

Notice: PyroCMS v 2.2.x is depreciated and is no long under development. This documentation is provided as-is, free of charge, for reference in existing websites.

Standard Fields

When you create a stream, the following fields are created automatically:

Field Notes
id An auto-incrementing standard primary key ID.
created A MySQL datetime field of when an entry was created.
updated A MySQL datetime field of the last time an entry was updated.
created_by ID of the user who initially created the entry.
ordering_count Incrementing numerical ordering count.

When using standard Streams functions, all of these fields will be populated automatically. For instance, when you create a new entry in a stream using streams functions, the ordering_count will be populated by an integer that is one more than the highest value in ordering_count.

add_stream

add_stream($stream_name, $stream_slug, $namespace, $prefix = null, $about = null, $extra = array())

The add_stream function allows you to create a stream. It will create the actual table in the database, as well as the streams metadata in the streams table.

Parameters

Parameter Required? Notes
stream_name Yes The full name of the stream.
stream_slug Yes The stream slug.
namespace Yes A namespace for your stream.
prefix Optional. A stream prefix. Will be used in the stream database table name.
about Optional. A short blurb about the stream.
extra Optional. An array of extra configuration variables (see below).

The $extra array possible values are as follows. None of them are required. Note that with the exception of title_column, it is up to the module using these streams to implement these features. For instance, get_streams will not automatically filter our streams that have is_hidden set to yes, you as a developer will need to do that yourself.

Name Default Value Type Notes
title_column null string A slug of the field that should be the title column. For more information on title columns, see the something docs.
is_hidden no string (yes or no) This will hide the stream from any stream listings that support is_hidden.
sorting title string (title or custom) This determines the entry sorting where supported. title will sort the title column DESC, and custom will sort by the ordering_count column ASC.
menu_path null string Menu path where supported. Takes a simple string with the main and sub menu seprated by a forward slash. Ex: Content / FAQs.
view_options array('id', 'created') array An array of field slugs that can be used when listing entries to control which fields are being displayed.

Example:

In this example we add the FAQ stream. The module is also called faqs, our namespace is called faq. We are providing the faq_ prefix, so our table will be created as default_faq_faqs (sitename, prefix and slug concatenated). Without specifying any prefix, it would be default_faqs (sitename and slug concatenated).

$this->streams->streams->add_stream('FAQ', 'faqs', 'faq', 'faq_', null);

get_stream

get_stream($stream, $namespace = null)

Gets data about a stream. It does not retrieve entries, just the stream metadata.

Example:

// Stream String
$this->streams->streams->get_stream('faqs', 'faq');

// Stream Object
$this->streams->streams->get_stream($faq_stream);

// Stream Id
$this->streams->streams->get_stream(2);

Example Return:

stdClass Object
(
    [id] => 18
    [stream_name] => FAQs
    [stream_slug] => faqs
    [stream_namespace] => faq
    [stream_prefix] => faq_
    [about] => 
    [view_options] => Array
        (
            [0] => id
            [1] => created
        )

    [title_column] => question
    [sorting] => title
)

get_streams

get_streams($namespace)

Gets basic data about all the streams in a namespace.

Example:

$this->streams->streams->get_streams('faq');

Returns:

Array
(
    [0] => stdClass Object
        (
            [id] => 18
            [stream_name] => FAQs
            [stream_slug] => faqs
            [stream_namespace] => faq
            [stream_prefix] => faq_
            [about] => 
            [view_options] => Array
                (
                    [0] => id
                    [1] => created
                )

            [title_column] => question
            [sorting] => title
        )
)

update_stream

update_stream($stream, $namespace = null, $data = array())

Allows you to update stream metadata. This function will take any of the parameters of add_stream (including values in the $extra array) and update the stream accordingly. Any changes in the stream prefix or slug will result in the stream table being renamed.

Returns boolean.

Example:

$update_data = array(
    'stream_slug'   => 'the_faqs',
    'about'         => 'A list of frequently asked questions.',
    'view_options'  => array('question')
);

$this->streams->streams->update_stream('faqs', 'faq', $update_data);

delete_stream

delete_stream($stream_slug, $namespace = null)

Deletes a stream. This will delete all the entries associated with this stream as well, as well as run all of the field destruct functions for fields assigned to this stream.

This streams returns true or false, based on whether the streams was successfully deleted.

Example:

$this->streams->streams->delete_stream('faqs', 'faq');

get_assignments

get_assignments($stream, $namespace = null)

Gets assignments for a stream.

Example:

$this->streams->streams->get_assignments('faqs', 'faq');

Returns:

Array
(
    [0] => stdClass Object
        (
            [id] => 10
            [stream_name] => FAQs
            [stream_slug] => faqs
            [stream_namespace] => faq
            [stream_prefix] => faq_
            [about] => 
            [title_column] => question
            [sorting] => title
            [stream_view_options] => a:2:{i:0;s:2:"id";i:1;s:7:"created";}
            [stream_id] => 18
            [field_id] => 10
            [field_name] => Question
            [field_slug] => question
            [field_namespace] => faq
            [field_type] => text
            [field_data] => a:1:{s:10:"max_length";i:200;}
            [field_view_options] => 
        )

    [1] => stdClass Object
        (
            [id] => 11
            [stream_name] => FAQs
            [stream_slug] => faqs
            [stream_namespace] => faq
            [stream_prefix] => faq_
            [about] => 
            [title_column] => question
            [sorting] => title
            [stream_view_options] => a:2:{i:0;s:2:"id";i:1;s:7:"created";}
            [stream_id] => 18
            [field_id] => 11
            [field_name] => Answer
            [field_slug] => answer
            [field_namespace] => faq
            [field_type] => textarea
            [field_data] => a:0:{}
            [field_view_options] => 
        )
)