Answer the question
In order to leave comments, you need to log in
Add values from db to limit(10) kohana 3.1 framework?
Made an additional block for output.
Code in the template:
<?php foreach ($block_1 as $news_1):?>
тут новости со стилями и т.д
<?php endforeach?>
$this->template->categories = $data;
$this->template->block_1 = ORM::factory('news')->where('status', '=',
1)->order_by('id', 'DESC')->and_where('block1', '=',
1)->limit(10)->find_all();
Answer the question
In order to leave comments, you need to log in
$limit = DB::select('per_page_block1')->from('settings')->limit(1)->execute()->get('per_page_block1', 10);
$this->template->categories = $data;
$this->template->block_1 = ORM::factory('news')->where('status', '=',
1)->order_by('id', 'DESC')->and_where('block1', '=',
1)->limit($limit)->find_all();
Settings::get('page_limit',10)
For Kohana, there is a ready-made module for implementing pagination (does not come with the box)
https://github.com/shadowhand/pagination
Thank you very much for the answer , oh, but I saw similar examples, but I thought that this was not right, not what was needed, but it turned out that this was what was needed and it worked! how simple it is)))
as I understand it, if there is nothing in the settings in the setting, then it takes parameter 10 and displays 10 news, did I understand correctly? (that is, if it does not take a value from the database, if there is nothing there, then it substitutes the value 10.
get('per_page_block1', 10);
======== ==========================================
Is it possible to connect pagination to all this? In general, there is pagination on the site, but how to do it for this news output, for this block.
let's set let's display 10 news, and if there are more of them, then pagination would work. and pages appear.
$limit = DB::select('per_page_block1')->from('settings')->limit(1)->execute()->get('per_page_block1', 10);
$this->template->categories = $data;
$this->template->block_1 = ORM::factory('news')->where('status', '=',
1)->order_by('id', 'DESC')->and_where('block1', '=',
1)->limit($limit)->find_all();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question