From a5366348682f81fad2583dd987d2cd4d75e242cf Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 25 Aug 2015 14:06:31 -0400 Subject: [PATCH] WIP Front end work Group the coupons by category adding style to them --- controllers/front.php | 36 ++++++++++++++++++++++---- css/front/coupons.css | 50 +++++++++++++++++++++++++++++++++++++ models/coupon.php | 2 +- views/admin/coupon_meta.php | 4 +-- views/front/couponList.php | 22 ++++++++++++---- 5 files changed, 101 insertions(+), 13 deletions(-) diff --git a/controllers/front.php b/controllers/front.php index 66ac6ed..0fc7df5 100644 --- a/controllers/front.php +++ b/controllers/front.php @@ -20,6 +20,7 @@ class glm_coupon_front add_shortcode('glmcoupons', array($this, 'glm_coupon_shortcode')); $this->viewDir = $this->pluginDirName . self::FORM_VIEW_DIR; $this->frontViewDir = $this->viewDir . '/front'; + add_action('wp_enqueue_scripts', array($this, 'load_stylesheet')); } public function glm_coupon_shortcode($atts) @@ -45,6 +46,17 @@ class glm_coupon_front // use smarty template to output the form } + public function load_stylesheet() + { + wp_enqueue_style( + 'glm-coupons', + plugins_url('glm-coupons/css/front/coupons.css' , $this->pluginDirName), + array(), + '0.0.1', + 'all' + ); + } + public function list_coupons() { global $wpdb, $wp; @@ -81,9 +93,10 @@ class glm_coupon_front ); } } + $categories = array(); $coupons = get_posts($args); - $totalCoupons = count($coupons); - $iterator = 1; + //$totalCoupons = count($coupons); + //$iterator = 1; foreach ($coupons as $coupon) { $custom = get_post_custom($coupon->ID); $coupon->end = false; @@ -91,10 +104,23 @@ class glm_coupon_front $coupon->glm_coupons_enddate = $custom['glm_coupons_enddate'][0]; $coupon->glm_coupons_expdate = $custom['glm_coupons_expdate'][0]; $coupon->glm_coupons_url = $custom['glm_coupons_url'][0]; - if ($iterator == $totalCoupons) { - $coupon->end = true; + $coupon->glm_coupons_thumb = get_the_post_thumbnail($coupon->ID, 'thumbnail', array('class' => 'aligncenter')); + $post_categories = wp_get_object_terms( + $coupon->ID, + GLM_COUPON_TAX_CATEGORIES, + array('fields' => 'names') + ); + //var_dump($post_categories); + foreach ($post_categories as $category) { + //$cat = get_category($c); + $coupon->categoryName = $category; + $categories[$category][] = $coupon; } - ++$iterator; + + //if ($iterator == $totalCoupons) { + //$coupon->end = true; + //} + //++$iterator; } include $this->frontViewDir . '/couponList.php'; return; diff --git a/css/front/coupons.css b/css/front/coupons.css index e69de29..347c645 100644 --- a/css/front/coupons.css +++ b/css/front/coupons.css @@ -0,0 +1,50 @@ +.coupon-row { + display: block; + width: 100%; +} +.coupon-item { + display: inline-table; + width: 30%; + padding: 0; + margin: 5px; + border: 1px dashed lightgrey; +} +.coupon-item-wrap { + padding: 20px; +} +.coupon-row h2 { + font-size: 1.45rem; +} +.coupon-row h3 { + font-size: 1.3rem; +} +.coupon-expires { + margin: 20px 5px 5px 0; + float: right; + font-size: .8rem; +} +.coupon-descr { + font-size: .9rem; +} +.coupon-url { + float: left; + font-size: .8rem; + margin: 20px 0 5px 5px; +} +.coupon-select { + background-color: lightgrey; + width: 100%; + height: 40px; + padding: 10px; +} + +@media screen and (max-width: 40em) { + .coupon-item { + width: 100%; + } +} +@media screen and (min-width: 40.63em) and (max-width: 64em) { + .coupon-item { + width: 45%; + } +} diff --git a/models/coupon.php b/models/coupon.php index b247167..e432b50 100644 --- a/models/coupon.php +++ b/models/coupon.php @@ -300,7 +300,7 @@ class glm_coupons_coupon 'public' => true, 'can_export' => true, 'menu_position' => 21, - 'supports' => array('title', 'editor'), + 'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'author'), 'has_archive' => true, 'menu_icon' => 'dashicons-products', 'capability_type' => 'post', diff --git a/views/admin/coupon_meta.php b/views/admin/coupon_meta.php index 0392209..b8f51f0 100644 --- a/views/admin/coupon_meta.php +++ b/views/admin/coupon_meta.php @@ -28,8 +28,8 @@
  • - +
  • diff --git a/views/front/couponList.php b/views/front/couponList.php index 47960b8..f4247cc 100644 --- a/views/front/couponList.php +++ b/views/front/couponList.php @@ -1,12 +1,24 @@

    List Coupons

    + $coupons) :?> +

    -
    -

    post_title;?>

    -
    post_content;?>
    -
    Expires: glm_coupons_expdate);?>
    +
    +
    +
    +

    post_title;?>

    + glm_coupons_thumb) : ?> + glm_coupons_thumb;?> + +
    post_content;?>
    + glm_coupons_url) :?> + + +
    Expires: glm_coupons_expdate);?>
    +
    +
    +
    -
    -- 2.17.1