Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » DataObject::get

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

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

Page: 1
Go to End
Author Topic: 1373 Views
  • kusi
    Avatar
    Community Member
    21 Posts

    DataObject::get Link to this post

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

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: DataObject::get Link to this post

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

  • kusi
    Avatar
    Community Member
    21 Posts

    Re: DataObject::get Link to this post

    $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.

  • kusi
    Avatar
    Community Member
    21 Posts

    Re: DataObject::get Link to this post

    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

    1373 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.