LEAP™ is a content editor’s dream (CMS), a designer’s best option, and the perfect framework for site development.
LEAP™ is simpleLEAPLEAP™ is secureLEAPLEAP™ is SEO-centric

Required Functions: insert / create

When a content plugin is inserted into a page, a "create" command is issued to the new instance via the $actionis variable. At this stage the database reference to the plugin instance should already exist, as verified by $ContentID.

Your plugin should include this handler and use it to set up default content or functionality if required.

It should also be used to switch the user to edit mode if required.

An example of a "Create Handler"

if($actionis == 'create' && $gv_admin == true) => {
    if($ContentID > 0) => {
        inline($gv_sql,
            -SQL='
                INSERT INTO Master_Content 
                SET ContentID = ' + $ContentID + ',
                    status = "html",
                    html = "Insert content here";
                    SELECT LAST_INSERT_ID() AS thisid;'
        ) => { 
            xs_iserror
            $gv_admin = true
            LEAP_audit->save('create','Msg',0,integer(field('thisid')),$ContentID)
        }
    }
}

Explaining the "Create Handler" above

The conditional on line 1 includes both the entry condition to the method (ie, $actionis == 'create') as well as an additional check to ensure appropriate admin authentication ($gv_admin == true).

Line 2 contains an additional conditional to ensure a successful SQL insert in the LEAP_Admin Kernel. This is essentially a safety net.

Line 3+ is the SQL insert with the default initial content. If your plugin's content or operational model is Object Oriented then here you would invoke the initiate method.

Line 12 (xs_iserror) collectes any errors from the SQL statement.

Line 13 ($gv_admin = true) ensures the returned mode is edit. If you wish your returned state on insert to be display, set this to false.

Line 14 (LEAP_audit) inserts an entry into the plugin's audit trail.

© Copyright LEAP™ 2017 | Privacy Policy | Design by Treefrog Inc.