<?php /* Template Name: Visual Composer Page */ ?>
<?php get_header(); ?>
    <?php $images = rwmb_meta('_muziq_jellythemes_slider_images', 'type=image', $post->ID ); ?>
    <?php foreach ($images as $image) : ?>
        <section class="intro intro-mini full-width jIntro bg-blog" style="background-image:url(<?php echo esc_url($image['full_url']); ?>);">
            <div class="container">
                <div class="row">
                    <div class="col-md-12">
                        <div class="text-center">
                            <h1 class="primary-title"><?php the_title() ?></h1>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <?php break; ?>
    <?php endforeach; ?>

    <?php if (function_exists('rwmb_meta')): ?>
        <?php while ( have_posts() ) : the_post(); ?>
            <?php $bg = rwmb_meta( '_muziq_jellythemes_section_bg', 'type=image', get_the_ID() );  foreach ($bg as $bg_image) : $bg_url = $bg_image['full_url']; endforeach; ?>
                <section id="<?php echo esc_attr($post->post_name); ?>" 
                    class="section 
                            <?php echo get_post_meta( $post->ID, '_muziq_jellythemes_section_color', true ); ?> 
                            <?php echo get_post_meta( $post->ID, '_muziq_jellythemes_section_type', true ); ?> 
                            <?php echo get_post_meta( $post->ID, '_muziq_jellythemes_section_width', true ); ?> 
                            <?php echo ($pattern ? 'pattern' : ''); ?>" 
                    <?php echo (!empty($bg_url) ? 'data-parallax-image="' . $bg_url . '"'  : ''); ?> 
                    style="background-color:<?php echo get_post_meta( $post->ID, '_muziq_jellythemes_bg_color', true ); ?>; 
                    <?php echo (!empty($bg_url) ? 'background-image: url(' . $bg_url . ')' : ''); ?>">
                        <div class="container">
                            <?php the_content(); ?> 
                        </div>
                        <?php if (get_post_meta( $post->ID, '_muziq_jellythemes_section_type', true )=='discography'): ?>
                            <div id="project-show"></div>
                            <div class="section player-album project-window">
                                <div class="project-content"></div><!-- AJAX Dinamic Content -->
                            </div>
                        <?php endif ?>
                </section>
            <?php $bg_url=''; ?>
        <?php endwhile; ?>

        <?php $back = $post //backup post data?>
        <?php $child_sections = new WP_Query(array('post_type' => 'page', 'post_parent' => $post->ID, 'orderby' => 'menu_order', 'order' =>'ASC', 'posts_per_page' => -1)); ?>
        <?php while ($child_sections->have_posts() ) : $child_sections->the_post(); ?>
            <?php $bg = rwmb_meta( '_muziq_jellythemes_section_bg', 'type=image', get_the_ID() );   foreach ($bg as $bg_image) : 
                    $bg_url = $bg_image['full_url']; endforeach; ?>
                    <?php $pattern = get_post_meta( $post->ID, '_muziq_jellythemes_pattern', true ); ?>
                <section id="<?php echo esc_attr($post->post_name); ?>" 
                    class="section 
                            <?php echo get_post_meta( $post->ID, '_muziq_jellythemes_section_color', true ); ?> 
                            <?php echo get_post_meta( $post->ID, '_muziq_jellythemes_section_type', true ); ?> 
                            <?php echo get_post_meta( $post->ID, '_muziq_jellythemes_section_width', true ); ?> 
                            <?php echo ($pattern ? 'pattern' : ''); ?>" 
                    <?php echo (!empty($bg_url) ? 'data-parallax-image="' . $bg_url . '"'  : ''); ?> 
                    style="background-color:<?php echo get_post_meta( $post->ID, '_muziq_jellythemes_bg_color', true ); ?>; 
                    <?php echo (!empty($bg_url) ? 'background-image: url(' . $bg_url . ')' : ''); ?>">
                        <div class="container">
                            <?php the_content(); ?> 
                        </div>
                        <?php if (get_post_meta( $post->ID, '_muziq_jellythemes_section_type', true )=='discography'): ?>
                            <div id="project-show"></div>
                            <div class="section <?php echo get_post_meta( $post->ID, '_muziq_jellythemes_section_color', true ); ?> player-album project-window">
                                <div class="project-content"></div><!-- AJAX Dinamic Content -->
                            </div>
                        <?php endif ?>
                </section>
            <?php $bg_url=''; ?>
        <?php endwhile; ?>
        <?php $post = $back //restore post data ?>
    <?php endif ?>    
<?php get_footer(); ?>