td_api_module::update

Available on: Newsmag V1.8+, Newspaper V5+
This api call is used to update  the parameters of an existing module .

Usage:

<?php td_api_module::update( $id, $params_array ) ?>

Parameters:

$id (string) (required)

  • the module id – has to match with one of the modules which are already registered in the theme

$params_array (array) (required)

  • an array which contains the parameters of the module:
Key name
Type
Description
file string the path of the module template file
text string the module title, appears in Theme Panel and on Article List settings area
img string the path for the icon used to represent the module
used_on_blocks array the blocks on which this module is used
excerpt_title integer title excerpt length
excerpt_content integer content excerpt length
enabled_on_more_articles_box boolean show the module in the more articles box in panel -> post settings -> more articles box
enabled_on_loops boolean show the module in panel on loops
uses_columns boolean enable/disable column use on this block, if it’s disabled it will display only one module on each row
category_label boolean show the module in panel -> block_settings -> category label
class string classes added on the module wrapper

Examples:

In the following example we’ll update the existing Module 1 , you can see how the code looks on plugin, you have to modify the file path to match with the plugin current folder, we use the variables which were introduced in the Plugin Method section, ex:

td_api_module::update('td_module_1',
    array(
        'file' => $this->plugin_path . '/includes/modules/td_module_1.php',
        'text' => 'Module 1',
        'img' => $this->plugin_url . '/images/panel/modules/td_module_1.png',
        'used_on_blocks' => array('td_block_3'),
        'excerpt_title' => 12,
        'excerpt_content' => '',
        'enabled_on_more_articles_box' => true,
        'enabled_on_loops' => true,
        'uses_columns' => true,
        'category_label' => true,
        'class' => 'td_module_wrap td-animation-stack',     // custom css module class
    )
);