Roots Discourse

SOLVED: CMB2 'show_on' with Sage


#1

Hello to everybody,
I need to deal with the correct use of the CMB2 plug-in.

I want to use them only on specific templates (template-homepage.blade.php). But my listing does not work.

$cmb->add_field( array(
	'name'         => esc_html__( 'Multiple Files', 'cmb2' ),
	'desc'         => esc_html__( 'Upload or add multiple images/attachments.', 'cmb2' ),
	'id'           => $prefix . 'file_list',
	'type'         => 'file_list',
    'preview_size' => array( 100, 100 ), // Default: array( 50, 50 )
    'show_on'      => array( 'key' => 'page-template', 'value' => 'template-homepage.blade.php' ),
) );

Can you tell me what is the right listing?


#2

Use views/template-homepage.blade.php.

If you right click the page template drop down when editing a page and select “Inspect element” you’ll see all the available values to use.


#3

working, thanks

'show_on'       => array( 'key' => 'page-template', 'value' => 'views/template-homepage.blade.php' )