当前位置: 首页>>代码示例>>PHP>>正文


PHP TimberHelper::array_truncate方法代码示例

本文整理汇总了PHP中TimberHelper::array_truncate方法的典型用法代码示例。如果您正苦于以下问题:PHP TimberHelper::array_truncate方法的具体用法?PHP TimberHelper::array_truncate怎么用?PHP TimberHelper::array_truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimberHelper的用法示例。


在下文中一共展示了TimberHelper::array_truncate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testArrayTruncate

 function testArrayTruncate()
 {
     $arr = array('Buster', 'GOB', 'Michael', 'Lindsay');
     $arr = TimberHelper::array_truncate($arr, 2);
     $this->assertContains('Buster', $arr);
     $this->assertEquals(2, count($arr));
     $this->assertFalse(in_array('Lindsay', $arr));
 }
开发者ID:rjagadishsingh,项目名称:timber,代码行数:8,代码来源:test-timber-helper.php

示例2: get_blog_posts

 public static function get_blog_posts()
 {
     $data = Timber::get_posts('post_type=post&posts_per_page=6');
     $data = TimberHelper::array_truncate($data, 6);
     return $data;
 }
开发者ID:ramsaylanier,项目名称:blades,代码行数:6,代码来源:blades-home.php

示例3: array

<?php

$data = Timber::get_context();
$data['wp_title'] = 'Upstatement - Portfolio';
$entry_manual = array();
$entries = get_field('entries', 'option');
if ($entries) {
    foreach ($entries as $e) {
        $entry_manual[] = $e->ID;
    }
}
$entry_manual = TimberHelper::array_truncate($entry_manual, 3);
$fp = new TimberPost(3251);
$fp->squares = get_field('squares', $fp->ID);
$billboards = array();
$billboard_ids = array();
foreach ($fp->squares as $square) {
    $bb = new TimberPost($square);
    $billboard_ids[] = $bb->ID;
    $bb->billboard = new TimberImage($bb->billboard);
    if (isset($bb->hero_tease)) {
        $bb->hero_tease = new TimberImage($bb->hero_tease);
    }
    $billboards[] = $bb;
}
// $data['billboards'] = array_slice($billboards, 0, 5);
// $data['plist'] = array_slice($billboards, 5);
$data['billboards'] = $billboards;
$data['clients'] = Timber::get_posts(array('post_type' => 'portfolio', 'numberposts' => -1, 'post__not_in' => $billboard_ids));
$portfolio_client_names = array();
foreach ($data['clients'] as $client) {
开发者ID:ramsaylanier,项目名称:blades,代码行数:31,代码来源:archive-portfolio.php

示例4: load_script

    load_script('scrollTo', get_stylesheet_directory_uri() . '/components/jquery.scrollTo/jquery.scrollTo.js', 1);
}
add_action('wp_enqueue_scripts', 'load_scripts');
update_option('siteurl', 'http://' . $_SERVER['HTTP_HOST']);
update_option('home', 'http://' . $_SERVER['HTTP_HOST']);
if (class_exists('Timber')) {
    Timber::add_route('blog', function ($params) {
        $sticky = get_option('sticky_posts');
        $sticky = TimberHelper::array_truncate($sticky, 4);
        $page = 0;
        $query = array('post_type' => 'post', 'posts_per_page' => 6, 'post__not_in' => $sticky, 'offset' => $page * 6);
        Timber::load_template('archive-blog.php', $query);
    });
    Timber::add_route('blog/page/:pg', function ($params) {
        $sticky = get_option('sticky_posts');
        $sticky = TimberHelper::array_truncate($sticky, 4);
        $page = $params['pg'];
        $page -= 1;
        $page = max(0, $page);
        $query = array('post_type' => 'post', 'posts_per_page' => 6, 'post__not_in' => $sticky, 'offset' => $page * 6);
        Timber::load_template('archive-blog.php', $query);
    });
}
if (class_exists('BladesSite')) {
    BladesSite::register_post_types();
    BladesSite::apply_admin_customizations();
    add_action('init', function () {
        BladesSite::register_post_types();
    });
}
if (class_exists('ChainsawDashboard')) {
开发者ID:JimCaignard,项目名称:blades,代码行数:31,代码来源:functions.php

示例5: TimberTerm

$data = Timber::get_context();
global $wp_query;
$api = false;
if (isset($_GET['api'])) {
    $api = $_GET['api'];
}
$data['base'] = 'base.twig';
if ($api) {
    $data['base'] = 'base-blank.twig';
}
$page = 0;
if ($wp_query->query_vars['paged']) {
    $page = $wp_query->query_vars['paged'];
}
$term = new TimberTerm();
$data['title'] = "Archives for " . $term->name;
$data['blog_cron'] = Timber::get_posts();
$data['tags'] = Timber::get_terms(array('tax' => 'tags', 'orderby' => 'count'));
shuffle($data['tags']);
$data['tags'] = TimberHelper::array_truncate($data['tags'], 10);
$next_page = $page + 1;
if ($page == 0) {
    $next_page = 2;
}
if ($api) {
    Timber::render('archive-blog-loop.twig', $data);
} else {
    $data['sidebar'] = Timber::get_sidebar('sidebar.php');
    Timber::render('archive-blog.twig', $data);
}
开发者ID:ramsaylanier,项目名称:blades,代码行数:30,代码来源:archive.php

示例6: TimberPost

 * @since Boilerplate 1.0
 */
$data = Timber::get_context();
$pi = new TimberPost();
$data['post'] = $pi;
$data['body_class'] .= ' page-' . $pi->post_name;
$template_file = 'page.twig';
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $data['theme_dir'] . '/css/' . $pi->post_type . '-' . $post->post_name . '.css')) {
    $data['post']->css_file = $data['theme_dir'] . '/css/' . $pi->post_type . '-' . $post->post_name . '.css';
}
$contribs = TimberHelper::transient('timber-contribs', function () {
    require_once __DIR__ . '/vendor/tan-tan-kanarek/github-php-client/tan-tan-kanarek/github-php-client/client/GitHubClient.php';
    $client = new GitHubClient();
    $auth = file_get_contents(__DIR__ . '/auth.json');
    $auth = json_decode($auth);
    $client->setCredentials($auth->github->user, $auth->github->pass);
    $contribs = $client->repos->listContributors('jarednova', 'timber', array('per_page' => 100));
    $extra = count($contribs) % 6;
    $total = count($contribs) - $extra;
    $contribs = TimberHelper::array_truncate($contribs, $total);
    $ret = array();
    foreach ($contribs as $contrib) {
        $obj = new stdClass();
        $obj->login = $contrib->getLogin();
        $obj->avatar_url = $contrib->getAvatarUrl();
        $ret[] = $obj;
    }
    return $ret;
}, 1200);
$data['contribs'] = $contribs;
Timber::render(array('custom/page-' . $pi->post_name . '.twig', 'page-' . $pi->post_name . '.twig', 'page.twig'), $data);
开发者ID:ramsaylanier,项目名称:blades,代码行数:31,代码来源:page-timber.php


注:本文中的TimberHelper::array_truncate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。