分页是将信息划分为离散页面的过程。
蓝色 <div class="mt-4"> {{ $posts->links('pagination::tailwind') }} </div> Controller public function index(Request $request) { $filter = [ 'title' => $request->title ?? '', 'slug' => $request->slug ?? '', 'category_name' => $request->category_name ?? '', ]; $posts = $this->postHelper->getAll($filter, $request->page ?? 1, $request->item_per_page ?? 25, $request->sort ?? ''); return view('admin.post.index', ['posts' => $posts['data']['data']]); } helper public function getAll(array $filter, int $page = 1, int $itemPerPage = 0, string $sort = '') { try { $posts = $this->postModel->getAll($filter, $page, $itemPerPage, $sort); if (empty($posts)) { return [ 'status' => false, 'data' => null, ]; } return [ 'status' => true, 'data' => $posts, ]; } catch (\Throwable $th) { return [ 'status' => false, 'error' => $th->getMessage(), ]; } } 模型 public function getAll(array $filter, int $page, int $itemPerPage, string $sort) { $skip = ($page * $itemPerPage) - $itemPerPage; $post = $this->query(); $total = $post->count(); $sort = $sort ?: 'created_at DESC'; $list = $post->orderByRaw($sort)->paginate($itemPerPage); return [ 'total' => $total, 'data' => $list, ]; } In Your Controller Change Like this return view('admin.post.index', ['posts' => $posts['data']]); In Your Model Modify the getAll Method return $post->orderByRaw($sort)->paginate($itemPerPage); return paginate result directly Laravel links() method requires Paginator object but your passing an array. 拉拉维尔分页 实际上,您所做的有点奇怪,但是您将paginate()的结果正确地传递给了视图。如果没有有意义的话,该方法不会返回任何内容:项目太少,无法分页。 拉拉维尔游乐场(Laravel Playground 拉拉维尔游乐场(Laravel Playground 如果您想更改功能,则可以选择手动创建自定义Paginator。在这种情况下,您需要操纵links()函数的结果始终返回hasPages()。通过这种操作,您可以覆盖默认行为,并使Paginator相信它总是需要显示,因为总有页面。 手动创建Paginator -Laravel 11.xdocs paginator / lenthawarepaginator实例方法 -Laravel 11.xdocs ,您可以选择实现自定义Paginator外观,从而使您还可以覆盖默认的IF-ELSE语句。 customation分页视图 -laravel 11.xdocs tailwindcssv4您将您的问题标记为使用V4。重要的是要注意,使用tailwindcss v4,已经实现了自动源检测,因此您不再需要列出true键中的每个源。默认情况下,与基于旧版JavaScript的配置相比,CSS优先配置优选。 tailwindcssv4的自动源检测 - stackoverflow 很重要的是要知道自动源检测并不能涵盖所有内容。它会自动排除content中列出的路径。 设定基本路径:tailwind.config.js -tailwindcss v4docs 可自动检测:.gitignore -tailwindcss v4docs 文件扫描哪些文件 TailWind将扫描项目中的每个文件中的每个文件中的类名,在以下情况下:: 文件中的文件 二进制文件,例如图像,视频或zip文件CSS文件 Common软件包管理器锁定文件 要在一个额外的@import "tailwindcss" source("../src");或@import "tailwindcss" source(none);文件夹中包含一个软件包(通常由.gitignore)中包含一个软件包,您需要使用/vendor指令在CSS文件中注册它,如下所示: /node_modules指令 -TailWindcss v4docs tailwind jit:分页的必要内容 - laravel 12.xdocs 文档仍然显示基于V3 JavaScript的路由,但是可以使用相对路径可以轻松地将其重新编码为新的V4语法。 。/resources/css/style.css .gitignore
蓝色 <div class="mt-4"> {{ $posts->links('pagination::tailwind') }} </div> Controller public function index(Request $request) { $filter = [ 'title' => $request->title ?? '', 'slug' => $request->slug ?? '', 'category_name' => $request->category_name ?? '', ]; $posts = $this->postHelper->getAll($filter, $request->page ?? 1, $request->item_per_page ?? 25, $request->sort ?? ''); return view('admin.post.index', ['posts' => $posts['data']['data']]); } helper public function getAll(array $filter, int $page = 1, int $itemPerPage = 0, string $sort = '') { try { $posts = $this->postModel->getAll($filter, $page, $itemPerPage, $sort); if (empty($posts)) { return [ 'status' => false, 'data' => null, ]; } return [ 'status' => true, 'data' => $posts, ]; } catch (\Throwable $th) { return [ 'status' => false, 'error' => $th->getMessage(), ]; } } 模型 public function getAll(array $filter, int $page, int $itemPerPage, string $sort) { $skip = ($page * $itemPerPage) - $itemPerPage; $post = $this->query(); $total = $post->count(); $sort = $sort ?: 'created_at DESC'; $list = $post->orderByRaw($sort)->paginate($itemPerPage); return [ 'total' => $total, 'data' => $list, ]; } In Your Controller Change Like this return view('admin.post.index', ['posts' => $posts['data']]); In Your Model Modify the getAll Method return $post->orderByRaw($sort)->paginate($itemPerPage); return paginate result directly Laravel links() method requires Paginator object but your passing an array.
上,该表被加载值重新绘制。除了一个问题外,一切都很好地工作了:当我从没有加载状态的页面的状态下去时,它不会为加载状态加载正确的页面,如果这很有意义。 例如:
我的代码可以获取自定义术语的所有帖子, 我想为该代码应用分页。 <div> <?php $text = $_POST['text']; /* echo ($text); */ $args = array( 'numberposts' => -1 ); $posts = get_posts( $args ); foreach($posts as $post) { $custom_terms = get_the_terms($post->ID,'Characters'); foreach($custom_terms as $custom_term) { if ( ($custom_term->name) == ($text) ) { ?> <div class="col-sm-2"> <article class="item"> <div class="article-inner"> <div class="overlay"></div> <div class="img-wrapper"><img class="img-100p latest-post-image" src="<?php the_post_thumbnail_url('large'); ?>" alt="img"></div> <div class="article-info"> <h4 class="entry-title"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php //echo $countA ?><?php //echo $count_posts?><?php //echo $count%$st?></a> </h4> </div> </div> </article> </div> <?php } } } ?> </div> 我使用插件 https://wordpress.org/plugins/wck-custom-fields-and-custom-post-post-types-cereator/ 在后端admin wordpress上创建该custom_term. 尝试使用此代码,但是当转到第2页时,没有帖子apperas <div> <?php $text = $_POST['text']; $paged = get_query_var('paged') ? get_query_var('paged') : 1; $count = 0; $st = 15; $args = array( 'numberposts' => -1 ); $posts = get_posts( $args ); $stack = array(2005); $poststatus = array( 'publish' ); $current_category = single_cat_title("", false); foreach($posts as $post) { $custom_terms = get_the_terms($post->ID,'characters'); foreach($custom_terms as $custom_term) { if ( (($custom_term->name) == ($text)) ) { $counter ++ ; array_push($stack,($post->ID) ); } } } $args1 = array( 'post_type' => 'post', 'post__in' => $stack, //'category_name' => '', 'post_status' => 'publish', 'posts_per_page' => 18, //'offset' => 5, 'order_by' => 'date', 'paged' => $paged, 'ignore_sticky_posts' => 5 , ); $wp_query = new WP_Query( $args1 ); $count_posts = $wp_query->post_count; if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); $count++; if ($count%$st == 4) : $count = 1; ?> <?php endif; ?> <div class="col-sm-4"> <article class="item"> <div class="article-inner"> <div class="overlay"></div> <div class="img-wrapper"><img class="img-100p latest-post-image" src="<?php the_post_thumbnail_url('large'); ?>" alt="img"></div> <div class="article-info"> <h4 class="entry-title"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h4> </div> </div> </article> </div><!--col-sm-4--> <?php endwhile; //wp_reset_postdata(); //wp_reset_query(); //wp_reset_postdata(); endif; ?> @manoharsingh 这个是完整的模板文件 <?php /** <?php /* Template Name: C1 * * Used to display archive-type pages if nothing more specific matches a query. * For example, puts together date-based pages if no date.php file exists. * * If you'd like to further customize these archive views, you may create a * new template file for each one. For example, tag.php (Tag archives), * category.php (Category archives), author.php (Author archives), etc. * * @link https://codex.wordpress.org/Template_Hierarchy * * @package Primer * @since 1.0.0 */ get_header(); $temp = $wp_query; // $wp_query = null; $wp_query = new WP_Query(); $wp_query->query('showposts=6&post_type=post_type_name'.'&paged='.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <div> <?php $text = $_POST['text']; /* echo ($text); */ $args = array( 'numberposts' => -1 ); $posts = get_posts( $args ); foreach($posts as $post) { $custom_terms = get_the_terms($post->ID,'characters'); foreach($custom_terms as $custom_term) { if ( ($custom_term->name) == ($text) ) { ?> <div class="col-sm-2"> <article class="item"> <div class="article-inner"> <div class="overlay"></div> <div class="img-wrapper"><img class="img-100p latest-post-image" src="<?php the_post_thumbnail_url('large'); ?>" alt="img"></div> <div class="article-info"> <h4 class="entry-title"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php //echo $countA ?><?php //echo $count_posts?><?php //echo $count%$st?></a> </h4> </div> </div> </article> </div> <?php } } } ?> </div> <?php endwhile; ?> <section class="all-pagination"> <div class="container"> <div class="col-md-12"> <div class="col-md-12 in-pagination"> <ul class="pagination"> <?php wp_pagenavi( array( 'query' => $wp_query ) ); ?> <?php //if (function_exists('wp_pagenavi')) { wp_pagenavi( array( 'query' => $wp_query ) ); } ?> </ul> </div> </div> </div> </section> <?php ?> <?php get_footer(); ?> 步调这个代码, <?php $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query('showposts=6&post_type=post_type_name'.'&paged='.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <!-- LOOP: Usual Post Template Stuff Here--> <?php endwhile; ?> <nav> <?php previous_posts_link('« Newer') ?> <?php next_posts_link('Older »') ?> </nav> 您可以尝试使用此插件来进行分页'https://wordpress.org/plugins/wp-pagenavi/''
$games = GameResource::collection(Game::all()); $clientGames = array(); foreach ($games as $game) { if (!$game->user->inRole('admin')) { array_push($clientGames, $game); } }
我们使用最新的WP(5.2.2)。我们有一种定制的帖子类型,称为Stories(Slug:Stories),具有以下功能。 公共:是的 公开查询:是的 显示UI:是的 ...
我已经在这件事上已经砍了几个小时了。阅读大约7或8个在线教程,但我仍然无法与我的分页进行搜索结果。
$this->set('plans', $this->Plan->find('all', $options));
我正在通过JDBC从MS-SQL数据库中获取数据。我的MS-SQL数据库在远程计算机上,我通过VPN连接机器。 我想在页面中获取数据,因此我使用了setfetchsize()method
preparedStatement = getStatement(connection, sqlStatement); int pageSize = 10; preparedStatement.setFetchSize(pageSize); resultSet = statement.executeQuery(); while (resultSet.next()) { int id = resultSet.getInt("id"); String name = resultSet.getString("name"); System.out.println("ID: " + id + ", Name: " + name); }
Doctrine2Paginator,getarrayresult
partial c.{id,name,created}
在Azure Data Factory中的API调用中的offset
I正在使用ADF从REST API检索数据并加载到SQL DB中。我的问题是,API中的端点每页最多返回50个记录。 我正在尝试使用内置
function scrapeTitlesData() { var url = "https://notices.philgeps.gov.ph/GEPSNONPILOT/Tender/SplashOpportunitiesSearchUI.aspx?menuIndex=3&BusCatID=53&type=category&ClickFrom=OpenOpp"; var response = UrlFetchApp.fetch(url).getContentText(); extractAndModifyUrls(response) } function extractAndModifyUrls(html) { // Regex pattern to match the required URLs var regex = /SplashBidNoticeAbstractUI\.aspx\?menuIndex=3&refID=\d+&[^"]+/g; // Initialize an empty array to store the modified URLs var modifiedUrls = []; var match; // Find all matches in the HTML while ((match = regex.exec(html)) !== null) { var newUrl = 'https://notices.philgeps.gov.ph/GEPSNONPILOT/Tender/' + match[0]; newUrl = newUrl.replace(/&/g, '&'); // Add the new URL to the array modifiedUrls.push(newUrl); } console.log(modifiedUrls); console.log(modifiedUrls.length) var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); sheet.getRange(1, 1, modifiedUrls.length, 1).setValues(modifiedUrls.map(function(url) { return [url]; })); }
,但尝试了各种事情,但无济于事。在我的情况下,我正在使用一个复制数据活动,该数据活动连接到API端点并将所得的JSON文件输出到Lakehouse文件夹。
pagination,其中自动从服务器上的特定文件夹自动发现页数 我是CSS的新手(不幸的是对JS),想知道是否可能: 我想为CSS(如果有人可以帮助我)为CSS(或JS/jQuery)编码脚本。
https://github.com/gbirke/jquery_pagination
Elementor“每页项目”不适用于“搜索结果”页面的“循环网格”
我创建了一个“搜索结果”页面模板,其中“循环网格”设置为“当前查询”,“每页项目数”设置为 20。 测试搜索时,在...