Yii2 two DetailView side by side - yii2

I'm making a purchase order system that exports the PO to PDF, but I need in the upper part to display data from buyer and also from seller.
I would like to have 2 DetailViews side by side, each one with a 50% of page width.
It is possible? So far I've not found any info regarding this and my CSS skills are low.
Thanks for any info.

You can unse bootstrap grid
In view you can palce the detailView in two separated bootstrap column
<div class="col-sm-6 col-md-6 col-lg-6" >
<?= DetailView::widget([
'model' => $modelBuyer,
......
?>
</div>
<div class="col-sm-6 col-md-6 col-lg-6" >
<?= DetailView::widget([
'model' => $modelSeller,
......
?>
</div>
in controller simply pass the two models in render
return $this->render('your_view', [
'modelBuyer' => $modelBuyer,
'modelSeller' => $modelSeller,
]);

I am using the kartik mpdf wrapper of mpdf. I noticed the kv-mpdf-bootstrap.min.css did not define "col-sm-6" as 50% the way it is in bootstrap.css. Since the documentation suggests that the mpdf css overides bootstrap I found the class "col-xs-5" which specifies 41.6666% which was suitable for my output requirements and allowed me to display two detailviews next to each other.
<form class="form-inline">
<div class="form-group">
<div class="col-xs-5">
<p><b>Bill To</b></p>
<div style="border: 1px solid grey; padding-left: 10px; padding-right: 10px; padding-top: 5px; padding-bottom: 5px; width:200px">
<?= DetailView::widget([
'model' => $model,
'bootstrap' => false,
//'condensed'=>true,
//'striped' => false,
//'bordered' => true,
'labelColOptions' => ['hidden' => true],
'attributes' => [
'company',
'billStreetAddress',
[
'attribute' => 'billStreetAddress2',
'visible' => (!empty($model->billStreetAddress2)),
],
'billCity',
'billPostalcode'
]
])
?>
</div>
</div>
<div class="col-xs-5" >
<p><b>Ship To</b></p>
<div style="border: 1px solid grey; padding-left: 10px; padding-right: 10px; padding-top: 5px; padding-bottom: 5px; width:200px">
<?= DetailView::widget([
'model' => $model,
'bootstrap' => false,
'labelColOptions' => ['hidden' => true],
'attributes' => [
'company',
'shipStreetAddress',
[
'attribute' => 'shipStreetAddress2',
'visible' => (!empty($model->billStreetAddress2)),
],
'shipCity',
'shipPostalcode'
]
])
?>
</div>
</div>
</div>

Related

Start new table row every 3 cells

I am using ACF to fetch yacht listings (custom post types) which are then output in a table.
I could try and lay these out as Divs but this particular design means it is much easier as a table (there are borders in between and fluctuating heights which I would like to display of equal height).
The problem is, as these are populated dynamically, I am unable to lay the table out in html and thus, can't find a way to only have 3 cells wide per table row.
Is there a way to have a new row automatically start every 3 cells? Furthermore, is there a way to alter this based on screen width.
Currently the posts are not set in a table in the HTML but in the CSS, but I have tried both.
My code is:
<div class="the-latest-listings">
<div class="listings-table-row">
<?php
$args = array(
'post_type' => 'yachts',
'posts_per_page' => 9,
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'sale_or_charter',
'value' => 'sale',
)
),
);
$my_posts = new WP_Query($args);
if ( $my_posts->have_posts() ) {
while ( $my_posts->have_posts() ) : $my_posts->the_post();
?>
<div class='latest-yacht-wrapper'>
<div class="single-latest-yacht-container">
<div class="latest-yacht-image">
<?php
$image = get_field( "preview_yacht_image", get_the_ID() );?>
<a href="<?php the_permalink(); ?>">
<img src="<?php echo esc_url($image['url']); ?>" title="<?php echo esc_attr($image['title']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
</a>
</div>
<div class="latest-yacht-blue-container">
<div class="sale-status-tab">
<p><?php echo the_field( "sale_or_charter", get_the_ID() );?></p>
</div>
<h4><?php the_title(); ?></h4>
<div class="teaser-details">
<?php if( get_field('price', get_the_ID() ) ){ ?>
<p class="latest-price">EUR <?php echo get_field( "price", get_the_ID() );?></p>
<p class="divider">|</p>
<?php }; ?>
</div>
</div>
</div>
</div>
<div class="yacht-spacer">
<div class="vertical-line"></div>
</div>
<?php
endwhile;
wp_reset_postdata();
}
?>
</div>
</div>
And the CSS that is think is relevant to the question
#page .the-latest-listings {
border-top: 1.3px solid rgba(28,34,64,.3);
border-bottom: 1.3px solid rgba(28,34,64,.3);
margin-top: 60px;
display: table;
width: 100%;
table-layout: fixed;
}
.listings-table-row {
display: table-row;
}
.latest-yacht-wrapper {
display: table-cell;
}
.single-latest-yacht-container {
padding: 78px 0;
}
.yacht-spacer {
width: 50px;
display: table-cell;
position: relative;
}
I tried setting the .latest-yacht-wrapper to 33% width but it doesn't work. I also tried these:
while($('.the-latest-listings ').find('tr:last').children(':gt(2)').length > 0){
$('.the-latest-listings ').find('tr:last').after(
$('.the-latest-listings ').find('tr:last').children(':gt(2)')
.wrapAll('<tr></tr>').parent().remove()
);
}
AND
while($('.the-latest-listings').find('tr:last').children(':gt(2)').length > 0){
var newRow = '';
$('.the-latest-listings').find('tr:last').children(':gt(2)').each(function(i,e){
newRow += $(e).prop('outerHTML');
}).remove();
$('.the-latest-listings').find('tr:last').after('<tr>' + newRow + '</tr>');
}
I also tried switching to a table layout in the html like so:
<table class="the-latest-listings">
<tr class="listings-table-row">
<?php
$args = array(
'post_type' => 'yachts',
'posts_per_page' => 9,
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'sale_or_charter',
'value' => 'sale',
)
),
);
$my_posts = new WP_Query($args);
if ( $my_posts->have_posts() ) {
while ( $my_posts->have_posts() ) : $my_posts->the_post();
?>
<td class='latest-yacht-wrapper'>
<div class="single-latest-yacht-container">
<div class="latest-yacht-image">
<?php
$image = get_field( "preview_yacht_image", get_the_ID() );?>
<a href="<?php the_permalink(); ?>">
<img src="<?php echo esc_url($image['url']); ?>" title="<?php echo esc_attr($image['title']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
</a>
</div>
<div class="latest-yacht-blue-container">
<div class="sale-status-tab">
<p><?php echo the_field( "sale_or_charter", get_the_ID() );?></p>
</div>
<h4><?php the_title(); ?></h4>
<div class="teaser-details">
<?php if( get_field('price', get_the_ID() ) ){ ?>
<p class="latest-price">EUR <?php echo get_field( "price", get_the_ID() );?></p>
<p class="divider">|</p>
<?php }; ?>
</div>
</div>
</div>
</td>
<td class="yacht-spacer">
<div class="vertical-line"></div>
</td>
<?php
endwhile;
wp_reset_postdata();
}
?>
</tr>
</table>
And then this:
var $td = $(".listings-table-row td");
$td.each(function(i){
if (i % 3 == 0) {
$td.slice(i, i+3).wrapAll('<tr/>')
}
}).parent('tr').unwrap();
But again, no luck.
As I am writing this, I realise accounting for the spacers will mean it's not 3 TD's across but I can't get any to work regardless of what numbers I enter.
One of the following techniques could fit the bill:
https://youtu.be/qm0IfG1GyZU?t=711
https://youtu.be/qm0IfG1GyZU?t=184
RAM (Repeat, Auto, Minmax)
.ex7 .parent {
display: grid;
grid-gap: 1rem;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
<div class="parent white">
<div class="box pink">1</div>
<div class="box purple">2</div>
<div class="box blue">3</div>
<div class="box green">4</div>
</div>
The Deconstructed Pancake
.ex2 .parent {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.ex2 .box {
flex: 1 1 150px;
/* Stretching: */
flex: 0 1 150px;
/* No stretching: */
margin: 5px;
}
<div class="parent white">
<div class="box green">1</div>
<div class="box green">2</div>
<div class="box green">3</div>
</div>
(source https://1linelayouts.glitch.me/)

Element disappears on certain dimensions

I have this website and my problem is with the language switcher on top.
As you can see from the screenshots, when  the width is between 768 - 990 px the top bar disappears.
With top bar at 1175px x 621px
Without top bar at 896px x 489px
I have tried many css tricks that i found online, like
-webkit-transform: translate3d(0, 0, 0);
but i still have the same result
The HTML code is the menu from the website. I think the problem is being created by the class="style2"
P.S. At line 6315 of the css you can see the
#media (min-width: 768px) {...}
but i can't figure if something contributes to my problem.
<?php if((get_theme_mod('andaman_top_contact') || get_theme_mod('andaman_menu_soc')) == true) { ?>
<div class="header style2">
<div class="top_bar">
<div class="container">
<div class="row">
<div class="col-lg-10 col-md-9 col-sm-12 col-xs-12">
<?php if(get_theme_mod('andaman_top_contact') == true) { ?>
<ul class="contacts-top">
<?php if(get_theme_mod('andaman_top_contact_address', 'enable') == true) { ?><li><?php echo esc_attr(get_theme_mod('andaman_top_contact_address', '455 Martinson, Los Angeles')); ?></li><?php }; ?>
<?php if(get_theme_mod('andaman_top_contact_phone', 'enable') == true) { ?><li><?php echo esc_attr(get_theme_mod('andaman_top_contact_phone', '+1 (043) 567-8930')); ?></li><?php }; ?>
<?php if(get_theme_mod('andaman_top_contact_hours', 'enable') == true) { ?><li><?php echo esc_attr(get_theme_mod('andaman_top_contact_hours', 'Mon-Sut: 10 AM-8 PM')); ?></li><?php }; ?>
</ul>
<?php }; ?>
</div>
<div class="col-lg-2 col-md-3 col-sm-12 col-xs-12">
<ul class="soc-top">
<?php if ( is_plugin_active( 'polylang/polylang.php' )) { ?>
<li class="lang"><span><img src="<?php echo get_stylesheet_directory_uri(). '/assets/images/lang-' . pll_current_language('slug') . '.png'; ?>" width="24" height="24" alt=""> <?php echo pll_current_language('name'); ?></span>
<ul class="lang-ul">
<?php $languages = pll_the_languages( array('raw'=> true, 'hide_if_no_translation'=>true, 'hide_current'=>true) );
foreach ($languages as $language ) {
echo '<li><img src="'.get_stylesheet_directory_uri(). '/assets/images/lang-'.$language['slug'].'.png" width="24" height="24" alt="'.$language['slug'].'">' .$language['name'].'</li>'; }; ?>
</ul>
</li>
<?php }; ?>
</ul>
</div>
</div>
</div>
</div>
<?php } else { ?>
<div class="header style2 no-bar">
<?php };?>
<div class="sticky-menu">
<div class="container">
<div class="menu-flex">
<div class="logo">
<a href="<?php echo esc_url(home_url('/')); ?>" title="<?php bloginfo( 'name' ); ?>" rel="home">
<?php if(get_theme_mod('andaman_logo_upload', 'enable') == true) { ?>
<img src="<?php echo esc_url(get_theme_mod('andaman_logo_upload', get_template_directory_uri() . '/assets/images/logo.png')); ?>" alt="<?php the_title_attribute(); ?>" style="height: <?php echo esc_attr(get_theme_mod('andaman_logo_height', '45px')); ?>;">
<?php } else { ?>
<h1 style="margin:0;"><?php echo the_title(); ?></h1>
<?php } ?>
</a>
</div>
<?php if(get_theme_mod('andaman_menu_select', 'standard') == 'standard') { ?>
<div class="menu-responsive desktop">
<div class="navbar-main-collapse pull-left responsive-menu">
<?php wp_nav_menu( array(
'theme_location' => 'menu',
'container' => false,
'menu_class' => 'nav navbar-nav',
'sort_column' => 'menu_order',
'walker' => new Andaman_My_Walker_Nav_Menu(),
'fallback_cb' => 'andaman_MenuFallback'
)); ?>
</div>
</div>
<div class="menu-responsive mobile">
<div class="burger_andaman_normal_holder"><span></span><span></span><span></span><span></span><span></span><span></span></div>
<div class="burger_andaman_menu_overlay_normal">
<div class="burger_andaman_menu_vertical">
<?php wp_nav_menu( array(
'theme_location' => 'menu',
'menu_class' => 'burger_andaman_main_menu',
'depth' => 3,
)); ?>
</div>
</div>
</div>
<?php } else { ?>
<div class="menu-responsive desktop">
<div class="navbar-main-collapse pull-left responsive-menu">
<?php wp_nav_menu( array(
'theme_location' => 'onepage-menu',
'container' => false,
'menu_class' => 'nav navbar-nav share-class',
'menu_id' => 'menu-onepage',
'sort_column' => 'menu_order',
'walker' => new Andaman_My_Walker_Nav_Menu(),
'fallback_cb' => 'andaman_MenuFallback'
)); ?>
</div>
</div>
<div class="menu-responsive mobile">
<div class="burger_andaman_normal_holder"><span></span><span></span><span></span><span></span><span></span><span></span></div>
<div class="burger_andaman_menu_overlay_normal">
<div class="burger_andaman_menu_vertical">
<?php wp_nav_menu( array(
'theme_location' => 'onepage-menu',
'menu_class' => 'burger_andaman_main_menu share-class',
'menu_id' => 'menu-onepage',
'depth' => 1,
)); ?>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
This is happening because one of your stylesheet hiding the li.lang between mentioned width, I have provided you CSS, you can paste it inside the stylesheet.
#media screen and (max-width:990px){
li.search, li.lang {
display: block !important;
}
}
Screenshot of your CSS: (You have to change display: none to display: block)
Thank you #Gamers Agenda for your quick and accurate answer.
The changes I made with your help:
#media screen and (max-width:990px){
.soc-top {
float: right;
margin-right: 30px;
}
li.search, li.lang {
display: block !important;
}
}
This will do:
Your style:
#media (max-width: 767px)
.header.style2 .soc-top {
float: none !important;
text-align: center;
}
remove float: none !important; and be like:
#media (max-width: 767px)
.header.style2 .soc-top {
text-align: center;
}

Drop Down Navs not working with Bootstrap & Wordpress

I'm using bootstrap to create my page templates for a wordpress site but I am having trouble getting my dropdown nav to work when I add a child in the wordpress menu screen.
Here is my header code...
<body id="grad1">
<div class="mynavbar">
<div class="row">
<div class="col-md-3 col-sm-3 col-xs-1">
<img src="/wp-content/uploads/2015/07/logo_80px.png" class=" center-block space" alt="Enter OmniMark here"/>
</div>
<div class="col-md-6 col-sm-6 col-xs-0">
</div>
<div class="col-md-3 col-sm-3 col-xs-1">
<img src="/wp-content/uploads/2015/07/OMsemicircle.png" class=" center-block space" alt="Enter OmniMark here"/>
</div>
</div>
</div>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="row">
<div class="container-fluid" id="fontfix">
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="center-block">
<div class="collapse navbar-collapse column " id="navbar-collapse-2">
<ul class="nav navbar-nav">
<!--<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Works</li>
<li>News</li>
<li>Contact</li>-->
<?php /* Primary navigation */
wp_nav_menu( array(
'menu' => 'menu 1',
'depth' => 0,
'container' => false,
'container_class' => 'collapse navbar-collapse column',
'container_id' => 'navbar-collapse-2',
'menu_class' => 'nav navbar-nav',
//Process nav menu using our custom nav walker
'walker' => new wp_bootstrap_navwalker())
);
?>
<!--Used to list nav and exclude pages-->
<!--<?php wp_list_pages(array('title_li' => '', 'exclude' => '615, 14',)); ?>-->
<li>Store</li>
</ul>
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="module top widewrapper center-block">
<h1><span class="fontgreen">Thin Film</span><span class="fontblue"> Product Markings</span></h1>
<p class="darktext">The world is full of products and brands whose image gets lost in the white noise of modern society. The Lauterbach Group protects your brand’s unique and inspiring image with film product markings. Thin film product markings provide exceptional decoration options, increased production efficiencies and supply chain savings with an environmental focus.</p>
<!--<img class="center-block" src="/wp-content/uploads/2015/07/homepage_800.png" alt="" />-->
</div>
<div class="container mainbump">
I can also provide the functions code if that will help...
<?php
//trying to register menu
/* Theme setup */
add_action( 'after_setup_theme', 'wpt_setup' );
if ( ! function_exists( 'wpt_setup' ) ):
function wpt_setup() {
register_nav_menu( 'primary', __( 'Primary navigation', 'wptuts' ) );
} endif;
// Register custom navigation walker
require_once('wp_bootstrap_navwalker.php');
//menu registery
function wpbootstrap_scripts_with_jquery()
{
// Register the script like this for a theme:
wp_register_script( 'custom-script', get_template_directory_uri() . '/bootstrap/js/bootstrap.js', array( 'jquery' ) );
wp_register_script( 'custom-script', get_template_directory_uri() . '/bootstrap/js/bootstrap.min.js', array( 'jquery' ) );
wp_register_script( 'custom-script', get_template_directory_uri() . 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js', array( 'jquery' ) );
// For either a plugin or a theme, you can then enqueue the script:
wp_enqueue_script( 'custom-script' );
}
add_action( 'wp_enqueue_scripts', 'wpbootstrap_scripts_with_jquery' );
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'sidebar',
'id' => 'sidebar',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => 'footer',
'id' => 'footer',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
register_sidebar(array(
'name' => 'sidebarmenu',
'id' => 'sidebarmenu',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
));
?>
The 'depth' value in the array is 0, you should change it to 2 or 3 if you want more.
Here's my example for the Wordpress wp_bootstraap_navkwalker() function.
<nav class="navbar" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div><!--end navbar-header-->
<div class="collapse navbar-collapse menu-primary" id="bs-example-navbar-collapse-1">
<?php
wp_nav_menu( array(
'menu' => '',
'theme_location' => 'primary',
'depth' => 3,
'container' => '',
'container_class' => 'collapse navbar-collapse',
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker())
);
?>
</div><!--end navbar-colapse-->
</div><!--end container-->
</nav>
Try that and you should be good.

Bootstrap 2 - correct way to centre a div

I am using Bootstrap with the Yii framework - and am trying to centre my login box in the middle of the page, but not having any joy.
My code looks like as follows:
How should I amend this to have the div display bang on in the centre?
A jsfiddle -:
http://jsfiddle.net/7946rak9/1/
<div class="row">
<?php $form = $this->beginWidget('CActiveForm', array(
'id' => get_class($model),
'enableAjaxValidation' => true,
'clientOptions' => array(
'validateOnSubmit' => true,
'validateOnChange' => false,
),
'htmlOptions' => array('class'=>'form-vertical'),
'action' => array('/frontend/user/login')
)); ?>
<div class="span2">
<?php echo $form->labelEx($model,'username'); ?>
</div>
<div class="span10">
<?php echo $form->textField($model,'username', array('class' => '')); ?>
<?php echo $form->error($model, 'username', array('class'=>'errorMessage')); ?>
</div>
</div>
<div class="row">
<div class="span2">
<?php echo $form->labelEx($model,'password'); ?>
</div>
<div class="span10">
<?php echo $form->passwordField($model,'password', array('class' => '')); ?>
<?php echo $form->error($model, 'password', array('class'=>'errorMessage')); ?>
</div>
</div>
<div class="row">
<div class="offset2 span10">
<?php echo $form->checkBox($model,'rememberMe', array('class' => 'pull-left')); ?>
<?php echo $form->labelEx($model,'rememberMe', array('style' => 'padding-left: 20px;')); ?>
<?php echo $form->error($model, 'rememberMe', array('class'=>'errorMessage')); ?>
</div>
</div>
<div class="row">
<div class="offset2 span3">
<?php echo Html::submitButton('Login', array('class' => 'btn')); ?>
</div>
</div>
<?php $this->endWidget();?>
have you tried adding another class "text-center" to the row div?
EDITED:
If you want to use Bootstrap 2's included markup, use the following to offset your div to the middle of the row.
<div class="row-fluid">
<div class="span4">...</div>
<div class="span4 offset3">...</div>
</div>
http://getbootstrap.com/2.3.2/scaffolding.html#fluidGridSystem
Alternative
Or you could wrap all your divs with another div and then use the following markup.
<div class="wrapper">
....all you content divs here
</div>
.wrapper {
margin: 0 auto;
width: 50%;
}
http://jsfiddle.net/7946rak9/2/
Simply use:
margin: 0 auto;
On the div you would like to center
You can simply use text-align: center; on the div you want to centre
<div id="mydiv"></div>
#mydiv {
text-align: center;
}
Should do the trick. Simple Demo
Try defining classes span2 and span 10 with text-align: center; in your CSS if you're using a pre 2.3.0 version of Bootstrap - the .text-center method, suggested by #Wu4D wasn't added until v2.3.

CSS background to wrapper class not working

I am trying to modify the Drupal menu:page.tpl.php
<?php if ($main_menu): ?>
<div id="navigation-wrapper">
<div id="navigation">
<nav id="main-menu" role="navigation" tabindex="-1">
<?php
// This code snippet is hard to modify. We recommend turning off the
// "Main menu" on your sub-theme's settings form, deleting this PHP
// code block, and, instead, using the "Menu block" module.
// #see https://drupal.org/project/menu_block
print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'class' => array('links', 'inline', 'clearfix'),
),
'heading' => array(
'text' => t('Main menu'),
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>
</nav>
<?php print render($page['navigation']); ?>
</div>
</div>
<?php endif; ?>
And the css is:
#navigation-wrapper{
overflow:hidden;
width:100%
background:#ff6005;
}
#navigation{
width:950px;
margin:0 auto;
background:#ff6005;
}
#navigation ul li
{
display:inline;
padding:5px 10px 6px 10px;
}
But my output produces the background color only for the div navigation ! I was expecting a background color covering full width . Whats wrong with my CSS >
#navigation-wrapper{
overflow:hidden;
width:100%;
background:#ff6005;
You missed a ; after width.