<?php get_header(); ?>

<div class="row">
	<div class="content <?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>col-sm-8 col-md-9<?php else : ?>col-sm-12<?php endif; ?>">
        <?php dynamic_sidebar( 'sidebar-content-top' ); ?>

        <?php $as_grid = get_theme_mod( 'realia_general_show_property_archive_as_grid', false ); ?>
        
        <?php if ( have_posts() ) : ?>
            <h1 class="page-header"><?php echo __( 'Properties', 'realia' ); ?></h1>

            <?php include Realia_Template_Loader::locate( 'misc/sort-options' ); ?>

            <?php if ( $as_grid ) : ?>
                <div class="row">
            <?php endif; ?>

            <?php while ( have_posts() ) : the_post(); ?>
                <?php if ( $as_grid ) : ?>
                    <div class="col-sm-6 col-md-4">
                        <?php get_template_part( 'templates/properties/box-simple' ); ?>
                    </div>
                <?php else: ?>
                    <?php get_template_part( 'templates/properties/row' ); ?>
                <?php endif; ?>
            <?php endwhile; ?>

            <?php if ( $as_grid ) : ?>
                </div><!-- /.row -->
            <?php endif; ?>

            <?php aviators_pagination(); ?>
        <?php else : ?>
            <?php get_template_part( 'templates/content-not-found' ); ?>
        <?php endif; ?>	

        <?php dynamic_sidebar( 'sidebar-content-bottom' ); ?>
	</div><!-- /.content -->

	<?php get_sidebar(); ?>
</div><!-- /.row -->
<?php get_footer(); ?>