Jump to:

10928 Posts in 2612 Topics by 1809 members

All other Modules

SilverStripe Forums » All other Modules » Sphinx 0.1: $SphinxSearchForm / no enabled local indexes to search

Discuss all other Modules here.

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

Page: 1 2 3 4 5 6 7 8
Go to End
Author Topic: 11337 Views
  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Sphinx 0.1: $SphinxSearchForm / no enabled local indexes to search Link to this post

    Hi Enclave,

    it really depends how your data objets are related to the holder page. If they are attached to a holder page (i.e. managed via a DataObjectManager) then you can use that relation for example:

    static $has_one = array(
    'ComplaintsHolder' => 'ComplaintsHolder'
    );

    function Link(){

    $Holder = $this->ComplaintsHolder();

    $Link = $Holder->Link() . 'retrieve_case/' . $this->ID;

    return $Link;

    }

    I think that should work, perhaps it didn't like constructing the link on return, I vaguely remember having that issue before.

    If your DO are not attached to holders directly then you need to fetch the Holder using a DataObject::get() or another method.

    Thanks for the advice getting mine working, I will give it a try in the office tomorrow.

    Aram

  • Enclave SSC
    Avatar
    Community Member
    31 Posts

    Re: Sphinx 0.1: $SphinxSearchForm / no enabled local indexes to search Link to this post

    Thanks @aram. As you posted I updated my post.

    ** I need to somehow call the ID from my page search in this Link function on my dataobject decorator. Then I need to get dataobject by ID. How can I call the ID from the page_controller search function in this link function? ** My total lack of PHP and OO programming is letting me down.

    You see via my page search function I am searching using sphinx and finding my dataobjects returned directly to Page_results.ss. They are just not linked correctly .

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Sphinx 0.1: $SphinxSearchForm / no enabled local indexes to search Link to this post

    Hi Enclave,

    That function I posted should be placed in your DataObject, it will then return the correct link when it is rendered on the Page_results page. As it is rendered the results control loop is inside the DO so the function needs to reference it's own objects ID, hence the $this->ID bit at the end.

    I'm pretty sure that is how it's done, but Mark may know better

    Aram

  • Enclave SSC
    Avatar
    Community Member
    31 Posts

    Re: Sphinx 0.1: $SphinxSearchForm / no enabled local indexes to search Link to this post

    Great @aram. I now understand it 100%.

    Although using this, as placed in my DO decorator always only returns the last ID and not the one I want for the specific result:

    function Link(){
       $case = DataObject::get_one("DecidedCase");
       return Director::baseURL() . 'cases/' . $case->Type . '/retrieve_case/' . $case->ID;
    }

    $this->ID returns no ID

    function Link(){
       $case = DataObject::get_one("DecidedCase");
       $link = $case->Link() . 'cases/' . $this->Type . '/retrieve_case/' . $this->ID;
       return $link;
    }

    The above throws me a blank page with nothing on it. Something dies but nothing in error log. This should be a simple task and I'm failing

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Sphinx 0.1: $SphinxSearchForm / no enabled local indexes to search Link to this post

    Hi Enclave

    this should not be in your decorator, it should be in your actual data object, and you should be using the DataObject::get_one() to get the holder, not the DO itself, we are in the DO so all we need to do to return that is $this.

    I think the function in my more recent post is closer to what you want.
    You need to grab the page that displays the DO, and then append the rest of the link onto the end of that pages Link() function, which is what that function I wrote did. so using what I understand of your names it should be something like this:

    class DecidedCase extends DataObject
    {
       static $has_one = array(
          'CaseHolder' => 'CaseHolder'
       );   

       //Function to create the link to THIS particular Object
       function Link(){
          
          //This is the page that can display the DO and which it is accociated
          $Holder = $this->CaseHolder();
          
          $Link = $Holder->Link() . 'retrieve_case/' . $this->ID;
          
          return $Link;
       }

       //Other stuff in the DataObject

    }

    If you still cant get it to work, paste the code for both the holder and the DO in something like pastie.com.

    Aram

  • Enclave SSC
    Avatar
    Community Member
    31 Posts

    Re: Sphinx 0.1: $SphinxSearchForm / no enabled local indexes to search Link to this post

    UPDATE: Thanks a million aram. I got it working!!!

    Now just to index files and I am one happy noob

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Sphinx 0.1: $SphinxSearchForm / no enabled local indexes to search Link to this post

    EDIT: lol just seen your last post, great news Ill let you know if I get mine going!

    Hi Enclave,

    try this: http://pastebin.com/ci3nSgqH

    I removed the relationships altogether as they were not needed (i'm guessing ur using ModelAdmin for managing complaints, then rendering them based on Type?).

    So the Link() function grabs a holder based on type then builds the link off that.

    Aram

  • Enclave SSC
    Avatar
    Community Member
    31 Posts

    Re: Sphinx 0.1: $SphinxSearchForm / no enabled local indexes to search Link to this post

    @aram Thanks for all the help, shout if you need any with the sphinx process.

    @mark I pasted my DO code here: http://pastebin.com/TkMuT7hL

    I still cannot manage to index 'Document' => 'File' on my DecidedCases DO. FileContentCache remains clear. I am not sure if my relationships are setup correctly or whether I am understanding the application of your code incorrectly.

    11337 Views
Page: 1 2 3 4 5 6 7 8
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.