Content disappear from templates after upgrade to 2.0
-
Hello!
I’ve been using CF for a while on several projecs and it’s been great. I just updated to V2 so we could use the radio image field and make editing easier for our customers and the php output on my template files disapeared. I can still view / edit / add fields on the edit page, but nothing shows on the template pages since the update.
I’m using the following structure to create the fields:
$panel_labels = array('plural_name' => 'Panels', 'singular_name' => 'Panel',); $section_labels = array('plural_name' => 'Sections', 'singular_name' => 'Section',); $column_labels = array('plural_name' => 'Columns', 'singular_name' => 'Column',); Container::make('post_meta', 'Panels') ->show_on_post_type('page') ->show_on_template('template_void.php') ->add_fields(array( Field::make('complex', 'panel')->setup_labels($panel_labels)->add_fields(array( Field::make("select", "panel-width", "Panel Width")->add_options(array('full-width' => 'Full Width','site-width' => 'Site Width',)) , Field::make("image", "panel-bg", "Background Image - Optional")->set_value_type('url'), Field::make('complex', 'section')->setup_labels($section_labels)->add_fields(array( Field::make('complex', 'column')->setup_labels($column_labels)->add_fields(array( Field::make("select", "column-width", "Column Width") ->add_options(array( '99' => 'Full', '49' => '1/2', '32' => '1/3', ))->set_width( 20 ), Field::make("rich_text", "column-content", "Column Content")->set_width( 80 ), )), )), )), ));
This is the code used to display the fields on the template pages:
<?php $panels = carbon_get_post_meta( get_the_ID(), 'panel', 'complex' ); ?> <?php if ( ! empty( $panels ) ): ?><?php foreach ( $panels as $panel ): ?> <div class="<?php echo $panel['panel-width']; ?>" style="background-image:url('<?php echo $panel['panel-bg']; ?>');background-size:cover;"> <?php if ( ! empty( $panel['section'] ) ): ?><?php foreach ( $panel['section'] as $row ): ?> <div class="section"> <?php if ( ! empty( $row['column'] ) ): ?><?php foreach ( $row['column'] as $column ): ?> <div class="column" style="width:<?php echo $column['column-width']; ?>%;"> <?php $shortcode = $column['column-content']; echo do_shortcode($shortcode); ?> </div> <?php endforeach ?><?php endif ?> <div class="clear"></div> </div> <?php endforeach ?><?php endif ?> </div> <?php endforeach ?><?php endif ?>
Can you point me in the right direction on how to update my code to use with v2?
Thank you!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Content disappear from templates after upgrade to 2.0’ is closed to new replies.