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


PHP Post::order_by方法代码示例

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


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

示例1: populyar_post_by_visits

 public function populyar_post_by_visits()
 {
     $post = new Post();
     $posts = $post->order_by('time_created', 'desc');
     $posts = $posts->get();
     $res = $this->like('page', 'blog/post/', 'after')->get();
     $sluge = array();
     foreach ($res->all as $key => $value) {
         $post = explode('/', $value->page);
         if ($post[1] == 'post') {
             if (array_key_exists($post[2], $sluge)) {
                 $sluge[$post[2]]++;
             } else {
                 $sluge[$post[2]] = 1;
             }
         }
     }
     foreach ($posts->all as $post_key => $post_value) {
         if (!array_key_exists($post_value->slug, $sluge)) {
             $sluge[$post_value->slug] = 0;
         }
     }
     arsort($sluge);
     return $sluge;
 }
开发者ID:hyrmedia,项目名称:builderengine,代码行数:25,代码来源:Visits.php

示例2: all_posts

 public function all_posts()
 {
     $posts = new Post();
     $page_number = 1;
     if (isset($_GET['page'])) {
         $page_number = $_GET['page'];
     }
     if (!$this->BuilderEngine->get_option('be_blog_num_posts_displayed')) {
         $posts_per_page = 6;
     } else {
         $posts_per_page = $this->BuilderEngine->get_option('be_blog_num_posts_displayed');
     }
     $data['posts'] = $posts->order_by('time_created', 'desc')->get_paged($page_number, $posts_per_page);
     $data['categories'] = $this->get_categories();
     $this->load->view('frontend/all_posts', $data);
 }
开发者ID:hyrmedia,项目名称:builderengine,代码行数:16,代码来源:blog.php

示例3: Post

						      else
						        $(".child" + i).addClass('visible-li');
						  }
						}
						</script>
					</div>

					<!-- recent posts -->
					<div class="widget">

						<h4>RECENT POSTS</h4>

						<ul class="nav nav-list">
						<?php 
$all_posts = new Post();
$recent_posts = $all_posts->order_by('time_created', 'desc');
$recent_post_limit = $this->BuilderEngine->get_option('be_blog_num_recent_posts_displayed');
if ($recent_post_limit == '' || $recent_post_limit == 0) {
    $recent_post_limit = 5;
}
$j = 1;
?>
						<?php 
foreach ($recent_posts->get() as $recent_post) {
    ?>
					        <?php 
    if ($j <= $recent_post_limit) {
        ?>
							    <li><a href="<?php 
        echo base_url();
        ?>
开发者ID:hyrmedia,项目名称:builderengine,代码行数:31,代码来源:all_posts.php

示例4: generate_content

    public function generate_content()
    {
        $CI =& get_instance();
        $CI->load->model('visits');
        $sequence = $CI->visits->populyar_post_by_visits();
        $sections_font_color = $this->block->data('sections_font_color');
        $sections_font_weight = $this->block->data('sections_font_weight');
        $sections_font_size = $this->block->data('sections_font_size');
        $sections_background_color = $this->block->data('sections_background_color');
        $post_count = $this->block->data('post_count');
        $alphabetical_order = $this->block->data('alphabetical_order');
        $category = $this->block->data('category');
        $sections_animation_type = $this->block->data('sections_animation_type');
        $sections_animation_duration = $this->block->data('sections_animation_duration');
        $sections_animation_event = $this->block->data('sections_animation_event');
        $sections_animation_delay = $this->block->data('sections_animation_delay');
        $settings[0][0] = 'category' . $this->block->get_id();
        $settings[0][1] = $sections_animation_event;
        $settings[0][2] = $sections_animation_duration . ' ' . $sections_animation_delay . ' ' . $sections_animation_type;
        add_action("be_foot", generate_animation_events($settings));
        $section_style = 'style="
                    background-color: ' . $sections_background_color . ' !important;
                "';
        $section_link_style = 'style="
                    color: ' . $sections_font_color . ' !important;
                    font-weight: ' . $sections_font_weight . ' !important;
                    font-size: ' . $sections_font_size . ' !important;
                "';
        $users = new User();
        $all_posts = new Post();
        $all_category = new Category();
        $BuilderEngine = new BuilderEngine();
        $recent_posts = $all_posts->order_by('time_created', 'desc');
        if ($category == 'all' || intval($category) == 0) {
            $recent_posts = $recent_posts->get();
        } else {
            $recent_posts = $recent_posts->get_where(array('category_id' => intval($category)));
        }
        $recent_post_limit = $BuilderEngine->get_option('be_blog_posts_per_page');
        if ($recent_post_limit == '' || $recent_post_limit == 0) {
            $recent_post_limit = 5;
        }
        if (isset($post_count)) {
            if ($post_count == 'all') {
                $recent_post_limit = count($recent_posts->all);
            } else {
                $recent_post_limit = $post_count;
            }
        }
        if ($alphabetical_order == 'yes') {
            ksort($sequence);
        }
        $output = '<div class="row">
                <div ' . $section_style . ' class="masonry-list">';
        $i = 1;
        foreach ($sequence as $key => $value) {
            foreach ($recent_posts as $post) {
                if ($key == $post->slug) {
                    if ($i <= $recent_post_limit) {
                        $user = $users->get_by_id($post->user_id);
                        $output .= '
							<link href="' . base_url('blocks/category_posts/style.css') . '" rel="stylesheet">
							<link href="' . base_url('builderengine/public/animations/css/animate.min.css') . '" rel="stylesheet" />
							<div class="col-md-6" id="blog">
                                <li class="masonry-item-blog-category-post">
                                    <div class="item" id="category' . $this->block->get_id() . '">
                                        <div class="item-title blog-header-small">
                                            <h2><a ' . $section_link_style . ' href="' . base_url('/blog/post') . '/' . $post->slug . '"> ' . $post->title . '</a></h2>  
											<small class="space14">';
                        $post_comments = array();
                        $CI =& get_instance();
                        $CI->load->model('comment');
                        $comments = new Comment();
                        foreach ($comments->where('post_id', $post->id)->get() as $comment) {
                            array_push($post_comments, $comment->id);
                        }
                        $num_comments = count($post_comments);
                        $pluralizer = $num_comments == 1 ? 'Comment' : 'Comments';
                        $output .= '                                          
                                            <a href="/blog/post/' . $post->slug . '#comments" class="label label-default light"><i class="fa fa-comment-o"></i> ' . $num_comments . '' . $pluralizer . '</a>
                                            <span class="label label-default light">' . date('M d, Y', $post->time_created) . '</span> 
											<a class="label label-default light pull-right"><i>Post by: </i> ' . $user->username . ' </a>
                                        </div>

                                        <figure>
                                            <a href="/blog/post/' . $post->slug . '"><img src="' . $post->image . '" class="img-responsive thumbnail" alt="" /></a>
                                        </figure>';
                        $text_without_slashes = ChEditorfix($post->text);
                        if (strlen($post->text) > 300) {
                            $text = substr($text_without_slashes, 0, 300) . '...';
                        } else {
                            $text = $text_without_slashes;
                        }
                        $output .= '<div style="word-wrap: break-word;">' . $text . '</div>
                                        <a href="/blog/post/' . $post->slug . '" class="btn-primary btn-xs pull-right"><i class="fa fa-sign-out"></i> READ MORE..</a>
                                    </div>
                                
                                </li></div>';
                        $i++;
                    }
//.........这里部分代码省略.........
开发者ID:hyrmedia,项目名称:builderengine,代码行数:101,代码来源:category_posts.php

示例5: latest

	function latest($page_number = 0)
	{
		
		
		$limit = 10;
		$offset = $page_number * $limit;
		
		$postObject = new Post;
		
		if(! $this->dx_auth->is_logged_in())
			$postObject->where("status", $this->_PUBLISHED)->order_by("published DESC")->limit($limit, $offset)->get();
		else
			$postObject->order_by("created DESC")->limit($limit, $offset)->get();
			
		foreach($postObject->all as $post)
		{
			$data["posts"][$post->id]["id"] = $post->id;
			$data["posts"][$post->id]["category"] = ($post->category_id > 0) ? $post->category->name : "Entry";
			$data["posts"][$post->id]["title"] = $post->title;
			$data["posts"][$post->id]["published"] = $post->published;
			$data["posts"][$post->id]["author"] = $post->author->name();
			$data["posts"][$post->id]["body"] = $post->body;
			$data["posts"][$post->id]["url"] = $post->url;
		}
		
		$this->load->view("chronicle/list", $data);
	}
开发者ID:narendranag,项目名称:Chronicle,代码行数:27,代码来源:chronicle.php

示例6: slugger

 private function slugger($title)
 {
     $a = explode(' ', $title);
     foreach ($a as &$t) {
         if (strpos($t, '-')) {
             explode(' ', $t);
         }
     }
     if (count($a) > 5) {
         $a = array_slice($a, 0, 4);
     }
     $f = implode('-', $a);
     $p = Post::order_by('created_at', 'desc')->first();
     $f .= "-" . ($p->id + 1);
     return $f;
 }
开发者ID:ryankennedy1991,项目名称:Toure-cms,代码行数:16,代码来源:posts.php

示例7: generate_content

    public function generate_content()
    {
        $sections_font_color = $this->block->data('sections_font_color');
        $sections_font_weight = $this->block->data('sections_font_weight');
        $sections_font_size = $this->block->data('sections_font_size');
        $sections_background_color = $this->block->data('sections_background_color');
        $post_count = $this->block->data('post_count');
        $animation = $this->block->data('animation');
        $animation_type = $this->block->data('animation_type');
        $animation_duration = $this->block->data('animation_duration');
        $animation_event = $this->block->data('animation_event');
        $animation_delay = $this->block->data('animation_delay');
        $settings[0][0] = 'recentitems' . $this->block->get_id();
        $settings[0][1] = $animation_event;
        $settings[0][2] = $animation_duration . ' ' . $animation_delay . ' ' . $animation_type;
        add_action("be_foot", generate_animation_events($settings));
        $section_style = 'style="
                    background-color: ' . $sections_background_color . ' !important;
                "';
        $section_link_style = 'style="
                    color: ' . $sections_font_color . ' !important;
                    font-weight: ' . $sections_font_weight . ' !important;
                    font-size: ' . $sections_font_size . ' !important;
                "';
        $CI =& get_instance();
        $CI->load->model('post');
        $all_posts = new Post();
        $BuilderEngine = new BuilderEngine();
        $recent_posts = $all_posts->order_by('time_created', 'desc');
        $recent_post_limit = $BuilderEngine->get_option('be_blog_num_recent_posts_displayed');
        if ($recent_post_limit == '' || $recent_post_limit == 0) {
            $recent_post_limit = 5;
        }
        if (isset($post_count)) {
            $recent_post_limit = $post_count;
        }
        $j = 1;
        $output = '
					<link href=\\"/builderengine/public/animations/css/animate.min.css\\" rel=\\"stylesheet\\" />
                     <link href="' . base_url('blocks/recent_posts/style.css') . '" rel="stylesheet">
					<div ' . $section_style . ' class="widgetblogrecent" id="blog">
					<div id="recentitems' . $this->block->get_id() . '" class="masonry-item-blog-recent">
                        <h4>RECENT BLOGS</h4>
                        <ul class="nav nav-list">';
        foreach ($recent_posts->get() as $recent_post) {
            if ($j <= $recent_post_limit) {
                $output .= '
                                    <li>
                                        <a ' . $section_link_style . ' href="' . base_url() . 'blog/post/' . $recent_post->slug . '">
                                            <i class="fa fa-sign-out"></i> 
                                        ' . $recent_post->title . '</a>
                                        <small>' . date('d.M.Y / h:i', $recent_post->time_created) . '</small>
                                    </li>';
                $j++;
            }
        }
        $output .= '
                        </ul>
                   </div> </div>';
        return $output;
    }
开发者ID:hyrmedia,项目名称:builderengine,代码行数:61,代码来源:recent_posts.php

示例8: action_index

 public function action_index()
 {
     $posts = Post::order_by('created_at', 'desc')->get();
     return View::make('posts.all')->with('posts', $posts);
 }
开发者ID:ryankennedy1991,项目名称:makeitvalue,代码行数:5,代码来源:posts.php

示例9: generate_content

    public function generate_content()
    {
        $CI =& get_instance();
        $CI->load->model('visits');
        $sequence = $CI->visits->populyar_post_by_visits();
        $sections_font_color = $this->block->data('sections_font_color');
        $sections_font_weight = $this->block->data('sections_font_weight');
        $sections_font_size = $this->block->data('sections_font_size');
        $sections_background_color = $this->block->data('sections_background_color');
        $sections_animation_type = $this->block->data('sections_animation_type');
        $sections_animation_duration = $this->block->data('sections_animation_duration');
        $sections_animation_event = $this->block->data('sections_animation_event');
        $sections_animation_delay = $this->block->data('sections_animation_delay');
        $settings[0][0] = 'blog_list';
        $settings[0][1] = $sections_animation_event;
        $settings[0][2] = $sections_animation_duration . ' ' . $sections_animation_delay . ' ' . $sections_animation_type;
        add_action("be_foot", generate_animation_events($settings));
        $post_count = $this->block->data('post_count');
        $alphabetical_order = $this->block->data('alphabetical_order');
        $category = $this->block->data('category');
        $section_style = 'style="
                    background-color: ' . $sections_background_color . ' !important;
                "';
        $section_link_style = 'style="
                    color: ' . $sections_font_color . ' !important;
                    font-weight: ' . $sections_font_weight . ' !important;
                    font-size: ' . $sections_font_size . ' !important;
                "';
        $all_posts = new Post();
        $all_category = new Category();
        $BuilderEngine = new BuilderEngine();
        $recent_posts = $all_posts->order_by('time_created', 'desc');
        // out(intval($category));
        if ($category == 'all' || intval($category) == 0) {
            $recent_posts = $recent_posts->get();
        } else {
            $recent_posts = $recent_posts->get_where(array('category_id' => intval($category)));
        }
        $recent_post_limit = $BuilderEngine->get_option('be_blog_num_recent_posts_displayed');
        if ($recent_post_limit == '' || $recent_post_limit == 0) {
            $recent_post_limit = 5;
        }
        if (isset($post_count)) {
            if ($post_count == 'all') {
                $recent_post_limit = count($recent_posts->all);
            } else {
                $recent_post_limit = $post_count;
            }
        }
        if ($alphabetical_order == 'az') {
            //ok
            ksort($sequence);
        }
        if ($alphabetical_order == 'za') {
            //ok
            krsort($sequence);
        }
        if ($alphabetical_order == 'oldest') {
            $recent_posts = $all_posts->order_by('time_created', 'asc');
        }
        if ($alphabetical_order == 'latest') {
            //ok
            rsort($sequence);
        }
        if ($alphabetical_order == 'updated') {
            $recent_posts = $all_posts->order_by('time_created', 'desc');
        }
        if ($alphabetical_order == 'most_visited') {
            //ok
            arsort($sequence);
        }
        if ($alphabetical_order == 'less_visited') {
            //ok
            asort($sequence);
        }
        $output = '
                    <link href="' . base_url('blocks/blog_posts_list/style.css') . '" rel="stylesheet">
					<div ' . $section_style . ' class="widgetbloglist" id="blog_list">
					<div class="masonry-item-blog-list">
                        <h4>BLOG POSTS</h4>
                        <ul class="nav nav-list">';
        $j = 1;
        foreach ($sequence as $key => $value) {
            foreach ($recent_posts as $recent_post) {
                if ($key == $recent_post->slug) {
                    if ($j <= $recent_post_limit) {
                        $output .= '
                                            <li>
                                                <a ' . $section_link_style . ' href="' . base_url() . 'blog/post/' . $recent_post->slug . '">
                                                    <i class="fa fa-sign-out"></i>  
                                                ' . $recent_post->title . '</a>
                                                <small>' . date('d.M.Y / h:i', $recent_post->time_created) . '</small>
                                            </li>';
                        $j++;
                    }
                }
            }
        }
        $output .= '
                        </ul>
//.........这里部分代码省略.........
开发者ID:hyrmedia,项目名称:builderengine,代码行数:101,代码来源:blog_posts_list.php


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