<?php
get_header();
global $post;
$page_builder = @get_post_meta($post->ID, THEMEMAKERS_APP_PAGE_BUILDER_PREFIX . "page", true);
?>
<!-- ************ - BEGIN Content Wrapper - ************** -->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <?php
        $page_top = get_post_meta($post->ID, 'page_top', true);
        $page_bottom = get_post_meta($post->ID, 'page_bottom', true);

        if (!empty($page_top)) {
            echo '<div class="gray-holder">' . do_shortcode(html_entity_decode($page_top)) . '<div class="clear"></div></div>';
        }
        ?>
        <div class="content-wrapper">
            <?php the_content(); ?>
            <div class="clear"></div>

            <?php if (!empty($page_builder)): ?>
                <ul id="page_builder_page">
                    <?php if (!empty($page_builder)): ?>
                        <?php foreach ($page_builder as $row_key => $row) : ?>

                            <li>
                                <div row-id="<?php echo $row_key ?>" class="page_builder_row">                                   
                                    <?php if (!empty($row)): ?>
                                        <ul class="page_builder_row_ul">
                                            <?php foreach ($row['columns'] as $col_key => $col) : ?>
                                            <li class="columns <?php echo ThemeMakersHelper::convert_css_class_name(count($row['columns'])) ?>" style="width: <?php echo (100 / count($row['columns'])) ?>%;" column-range="<?php echo count($row['columns']) ?>">
                                                    <div col-id="<?php echo $col_key ?>" class="page_builder_column page_builder_column1">                                                        
                                                        <div class="column_content_area" col-id="<?php echo $col_key ?>" id="column_content_area_<?php echo $col_key ?>">
                                                            <ul>
                                                                <?php if (!empty($col)): ?>
                                                                    <?php foreach ($col as $column_shortcode_key => $column_shortcode_item) : ?>
                                                                        <li>
                                                                            <?php echo do_shortcode($column_shortcode_item['value']) ?>
                                                                        </li>
                                                                    <?php endforeach; ?>
                                                                <?php endif; ?>
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </li>
                                            <?php endforeach; ?>
                                        </ul>
                                        <div class="clear"></div>
                                    <?php endif; ?>
                                </div>
                                <div class="clear"></div>
                            </li>


                        <?php endforeach; ?>
                    <?php endif; ?>
                </ul>
            <?php endif; ?>

        </div>
        <?php
        if (!empty($page_bottom)) {
            echo '<div class="box"><div class="content-wrapper">' . do_shortcode(html_entity_decode($page_bottom)) . '<div class="clear"></div></div></div>';
        }
        ?>
    <?php
    endwhile;
endif;
?>
<?php get_footer(); ?>


