Edit
I've added a github repostitory of my /application
directory.
https://github.com/ashleyconnor/Egotist
I'm working through "Kohana 3: Beginner's Guide" from Packt Publishing and have just completed the 7th chapter.
The problem I am having is on my homepage I render paginated urls from a message model but the second url points to a route that doesn't exist.
I've highlighted where the View is rendering a 1
before the correct URL.
Another issue I am having is random 1
s printed throughout the screen. Is this due to me coding in Development mode?
Controller:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Welcome extends Controller_Application {
public function action_index()
{
$content = View::factory('welcome')
->bind('messages', $messages)
->bind('pager_links', $pager_links);
$message = new Model_Message;
$message_count = $message->count_all();
$pagination = Pagination::factory(array(
'total_items' => $message_count,
'items_per_page' => 3,
));
$page开发者_StackOverflow中文版r_links = $pagination->render();
$messages = $message->get_all($pagination->items_per_page, $pagination->offset);
$this->template->content = $content;
}
}
View:
<h1>Recent Messages on Egotist</h1>
<?php foreach ($messages as $message) : ?>
<p class="message">
<?php echo $message->content; ?>
<br />
<span class="published">
<?php echo Date::fuzzy_span($message->date_published); ?>
</span>
</p>
<hr />
<?php endforeach; ?>
<?php echo $pager_links; ?>
Snippet of the output:
<p class="pagination">
First
Previous
<strong>1</strong>
<a href="1/?page=2">2</a> <--misbehaving
<a href="/?page=3">3</a>
<a href="/?page=4">4</a>
<a href="/?page=5">5</a>
<a href="/?page=6">6</a>
<a href="/?page=7">7</a>
<a href="/?page=8">8</a>
<a href="/?page=2" rel="next">Next</a>
<a href="/?page=8" rel="last">Last</a>
</p><!-- .pagination -->
In your Controller_User_Account
and HTML
class:
replace
<?php echo defined('SYSPATH') or die('No direct access allowed.');
with
<?php defined('SYSPATH') or die('No direct access allowed.');
I can't see anything wrong with the 3.0/master version of the pagination module.
Anything that could be adding a '1' at that point during the output would be something called during the execution of HTML::chars($page->url($i))
.
I suggest you check your codebase and system libraries for out of place calls to 'echo'. If you've cloned from git you should be able to check for changes, if not, compare it to a fresh copy.
Also, in your bootstrap file, you should set your index_file
option to FALSE
instead of the empty string.
精彩评论