I’m trying to figure out a way to customize flex block 4. I’ve looked at Custom Modules Template and tried to work from a blank one. But that doesn’t seem very promising.
What I am trying to do is add a second category to hover over the images in the block. I want to add a ‘Sponsored Content’ label on the image alongside the category.
What is the best way to go about that? I tried building a custom module from a blank template but that wasn’t making progress. I looked to see if there were any hooks I could get into, to add the code needed – no luck so far.
I really just need to get it to recognize the second category and put it into the DOM. I could manipulate it with javascript to get it to become what I need. But I don’t see any way to customize/modify flex block 4 to do this.
Any help would be appreciated
Hello @wordpressive!
Try to add this element: Module Categories/Taxonomies with these settings:
-> https://app.screencast.com/4mEGO0dbxKzwQ (transparent on the first option and with color on the second option for hover). So, it will display only on hover.
-> https://app.screencast.com/N0xGni8CCteBl this will help to place it over the image
The same settings could be done with an inline text.
Thank you!
Recreating it in custom module misses a lot of the features I can’t seem to replicate. Like using ajax categories dropdown on the header.
Where can I find the code for Flex Block 4, if I wanted to modify it? Or are there any hooks available?
Hello @wordpressive!
Check this guide: https://forum.tagdiv.com/api-blocks-introduction/
I hope that helps you!
Thank you!
Thank you. Is it possible for you to show me where in the code Flex Block 4 was added/created, so I could copy/modify that code? I assume it uses this same API? I want to use it as an example to follow.
Hello @wordpressive!
The theme blocks are registered in td-composer/legacy/Newspaper/includes/td_config.php
Thank you!
I’m trying to get this working, I made a custom plugin following the documentation (https://forum.tagdiv.com/the-plugin-method/)
I copied the code for flex block 4 from td_config_blocks and put it into the plugin
//hook used to add or modify items via Api
add_action( 'tdc_loaded' , function() { //add the api code inside this function
td_api_block::add( 'td_flex_block_4_custom',
array(
'map_in_visual_composer' => false,
'map_in_td_composer' => true,
"name" => 'Flex Block 4 Custom',
"base" => 'td_flex_block_4_custom',
"class" => 'td_flex_block_4',
"controls" => "full",
"category" => 'Blocks',
'tdc_category' => 'Blocks',
'icon' => 'icon-pagebuilder-td_flex_block_4',
'file' => TDC_PATH_LEGACY . '/includes/shortcodes/td_flex_block_4.php',
I copied all the ‘tdc_style_params’ ‘tdc_start_values’ ‘params’ as well but don’t want to paste them here as they are very large.
I changed the parameters that seemed to need changing, by adding _custom ad the end of them. But kept all the code the same.
When I activate my plugin and try to load it in TD Composer it doesn’t load.
tdcJobManager.addJob - Error callback - textStatus: error errorThrown:
js_files_for_wp_admin.min.js?ver=e12b81d6cbdf467845997a891495df2cx:42 jobRequest {shortcode: '[td_flex_block_4_custom modules_category="image" m…xcerpt1="" show_excerpt2="none" hide_audio="yes"]', columns: 2, jobId: 1, postId: '40247', replyHtml: ''}
tdcJobManager.addJob - ERROR: 500 server error
I see in the logs this:
Fatal error: Uncaught Error: Class 'td_flex_block_4_custom' not found
in public_html/wp-content/plugins/td-composer/legacy/common/wp_booster/td_global_blocks.php on line 33
Any help getting this working would be appreciated.
-
This reply was modified 2 years by
wordpressive.
Hello @wordpressive!
You must paste the ‘tdc_style_params’ ‘tdc_start_values’ ‘params’. Otherwise, it will not work properly.
Thank you!
I did paste them. I didnt paste them on the forum because they are thousands of lines. But I copied them exactly in my code and still get this error.
Hello @wordpressive!
Copy and rename the file for Flex Block 4 into the custom plugin. The error is saying that it is unable to find the class td_flex_block_4_custom.
Thank you!