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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

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

DataObject::get


Go to End


4 Posts   1730 Views

Avatar
kusi

Community Member, 21 Posts

19 August 2008 at 12:28pm

Edited: 20/08/2008 11:41am

I really count on U. Is it possible to modify this function and give there some arguments that would be in GET array?.

Avatar
Willr

Forum Moderator, 5523 Posts

19 August 2008 at 1:18pm

So what are you trying to pass to DataObject::get()? You can access GET vars the same as normally using $_GET['VariableName'] ?

Avatar
kusi

Community Member, 21 Posts

19 August 2008 at 9:19pm

Edited: 20/08/2008 11:56am

$data = DataObject::get("Article", "ParentID = {$this->ID}) AND (Date>'{$date1}')
AND (Date<'{$date2}'", "Date","","$SQL_start, 2");
return $data

and I know $date from POST but I've got limit and pagination. limit is gived by HTTP::setGetVar in DataObjectSet I can't use more Get Vars ex. $date1...

I want to give more arguments in filter than just ParentID IN .ss file it looks like this:

<% control LatestNews %>
<br>
<table>
<tr>
<td>
<% control Image.SetWidth(75) %>
<img src="$URL" alt="$Nickname's Avatar" />
<% end_control %>
</td>
<td>
$Content.FirstParagraph </td>
</tr>
<a href="$Link" title="Read more">
<tr>
<td>
$Date.Nice
</td>
</tr>
<tr>
<td>read more...
</td>
</tr>
</a>
</table>
<% end_control %>
<% if LatestNews.PrevLink %>
<a href="$LatestNews.PrevLink">Prev</a> |
<% end_if %>
<% control LatestNews.Pages %>
<% if CurrentBool %>
<strong>$PageNum</strong>
<% else %>
<a href="$Link" title="Go to page $PageNum">$PageNum</a>
<% end_if %>
<% end_control %>
<% if LatestNews.NextLink %>
<a href="$LatestNews.NextLink">Next</a>
<% end_if %>

When i'm using next link or just any other way of pagination i'm loosing my GET arguments what's normal but i think there are a lot of solutions to do this without database connection...what's not very normal in here

HELP PLEASE?

I can write function setGetVarS, but regular expression is not my best and there would be some more modification that could bring some problems.
When i don't use additional filters pagination's working good.

Avatar
kusi

Community Member, 21 Posts

20 August 2008 at 4:52am

Edited: 20/08/2008 11:46am

It's a big problem to me I think that for other people it would be also good advice, or let me know if I can do this any other way.Please.

Edit: I;m saving results in database, everything works good. Leavin' it, but I think DataObjectSet is very intresting and a little to small class ;]

bless