Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Dispalay pages...(paging)


Go to End


10 Posts   2898 Views

Avatar
Dr0gaz

Community Member, 37 Posts

1 March 2011 at 4:50am

Hi, guys... it's possible make one template and show all pages in my html... i want paging items 5 in 5 but... first i have charge all pages in hmtl code... example:

<div class="item"> /*first page
<ul>
<li><a href="13">ITEM 1 </a></li>
<li><a href="12">ITEM 2</a></li>
<li><a href="7">ITEM 3 </a></li>
<li><a href="6">ITEM 4 </a></li>
<li><a href="5">ITEM 5 </a></li>
</ul>
</div>

<div class="item"> /*second page
<ul>
<li><a href="13">ITEM 6 </a></li>
<li><a href="12">ITEM 7</a></li>
<li><a href="7">ITEM 8 </a></li>

</ul>
</div>

2 pages i have write in html whithout query:

if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
$SQL_start = (int)$_GET['start'];

how i resolve this problem?

Avatar
swaiba

Forum Moderator, 1899 Posts

1 March 2011 at 6:07am

Sorry I don't follow exactly - you are trying to add pagination no?

I've looked for the doc page, but could find it.. how about this instead...

http://www.silverstripe.org/general-questions/show/14780#post295050

Avatar
Dr0gaz

Community Member, 37 Posts

2 March 2011 at 12:20am

hi!!
thank's for the tip but not quite what I am seeking...
I've a jquery that makes the pagination, but i have the query's divided for div's 5 in 5 items!
well i'have first write code in html...

Avatar
swaiba

Forum Moderator, 1899 Posts

2 March 2011 at 2:41am


something like in your Page controller...

function Results {
$iPageLength = 5;

$dos=DataObject::get('SomeObject');
$dos->setPageLength($iPageLength);

$dosResults= new DataObjectSet();
for ($i=0;$i<$dos->TotalPages();$i++) {
$dosResults->Items = new DataOBjectSet();
$dosResults->Items = $dos->getRange($i*$iPageLength,$iPageLength);
}
returning $dos;
}

and this on your template...

<% control Results %>
<% control Items %>
$ItemData
<% end_control %>
<% end_control %>

If this doesn't make sense or has bugs (it is untested) then please read the documentation on templates and dataobjects (help - docs or api - and search)

Avatar
Dr0gaz

Community Member, 37 Posts

3 March 2011 at 12:02am

function getResults() {

$iPageLength = 5;

$dos = DataObject::get('Problema',"`CategoriaProbID` = '{$this->ID}'");
$dos->setPageLength($iPageLength);

//echo TotalPages($dos);

//$dos= new DataObjectSet();
//echo $dos->pergunta;
//echo $dos->count();

//echo $dos->getRange();
/*
for ($i=0;$i<$dos->TotalPages();$i++) {
$dosResults->Items = new DataOBjectSet();
$dosResults->Items = $dos->getRange($i*$iPageLength,$iPageLength);
}
//echo $dos->getRange();
*/

return $dos ? $dos : false;

}

Why have a error?

whats difrence

$dos=DataObject::get('SomeObject');
$dos = DataObject::get('SomeObject',$filter);

Avatar
swaiba

Forum Moderator, 1899 Posts

3 March 2011 at 12:11am

always help if you actually provide the error message...

Avatar
Dr0gaz

Community Member, 37 Posts

3 March 2011 at 12:28am

that's de error...

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

Go to Top