效果展示

教程开始

1.将以下css代码复制到ripro-v2主题文件css中


@media (min-width: 1450px){
.ripro_v2-widget-case .container{
    max-width:88%;
}
}
.customer-show {
    padding: 40px 0;
}
.customer-show .home-title {
    margin-bottom: 50px;
    text-align: center;
}
.customer-warp {
    margin-left: -35px!important;
    margin-right: -35px!important;
}
.customer-warp [class*="col-"] {
    padding-right: 35px;
    padding-left: 35px;
}
.customer-warp .item {
    position: relative;
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.15);
    transition: all .3s;
    margin-bottom: 70px;
}
.customer-warp .item:hover {
    transform: translateY(-5px);
}
.customer-warp .item .item-header {
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f6f6f6;
    padding-bottom: 30px;
}

.customer-warp .item .item-header .icon {
    width: 45px;
    height: 45px;
    margin-right:10px;
    position: relative;
    background: #f6f6f6;
    border-radius: 50%;
    overflow: hidden;
}
.customer-warp .item .item-header .icon img {
    max-width: 100%;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
}
.customer-warp .item .item-header .item-user {
    flex: 1;
    overflow: hidden;
}
.customer-warp .item .item-header .item-user b {
    display: block;
    line-height: normal;
    font-size: 15px;
}
.customer-warp .item .item-header .item-user span {
    display: block;
    color: #999;
    font-size: 12px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}
.customer-warp .item .item-desc {
    color: #606266;
    font-size: 14px;
    height: 96px;
    line-height: 24px;
    margin: 30px 0 60px 0;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}
.customer-warp .item .goto {}
.customer-warp .item .goto a {
    display: inline-block;
    border: 2px solid #461cff;
    border-radius: 50px;
    font-size: 15px;
    padding: 5px 15px;
    color: #461cff;
    transition: all .3s;
}
.customer-warp .item:hover .goto a {
    background: #461cff;
    color: #fff;
}
.customer-warp .item .item-bg {
    position: absolute;
    bottom: 0;
    right: 0;
}
@media (max-width: 767px){
    .customer-show {
        padding: 20px;
    }
    .customer-warp .item {
        padding: 15px;
        margin-bottom: 20px;
    }
    .customer-show .home-title {
        margin-bottom: 20px;
    }
    .customer-show .home-title h3 {
        font-size: 24px;
    }
    .customer-warp {
        margin-left: -15px!important;
        margin-right: -15px!important;
    }
    .customer-warp [class*="col-"] {
        padding-right: 15px;
        padding-left: 15px;
    }
    .customer-warp .item .item-header {
        margin-bottom: 15px;
    }
    .customer-warp .item .item-desc {
        display: none;
    }
}
.home-title h3 {
    margin-bottom: 10px;
    font-size: 26px;
    font-weight: normal;
}
.home-title span {
    color: #999;
    font-size: 13px;
}

2.将以下代码添加到ripro-v2/inc/options/widget-options.php底部

<?php
/**
 * 案例展示
 */
CSF::createWidget('ripro_v2_module_case', array(
    'title' => esc_html__('RI-首页模块 : 案例展示', 'ripro-v2'),
    'classname' => 'ripro_v2-widget-case',
    'description' => esc_html__('VAN主题 a 案例展示', 'ripro-v2'),
    'fields' => array(
        array(
            'id' => 'home_mode_case',
            'type' => 'fieldset',
            'title' => '',
            'fields' => array(
                array(
                    'id' => '_title',
                    'type' => 'text',
                    'title' => '标题',
                    'default' => '案例展示',
                ),
                array(
                    'id' => '_describe',
                    'type' => 'text',
                    'title' => '简介',
                    'default' => '优质客户网站案例展示',
                ),

                array(
                    'id' => 'casecms',
                    'type' => 'group',
                    'title' => '新建案例展示(至多4个)',
                    'max' => 4,
                    'fields' => array(
                        array(
                            'id' => 'case_title',
                            'type' => 'text',
                            'title' => '网站标题',
                            'default' => '源分享',
                        ),
                        array(
                            'id' => 'case_href',
                            'type' => 'text',
                            'title' => '网站地址',
                            'default' => 'https://www.yfxw.cn/',
                            'desc' => '记得填写完整地址哟!!!示例:https://www.yfxw.cn/',
                        ),
                        array(
                            'id' => 'case_describe',
                            'type' => 'textarea',
                            'title' => '网站描述',
                            'default' => '源分享是一个优质程序聚集地,不定期更新原创资源分享给大家,用心制作建站教程和源码评测,为更多的个人站长推荐有价值的好东西!',
                            'desc' => '这里填写该网站的描述',
                        ),
                        array(
                            'id'    => 'case_logo',
                            'type'  => 'upload',
                            'button_title' => '上传',
                            'remove_title' => '删除',
                            'default' => trailingslashit(get_stylesheet_directory_uri()).'assets/images/case_logo.png',
                            'title' => '网站LOGO',
                        ),
                        array(
                            'id'    => 'case_bg',
                            'type'  => 'upload',
                            'button_title' => '上传',
                            'remove_title' => '删除',
                            'default' => trailingslashit(get_stylesheet_directory_uri()).'assets/images/case_bg.png',
                            'title' => '背景图片',
                        ),
                    ),
                ),
            ),
        ),

    ),
));


if (!function_exists('ripro_v2_module_case')) {
    function ripro_v2_module_case($args, $instance)
    {
        if (!is_page_template_modular()) {
            return false;
        } //非模块页面不显示
        
        echo $args['before_widget'];
        //案例CSS
        wp_enqueue_style('case_style', trailingslashit(get_stylesheet_directory_uri()) . 'assets/css/case.css?van_ver=' . VAN_VER);?>
    <section class="customer-show bgfff">
    <div class="home-title">
        <h3><?php echo $instance['home_mode_case']['_title'] ?></h3>
        <span><?php echo $instance['home_mode_case']['_describe'] ?></span>
    </div>
    <div class="container">
        <div class="customer-warp row">
            <?php if (!empty($instance['home_mode_case']['casecms'])) 
                foreach ($instance['home_mode_case']['casecms'] as $k => $item) {
            ?>
              <div class="col-12 col-lg-3">
                <div class="item">
                    <div class="item-header">
                        <div class="icon">
                            <img src="<?php echo $item['case_logo'] ?>" alt="<?php echo $item['case_title'] ?>" />
                        </div>
                        <div class="item-user">
                            <b><?php echo $item['case_title'] ?></b>
                            <span>
                            <?php 
                            echo  parse_url($item['case_href'])['host'];
                            ?></span>
                        </div>
                    </div>
                    <div class="item-desc"><?php echo $item['case_describe'] ?></div>
                        <div class="goto">
                            <a href="<?php echo $item['case_href'] ?>" target="_blank" rel="nofollow">前去围观</a>
                        </div>
                        <div class="item-bg">
                            <img src="<?php echo $item['case_bg'] ?>" />
                        </div>
                    </div>
                </div>
                <?php      
                }
                ?>
            </div>
        </div>
    </section>
    <?php

        echo @$args['after_widget'];

    }
}

3.外观-小工具,拖动到显示的位置,添加相应数据即可

本教学根据源分享van子主题制作,转载请留好主题作者信息

发表评论

后才能评论