I searched everywhere for a solution and can't mange to work it out.
I want to control the border bottoms length for td elements in a table.
I put two screenshots.
Any help? thank you!
This is the current result :
This is what it should look like:
edit:
This is the code (it's woocommerce order page)
<tr class="order">
<td class="order-number" data-title="<?php _e( 'Order Number', 'woocommerce' ); ?>">
<a href="<?php echo esc_url( $order->get_view_order_url() ); ?>">
#<?php echo $order->get_order_number(); ?>
</a>
</td>
<td class="order-date" data-title="<?php _e( 'Date', 'woocommerce' ); ?>">
<time datetime="<?php echo date( 'Y-m-d', strtotime( $order->order_date ) ); ?>" title="<?php echo esc_attr( strtotime( $order->order_date ) ); ?>"><?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->order_date ) ); ?></time>
</td>
<td class="order-status" data-title="<?php _e( 'Status', 'woocommerce' ); ?>" style="text-align:left; white-space:nowrap;">
<span><?php echo wc_get_order_status_name( $order->get_status() ); ?></span>
</td>
<td class="order-total" data-title="<?php _e( 'Total', 'woocommerce' ); ?>">
<span><?php echo sprintf( _n( '%s for %s item', '%s for %s items', $item_count, 'woocommerce' ), $order->get_formatted_order_total(), $item_count ); ?></span>
</td>
<td class="order-actions">
<?php
$actions = array();
if ( in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'failed' ), $order ) ) ) {
$actions['pay'] = array(
'url' => $order->get_checkout_payment_url(),
'name' => __( 'Pay', 'woocommerce' )
);
}
if ( in_array( $order->get_status(), apply_filters( 'woocommerce_valid_order_statuses_for_cancel', array( 'pending', 'failed' ), $order ) ) ) {
$actions['cancel'] = array(
'url' => $order->get_cancel_order_url( wc_get_page_permalink( 'myaccount' ) ),
'name' => __( 'Cancel', 'woocommerce' )
);
}
$actions['view'] = array(
'url' => $order->get_view_order_url(),
'name' => __( 'View', 'woocommerce' )
);
$actions = apply_filters( 'woocommerce_my_account_my_orders_actions', $actions, $order );
if ( $actions ) {
foreach ( $actions as $key => $action ) {
echo '' . esc_html( $action['name'] ) . '';
}
}
?>
</td>
</tr>
Add border botted for "td" as dotted .
border-bottom:1px dotted #000;
Please add the below code.
border-collapse: separate;
border-bottom:1px dotted color;
You can't control the border length of any element...
Instead, you can control the width of the element itself and then apply the property border-bottom.
Now if you need that the element doesn't have full available width... you can make use of margin alongside width display (because we are talking about tables)
Ex.
td {
margin: 10px; <-- to separete the cell from the border
display: inline-block; <-- replace the default "table-cell"
border-bottom: 1px dotted #999; <-- the dotted border
}
See example: http://jsfiddle.net/gmolop/jn846ypv/
Related
I tried the code below to show posts in a grid , in side by side manner. but , as shown in the image divs appear broken.
<?php
$args = array( 'posts_per_page' => 15, 'offset'=> 1, 'category' => '' );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<div class="container" style="width:960px;margin :opx auo;">
<div class="colk" style="width:200px;height:150px;border-style:dotted;border-width:thin;display:inline-block;
float:left;clear:top;margin: 5px 20px 15px 0px;margin:10px;margin-top:0px;clear:top;" >
<?php the_title(); echo '<br>' ?>
</div>
</div>
<?php echo '<br>'; ?>
<?php endforeach; ?>
<?php
wp_reset_postdata(); ?>
How can i show the divs inline?
<?php
$args = array( 'posts_per_page' => 15, 'offset'=> 1, 'category' => '' );
$myposts = get_posts( $args );?>
<div class="container" style="width:960px;margin :0 auto;">
<?php foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<div class="colk" style="width:200px;height:150px;border-tyle:dotted;border-width:thin;display:inline-block;float:left;clear:top;margin: 5px 20px 15px 0px;margin:10px;margin-top:0px;clear:top;" >
<?php the_title();?>
</div>
<?php endforeach; ?>
</div>
I am attempting to create some custom widgets.
I have created one, which only needed a different title field. However I am now stuck when trying to create a widget which allows me to have multiple fields. I need the following fields for the widget:
Title
Introduction text
Main text
Email address
I want the widget form to allow the user to update the fields above with text. I then want to output the text they have written in my sidebar widget.
I have the following code which is for the previous widget I made (with no extra fields other than title)
class registercv_widget extends WP_Widget {
function __construct() {
parent::__construct(
'registercv_widget',
__('Register CV Widget', 'registercv_widget_domain'),
array( 'description' => __( 'Provides a "Register CV" button which launches a pop-up', 'registercv_widget_domain' ), )
);
}
public function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance['title'] );
echo $args['before_widget'];
echo '<div class="widget-wrapper">';
if ( ! empty( $title ) )
echo $args['before_title'] . $title . $args['after_title'];
// This is where you run the code and display the output
echo __( '<div class="register-button"><span><div class="button white">Send your CV</div></span></div>', 'registercv_widget_domain' );
echo '</div>';
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'Register as a candidate', 'registercv_widget_domain' );
}
// Widget admin form
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
function registercv_load_widget() {
register_widget( 'registercv_widget' );
}
add_action( 'widgets_init', 'registercv_load_widget' );
This works fine but how can I add extra fields to this?
I have attempted copying all instances of $title and making them again but with $text_one but I do not understand how this field is being registered. Can anybody help?
Found the solution.
I started with the code above and was able to create multiple fields as such:
echo $args['before_widget'];
echo '<div class="widget-wrapper">';
if ( ! empty( $title ) )
echo $args['before_title'] . $title . $args['after_title'];
if ( ! empty( $text_two ) )
echo '<p>' . $text_two . '</p>';
if ( ! empty( $link_text ) )
echo '<p>' . $link_text . '<i class="fa fa-play"></i></p>';
echo '</div>';
echo $args['after_widget'];
The above example makes use of $text_two and $link_text variables which can be set through the widget screen with use of the following:
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'Executive Search', 'executive_widget_domain' );
}
if ( isset( $instance[ 'text_two' ] ) ) {
$text_two = $instance[ 'text_two' ];
}
else {
$text_two = __( 'Systematic searching to map the right talent for Director level roles using the best possible sector intelligence.', 'executive_widget_domain' );
}
if ( isset( $instance[ 'link_text' ] ) ) {
$link_text = $instance[ 'link_text' ];
}
else {
$link_text = __( 'Visit Executive Search', 'executive_widget_domain' );
}
// Widget admin form
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
<br /><br />
<label for="<?php echo $this->get_field_id( 'text_two' ); ?>"><?php _e( 'Main text:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'text_two' ); ?>" name="<?php echo $this->get_field_name( 'text_two' ); ?>" type="text" value="<?php echo esc_attr( $text_two ); ?>" />
<br /><br />
<label for="<?php echo $this->get_field_id( 'link_text' ); ?>"><?php _e( 'Link text' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'link_text' ); ?>" name="<?php echo $this->get_field_name( 'link_text' ); ?>" type="text" value="<?php echo esc_attr( $link_text ); ?>" />
</p>
<?php
}
Entire code snippet here which can be popped right into your project. http://pastebin.com/X7wXmcds
Placing the above code in your functions.php will give you a widget called Executive Search. It has three fields:title,text_two(a simple text string) andlink text`. So those are the three fields the user can add.
I don't know if I've used the best title for this question but I'm not sure exactly how to phrase it. I've successfully setup a filterable portfolio script on my site but I need to apply the appropriate class to each item. Right now I've got this.
<?php $loop = new WP_Query( array( 'post_type' => 'productions', 'posts_per_page' => -1 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="tile web all"> <?php the_post_thumbnail ( 'home-page' ); ?>
<h1><?php the_title(); ?></h1>
</div>
<?php endwhile; wp_reset_query(); ?>
The class "web" is just an example, it needs to be replaced by the slug(s) for the categories used for that particular post, as I've setup the filters to automatically show all the categories like this:
<div class="filters">
<p href="" data-rel="all">All</p>
<?php
$args = array(
'type' => 'productions',
'orderby' => 'name',
'order' => 'ASC',
'taxonomy' => 'production_type',
);
$categories = get_categories($args);
foreach($categories as $category) {
echo '<p data-rel="' . $category->slug.'">' . $category->name.'</p> ';
}
?>
Hopefully that is enough info for some help. Thanks.
This worked:
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="tile <?php
$terms = get_the_terms( $post->ID , 'production_type' );
foreach ( $terms as $term ) {
echo $term->slug;
echo ' ';
}
?> all"> <?php the_post_thumbnail ( 'home-page' ); ?>
<h1><?php the_title(); ?></h1>
</div>
<?php endwhile; wp_reset_query(); ?>
I am creating a Wordpress recent posts widget with a bunch of different functions for practice. One of the functions I need it to do was allow the admin to specify one category to display via a drop down menu with the categories on it. I asked for help with this here and got an answer but I am not understanding how to get it to work properly. Here is my code:
<?php
/*
Plugin Name: News Recent Posts Widget
Plugin URI:
Description: A recent post widget with extra functions that allow admin to make changes to certain values
Author: Kevin Ullyott
Version: 1.0
Author URI: http://modmacro.com/
*/
class recentpost extends WP_Widget {
public function __construct() {
parent::WP_Widget(
// or parent::__construct(
false,
'Kevin - Recent Posts Widget',
array(
'description' => __('A recent post widget with extra functions that allow admin to make changes to certain values')
)
);
;
}
public function widget( $args, $instance ) {
extract( $args );
$headline = $instance['headline'];
$category = $instance['category'];
$numberposts = $instance['numberposts'];
$readmore = $instance['readmore'];
echo $before_widget;
echo $before_title;
echo "<p class=\"headline\">$headline</p>";
echo $after_title;
$args = array( 'numberposts' => $numberposts, 'category_name' => $category );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
setup_postdata(get_post($recent['ID']));
echo '<a href="' . get_permalink($recent['ID']) . '" title=" '.esc_attr(get_the_title($recent['ID'])).'" >' . get_the_title($recent['ID']).'</a> ';
echo get_the_time('F j, Y', $recent['ID']);
the_excerpt();
}
wp_reset_postdata();
echo $after_widget;
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['headline'] = ( $new_instance['headline'] );
$instance['category'] = ( $new_instance['category'] );
$instance['numberposts'] = ( $new_instance['numberposts'] );
$instance['readmore'] = ( $new_instance['readmore'] );
return $instance;
}
public function form( $instance ) {
$headline = $instance[ 'headline' ];
$category = $instance[ 'category' ];
$numberposts = $instance[ 'numberposts' ];
$readmore = $instance[ 'readmore' ];
?>
<p>
<label for="<?php echo $this->get_field_id( 'headline' ); ?>">
<?php _e( 'Headline:' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'headline' ); ?>" name="<?php echo $this->get_field_name( 'headline' ); ?>" type="text" value="<?php echo esc_attr( $headline ); ?>" />
</p>
<label for="<?php echo $this->get_field_id( 'category' ); ?>">
<?php _e( 'Category:' ); ?>
</label>
<?php wp_dropdown_categories(array('name' => $this->get_field_name('category'), 'selected' => $category, 'id' => $this->get_field_id('category'), 'class' => 'widefat')); ?>
</p>
<label for="<?php echo $this->get_field_id( 'numberposts' ); ?>">
<?php _e( 'Number of posts:' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'numberposts' ); ?>" name="<?php echo $this->get_field_name( 'numberposts' ); ?>" type="text" value="<?php echo esc_attr( $numberposts ); ?>" />
</p>
<label for="<?php echo $this->get_field_id( 'readmore' ); ?>">
<?php _e( 'Read More:' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'readmore' ); ?>" name="<?php echo $this->get_field_name( 'readmore' ); ?>" type="text" value="<?php echo esc_attr( $readmore ); ?>" />
</p>
<?php
}
}
add_action( 'widgets_init', create_function('', 'return register_widget("recentpost");') );
?>
So if you look down at the form for Category I put in a PHP code there to create the drop down menu. It succesfully creates the form and displays the correct categories within the drop down menu but when I save it does not correctly update and makes the widget display nothing.
The user that gave me this code told me this. He said: "function wp_dropdown_categories will bring in the categories but adding the function alone wont save or retrieve the selected category. You'll need to add the name selected and id arguments." But the problem is I do not know how to add the name, selected, and id arguments. Everything I have tried to do has fail so far. Can some one show me the correct way to do this using my code. It would help a lot. I am very new to this and am trying to learn so please provide what I need to do and if you could explain it.
Sorry to ask so much I just enjoy coding and want to know as much as I can!
wp_dropdown_categories returns the category ID. so, if your form displaying the correct categories and saving, then its working. So youll want to look at your query. It looks like you are currently trying to get categories by category_name.
$args = array( 'numberposts' => $numberposts, 'category_name' => $category );
change that to
`$args = array( 'numberposts' => $numberposts, 'cat' => $category );
Hey guys we have a perfectly working web page (index_admin) of the Relationships controller, but after adding pagination its all crashing.
Coming up with:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'Relationship.sender_id' in 'where clause'
Customers and businesses build 'relationships' so they can exchange invoices over our website. Here is the DB schema:
id, sender_id, receiver_id, active, requested, expiry_date
Sender_id and receiver_id are both foreign keys to the Account Table. So in other words tells the db which accounts are linked to each other.
Relationship model 'BELONGSTO' 'RECEIVER AND SENDER ACCOUNT MODELS':
public $belongsTo = array(
'ReceiverAccount' =>array(
'className' => 'Account',
'foreignKey' =>'receiver_id',
'associationForeignKey' => 'accounts_id',
),
'SenderAccount' =>array(
'className' => 'Account',
'foreignKey' =>'sender_id',
'associationForeignKey' => 'accounts_id',)
);
Index_admin:
public function index_admin(){
$this->set('title_for_layout', 'Relationships');
$this->set('stylesheet_used', 'homestyle');
$this->set('image_used', 'eBOXLogoHome.png');
$this->layout='home_layout';
//retrieve Account Id of current User
$accountid=$this->Auth->user('account_id');
//Conditions
$conditions=array(
"OR"=> array(
'Relationship.sender_id' => $accountid,
'Relationship.receiver_id' => $accountid)
);
//Find all Invoices where receiver_id = accountid
$relationships=$this->Relationship->find('all', array(
'conditions' => $conditions));
debug($conditions);
$compName = $this->Account->field('account_name', array('id' => 'Relationship.id'));
$this->paginate = array(
'limit' => 10,
'conditions'=> $conditions
);
$this->set('accountid', $accountid);
$this->set('relationship', $this->paginate());
$this->set('compName', $compName);
}
Index_admin view (partial):
<table id="data">
<tr>
<td colspan=7 align='right'>
<?php
echo $this->Paginator->prev('<' . __('previous'), array(), null, array('class'=>'prev disabled'));
echo ' ';
echo $this->Paginator->numbers(array('seperator'=>''));
echo ' ';
echo $this->Paginator->next(__('next') . '>', array(), null, array('class'=>'next disabled'));
?>
</td>
</tr>
<tr>
<th><?php echo $this->Paginator->sort('id'); ?></th>
<th><?php echo $this->Paginator->sort('sender_id'); ?></th>
<th><?php echo $this->Paginator->sort('receiver_id'); ?></th>
<th><?php echo $this->Paginator->sort('expiry_date'); ?></th>
<th>Status</th>
<th>Actions</th>
</tr>
<?php foreach($relationship as $relationships):?>
<?php
if($relationships['Relationship']['requested']==1)
{
$status = 'Requested';
$bgcol = '#F8FAC0';
}
else if($relationships['Relationship']['active']==1)
{
$status = 'Active';
$bgcol = '#CFDAE8';
}
else if($relationships['Relationship']['active']==0)
{
$status = 'Expired';
$bgcol = '#FAB9B9';
}
if($relationships['Relationship']['active']==0 && $relationships['Relationship']['requested']==0)
{
$action = 'Reactivate';
}
else
{
$action = 'Edit Expiry';
}
if($relationships['Relationship']['sender_id']==$accountid)
{
$start = '<font color="#191970">';
$end = '</font>';
}
else
{
$start = NULL;
$end = NULL;
}
if($relationships['Relationship']['receiver_id']==$accountid)
{
$startr = '<font color="#191970">';
$endr = '</font>';
}
else
{
$startr = NULL;
$endr = NULL;
}
if($relationships['Relationship']['sender_id']==$accountid)
{
$acctname = $relationships['ReceiverAccount']['account_name'];
}
else if($relationships['Relationship']['receiver_id']==$accountid)
{
$acctname = $relationships['SenderAccount']['account_name'];
}
?>
<tr>
<td align='center'><?php echo $relationships['Relationship']['id']; ?></td>
<td align='center'><?php echo $start?><?php echo $relationships['SenderAccount']['account_name']; ?><?php echo $end ?></td>
<td align='center'><?php echo $startr?><?php echo $relationships['ReceiverAccount']['account_name']; ?><?php echo $endr ?></td>
<td align='center'><?php echo date('d.m.Y', strtotime($relationships['Relationship']['expiry_date'])); ?></td>
<td align='center' bgcolor='<?php echo $bgcol ?>'><?php echo $status ?></td>
<td align='center'>
<?php echo $this->Form->Html->link('Delete', array('controller' => 'Relationships','action'=>'delete',$relationships['Relationship']['id']), NULL, 'Are you sure you want to delete '. $acctname);
?> | <?php echo $action ?> </td>
</tr>
<?php endforeach; ?>
<tr>
<td colspan=7 align='right'>
<?php
echo $this->Paginator->prev('<' . __('previous'), array(), null, array('class'=>'prev disabled'));
echo ' ';
echo $this->Paginator->numbers(array('seperator'=>''));
echo ' ';
echo $this->Paginator->next(__('next') . '>', array(), null, array('class'=>'next disabled'));
?>
</td>
</tr>
</table>
Like I said it was all working before hand, now it isn't, but I can't see why.
It is always wise to set the debug mode on to see all possible errors in detail. You've just shared the sql error part from which it is clear that the intended table doesn't have the "sender_id" field. I'm assuming you've debug mode on. So first have a look at the generated query. Then you'll find which table the query is trying to dig in.
If your query is referencing the correct table, you can try this:
public function index_admin(){
$this->set('title_for_layout', 'Relationships');
$this->set('stylesheet_used', 'homestyle');
$this->set('image_used', 'eBOXLogoHome.png');
$this->layout='home_layout';
//retrieve Account Id of current User
$accountid=$this->Auth->user('account_id');
//Conditions
$conditions=array(
"OR"=> array(
'Relationship.sender_id' => $accountid,
'Relationship.receiver_id' => $accountid)
);
App::import('Model', 'Relationship');
$objRelationship = new Relationship();
$this->paginate = array( "conditions" => $conditions, 'limit' => 10 );
$relationships = $this->paginate( $objRelationship );
$compName = $this->Account->field('account_name', array('id' => 'Relationship.id'));
$this->set('accountid', $accountid);
$this->set('relationship', $this->paginate());
$this->set('compName', $compName);
}