Error creating custom block Modules with td-api-plugin

Posted in: Newspaper
Post count: 4

Hello,

i have created two custom blocks. I want to use them inside a “Module cloud template” to render items in a “Flex Loop Builder”
I used de td-api-plugin. I can drag and Drop de block inside de tag div editor but something is not working. I can save de “module template” the first time but when i edit again it returns an ERROR “Errors at columns elements: 1(models) : 0(dom). The model does not match the content Current state has involved an issue. You could try an UNDO operation (CTRL+Z / CTRL+SHIFT+Z)”
What i am doing wrong?

This is how i add the api block (it has no parameters, all is coded into de file that renders the module -> td_video_empresa.php):

td_api_block::add('td_video_empresa',
array(
'map_in_visual_composer' => false,
'map_in_td_composer' => true,
"name" => 'Mòdul Video Empresa',
"base" => "td_video_empresa",
'tdc_category' => 'Modules elements',
'file' => $this->plugin_path . '/modules/td_video_empresa.php',
"params" =>
array_merge(
td_config::get_map_block_general_array()
)
)
);

This is the file that renders the block -> td_video_empresa.php

class td_video_empresa extends tdb_module_template_part {

function render( $atts, $content = null ) {

/* -- Call the parent render method -- */
parent::render($atts);

/* -- Retrieve the module post data -- */
$post_obj = self::$post_obj;
$post_type = null;

$postID=$post_obj->ID;

$url_video=get_field("url_video_empresa",$postID);
$video_extern=get_field("link_finestra_nova",$postID);

$logo=get_post_thumbnail_id($postID);
$linkEmpresa=get_permalink($postID);
$tituloEmpresa=$post_obj->post_title;

$string="";

$string.=renderVideo($url_video,220,$tituloEmpresa,$postID);

$string.='<div class="modul-caixa" >';
$string.='<h3 style="margin:0px;">'.$post_obj->post_title.'</h3>';
$string.='</div>';

return $string;

}

}

Post count: 35449

Hi Danizar, if you want to create a module for your website, you can use the module builder (those modules can be used on Flex Block Builder and Flex Loop Builder). This is easier than creating a classic module in code and you’ll avoid problems like the one you are facing now. If you want to create a simple module, you can use the example from here – https://forum.tagdiv.com/practical-example-how-to-add-a-new-block-and-module/

Post count: 4

I’ve come up to a solution using the default FLex Module Block. Thank You.

Viewing 3 posts - 1 through 3 (of 3 total)
The forum ‘Newspaper’ is closed to new topics and replies.