Hi guys,
I am trying to add a new custom module but I still get the following error:
Fatal error: Class ‘td_module_16’ not found in …/includes/shortcodes/td_block_1.php on line 49
Things I did:
1. created td_module_16.php with the same almost the same content as td_module_4.php:
<?php
class td_module_4 extends td_module {
function __construct($post) {
//run the parrent constructor
parent::__construct($post);
}
function render() {
ob_start();
?>
<div class="<?php echo $this->get_module_classes();?>" <?php echo $this->get_item_scope() ?>>
<div class="td-module-image">
<?php echo $this->get_image('td_300x194'); ?>
<?php if (td_util::get_option('tds_category_module_4') == 'yes') { echo $this->get_category(); }?>
</div>
<?php echo $this->get_title(12); ?>
<div class="meta-info">
<?php //echo $this->get_author();?>
<?php //echo $this->get_date();?>
<?php echo $this->get_comments();?>
</div>
<div class="td-excerpt">
<?php echo $this->get_excerpt(25); ?>
</div>
<?php if(empty(td_global::$is_wordpress_loop)){echo $this->get_quotes_on_blocks();}?>
<?php echo $this->get_item_scope_meta(); ?>
</div>
<?php
return ob_get_clean();
}
}
2. Edited td_block_1.php, because I want to use this custom module inside this block:
function inner($posts, $td_column_number = '') {
$buffy = '';
$td_block_layout = new td_block_layout();
if (empty($td_column_number)) {
$td_column_number = td_util::vc_get_column_number(); // get the column width of the block from the page builder API
}
$td_post_count = 0; // the number of posts rendered
if (!empty($posts)) {
foreach ($posts as $post) {
$td_module_16 = new td_module_16($post);
$td_module_6 = new td_module_6($post);
switch ($td_column_number) {
case '1': //one column layout
$buffy .= $td_block_layout->open12(); //added in 010 theme - span 12 doesn't use rows
if ($td_post_count == 0) { //first post
$buffy .= $td_module_16->render();
} else {
$buffy .= $td_module_6->render();
}
$buffy .= $td_block_layout->close12();
break;
case '2': //two column layout
$buffy .= $td_block_layout->open_row();
if ($td_post_count == 0) { //first post
$buffy .= $td_block_layout->open6();
$buffy .= $td_module_16->render();
$buffy .= $td_block_layout->close6();
} else { //the rest
$buffy .= $td_block_layout->open6();
$buffy .= $td_module_6->render();
}
break;
case '3': //three column layout
$buffy .= $td_block_layout->open_row();
if ($td_post_count == 0) { //first post
$buffy .= $td_block_layout->open4();
$buffy .= $td_module_16->render();
$buffy .= $td_block_layout->close4();
} else { //2-3 cols
$buffy .= $td_block_layout->open4();
$buffy .= $td_module_6->render();
if ($td_post_count == 4) { //make new column
$buffy .= $td_block_layout->close4();
}
}
break;
}
$td_post_count++;
}
}
$buffy .= $td_block_layout->close_all_tags();
return $buffy;
}
3. I added the following code to td_config.php:
'td_module_16' => array (
'text' => 'Module 4 custom',
'img' => get_template_directory_uri() . '/includes/wp_booster/wp-admin/images/panel/module-4.png',
'used_on_blocks' => array ('td_block_1', 'td_block_2'),
'excerpt_title' => 12,
'excerpt_content' => 25,
'enabled_on_more_articles_box' => true,
'enabled_on_loops' => true,
'uses_columns' => true, // if the module uses columns on the page template + loop
'category_label' => true
),
What did I forget to do?
Hi,
Use the error message to track and find the source of the error then double check the file to make sure that you did everything right.
If you still can’t get this right we suggest to get someone to helps you with it as unfortunately you’ll need custom work for this which we cannot offer at this time as we work hard on the development, updates, fixes and support. You can always get a freelancer from sites like: http://studio.envato.com/ if you don’t know how to do it yourself.
Sorry for the inconvenience!
Thanks for the message!