Jump to:

23581 Posts in 19403 Topics by 2893 members

General Questions

SilverStripe Forums » General Questions » ***SOLVED***Staff Section without individual pages?

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

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

Page: 1 2 3
Go to End
Author Topic: 1634 Views
  • ambient
    Avatar
    Community Member
    123 Posts

    Re: ***SOLVED***Staff Section without individual pages? Link to this post

    Thanks Guys, I'll be looking into Uploadify except for I just noticed the data objects aren't searchable.

    Since the staff section is an important part of the site it has to be searchable. Anybody know of a way to make that happen?
    I've tried Lucene search and Sphinx but their set up is quite complicated and over my head, can't get either working.

    If I can't get this figured out I may just have to forget it and go back to creating individual pages for a few lines of text... pity

  • swaiba
    Avatar
    Forum Moderator
    1796 Posts

    Re: ***SOLVED***Staff Section without individual pages? Link to this post

    I feed bad keep posting this, but it is a quick easy method to include dataobjects into the regular site search...

    http://www.silverstripe.org/customising-the-cms/show/14067#post288644

  • zenmonkey
    Avatar
    Community Member
    528 Posts

    Re: ***SOLVED***Staff Section without individual pages? Link to this post

    Swaiba, just get the, to add it to the recipe's page

  • ambient
    Avatar
    Community Member
    123 Posts

    Re: ***SOLVED***Staff Section without individual pages? Link to this post

    My php is terrible.

    I changed the line:

    $dos = DataObject::get('YOURDATAOBJECT',"FIELD LIKE '".$strSearchQuery."'");

    to the same as the function return DataObject from the data object php file

    $dos = DataObject::get('Staff', "`MyStaffMemberID` = '{$this->ID}'".$strSearchQuery."'");

    And I changed:


    $p = new Page();
    $p->Title = $do->SOMEFIELD;
    $p->URLSegment = 'SOMEURL?POSTVAR='.$do->SOMEFIELD;;
    $p->Content = $do->SOMEFIELD;;
    $p->Name = $do->SOMEFIELD;;
    $p->Relevance = 1;
    $p->CanViewType = 'Anyone';

    To:


    $p = new Page();
    $p = new Page();
    $p->Title = $do->MemberTitle;
    //$p->URLSegment = 'SOMEURL?POSTVAR='.$do->SOMEFIELD;;
    $p->Content = $do->Content;;
    $p->Name = $do->Name;;
    $p->Relevance = 1;
    $p->CanViewType = 'Anyone';

    Am I missing something? I'm getting a 'Couldn't run query' error. Obviously I'm doing something wrong.

  • swaiba
    Avatar
    Forum Moderator
    1796 Posts

    Re: ***SOLVED***Staff Section without individual pages? Link to this post

    $dos = DataObject::get('Staff', "`MyStaffMemberID` = '{$this->ID}'".$strSearchQuery."'");

    I don't follow that at all...

    $dos = DataObject::get('YOURDATAOBJECT',"FIELD LIKE '".$strSearchQuery."'");

    YOURDATAOBJECT = Staff = OK
    FIELD LIKE QUERY = uses a like and it breaks up the search query text to match it against something... e.g. Name LIKE '%bob%

  • ambient
    Avatar
    Community Member
    123 Posts

    Re: ***SOLVED***Staff Section without individual pages? Link to this post

    Sorry, I should have just asked which parts of the code I need to change to get it to work.
    So I'll ask now, which parts of the code I need to change to get it to work?

  • swaiba
    Avatar
    Forum Moderator
    1796 Posts

    Re: ***SOLVED***Staff Section without individual pages? Link to this post

    Mainly those IN CAPITALS - but read on in the thread as stew went throguh the same process

  • ambient
    Avatar
    Community Member
    123 Posts

    Re: ***SOLVED***Staff Section without individual pages? Link to this post

    Duh! Sorry, I didn't see that that post had 2 more pages.

    Okay, making some progress now. It finds the relevant info but in the search results the Found in: and Read more about ""... don't display the name of the page. The links work but it just doesn't display the name of the page. Any idea on what I've done to cause that?

    Heres the current code:

    /////////////////////////////////////////////////////////////
    // Start Custom

    $arrSearchQuery = explode(' ',$form->getSearchQuery());
    $strSearchQuery = '%'.implode('%',$arrSearchQuery).'%';

    $dos = DataObject::get('StaffMember',"(ChamberTitle LIKE '".$strSearchQuery."'"."OR Name LIKE '".$strSearchQuery."'"."OR Business LIKE '".$strSearchQuery."'"."OR Phone LIKE '".$strSearchQuery."'"."OR Email LIKE '".$strSearchQuery."') " );

    //make our our result set
    $dosNewResults = new DataObjectSet();

    if ($dos)
    {
    $arr = $dos->toArray();
    foreach ($arr as $do)
    {
    $p = new Page();
    $p->ChamberTitle = $do->ChamberTitle;
    $p->URLSegment = '/your-chamber/Staff-members/';;
    $p->Content = $do->Description;;
    $p->Name = $do->Name;;
    $p->Business = $do->Business;;
    $p->Phone = $do->Phone;;
    $p->Email = $do->Email;;

    // $p->SearchTerm = $do->SearchTerm;;

    $p->ID = $do->ID;;
    $p->Relevance = 1;
    $p->CanViewType = 'Anyone';
       
       
    $dosNewResults->push($p);
    }
    }
    foreach ($arrSearchQuery as $strSearchQuery)
    {
    $strSearchQuery = '%'.$strSearchQuery.'%';

    //repeat code to do DataOBject::get
    //add to $dosNewResults
    }

    //strip out the html from the results and append them to the results
    //above - so that the ones with things to buy are first
    if ($data['Results']->Count() > 0)
    {
    $arr = $data['Results']->toArray();
    foreach ($arr as $do)
    {
    $do->Content = strip_tags($do->Content);
    $dosNewResults->push($do);
    $dosNewResults->removeDuplicates('URLSegment');
    }
    }

    $data['Results'] = $dosNewResults;
    // End Custom
    /////////////////////////////////////////////////////////////

    return $this->customise($data)->renderWith(array('Page_results', 'Page'));
    }

    1634 Views
Page: 1 2 3
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.