21309 Posts in 5738 Topics by 2603 members
| Go to End | Next > | |
| Author | Topic: | 1589 Views |
-
Dispalay pages...(paging)

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?
-
Re: Dispalay pages...(paging)

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
-
Re: Dispalay pages...(paging)

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... -
Re: Dispalay pages...(paging)

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)
-
Re: Dispalay pages...(paging)

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); -
Re: Dispalay pages...(paging)

3 March 2011 at 12:11am
always help if you actually provide the error message...
-
Re: Dispalay pages...(paging)

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.
| 1589 Views | ||
| Go to Top | Next > |


