ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

identify custom fields in search results

November 07, 2011 7:53am

Subscribe [4]
  • #1 / Nov 07, 2011 7:53am

    Transparency

    7 posts

    Hi everybody,
    I’m quite new to EE, but already a very big fan. It beats the pants off of CMSs I’ve been working with lately.

    I am having a problem with the native search, though, and hope somebody out there can give me a bit of assistance.

    I have a channel with several custom fields for text input, and I’m using a template within a template group to display each of these custom fields individually, accessed through a tabbed listing at the top of the template group index page.
    The setup is basically:

    /guide/intro
    /guide/context
    /guide/data

    and so on. Everything is stored in a “guide” channel entry, in custom fields for intro, data, etc. I though this would be a nice way to do things, until I tried to fire up searchability. As you can probably guesss, when I get a hit on a search, it’s the channel entry as a whole that is found, rather than one of the “sub-sections”.

    Is there anyway to be told by the search which custom field returned the result, so that I can link to the appropriate sub-section of my guide?

    My thanks in advance for any guidance on this.

    Andy

  • #2 / Nov 07, 2011 7:06pm

    Sean C. Smith

    3818 posts

    Hi Andy,

    Welcome to the forums, we’re glad to have you here.

    Could you clarify exactly what you are trying to do here. It’s a little unclear and before offering a solution, I’d like to be 100% certain about what you expect/want to happen and what is actually happening. If you could post up relevant template code and a link to a live site (if possible) that would be very helpful.

    Sean

  • #3 / Nov 18, 2011 10:15am

    Transparency

    7 posts

    Hi Sean,

    please forgive my not having answered you much sooner. I’ve been under some deadline pressure and pushing forward without looking back. I’m afraid this all got lost in the shuffle.

    I was so pressured to meet a deliverable date that I simply re-engineered some things and found a different way to achieve what I was aiming at, so the exact details of what I alluded to earlier are no longer pertinent. But for the sake of closure, I’ll restate the core of my question, so that it’s documented in case it ever comes up for anybody else:

    When using the EE native search and then displaying the results, is it possible to identify which custom field in the resulting “hit” on a channel entry actually triggered the hit?

    And while I’m here and we’re talking about the native search, I’m really curious as to why a decision was made to strip the $_POST array after processing. I can see that the array is still available, but it’s been emptied so there is no way for me to pass myself any useful information from the sending form.

    Actually, I have several questions, but it would be wrong to just shotgun them all into this post, and perhaps a bit tedious creating a dozen new posts for potentially trivial questions. Is there any possibility of private communication for something like this?

    Andy

  • #4 / Nov 21, 2011 6:46pm

    Sean C. Smith

    3818 posts

    Andy,

    Unfortunately it is not possible to identify which field search has found, but I did a quick search on Devot://ee and found an add-on that looks like it could help you out: Search Fields.

    Re: $_POST I’m not exactly sure why it strips the array, but it may be because search results are cached and the page pulls them from cache. In any case I’m going to alert a dev to come in and answer that question for you.

    Sean

  • #5 / Nov 29, 2011 11:20am

    Robin Sowell

    13255 posts

    Sorry for the delay, Andy.  In the search module, EE’s not actually stripping the post data, but I suspect what you’re seeing is a result of the fact it redirects after the search- and thus the post array is lost.

    If you take a look at mod.search.php in system/ee/modules/search/ around line 316 you’ll see the final outcome of a successful search:

    $path = $this->EE->functions->remove_double_slashes($this->EE->functions->create_url(trim_slashes($this->_meta['result_page'])).'/'.$hash.'/');
      
      print_r($_POST); exit;
      
      return $this->EE->functions->redirect($path);

    Heh- well, the print/exit won’t be there.  But if you dump the post array there it’s still populated.  And if were EE to continue to normal termination, the next step would be a redirect to the designated result page, which is where the post is lost.  This is standard proceedure for EE frontend form processing- it ends with either a user message or a redirect to a specified result page.

    That help clarify?

  • #6 / Dec 02, 2011 1:56pm

    Kevin Smith

    4784 posts

    Andy,

    Did Robin’s explanation help clarify things for you?

  • #7 / Dec 22, 2011 2:29am

    Transparency

    7 posts

    @Sean,
    thank you for your answer and the plugin tip. The plugin looks interesting, but it doesn’t look like it going to address my original problem. No worries, I’ve worked around things by changing the makeup of my template groupings.

    @Robin, @Kevin,
    thank you both for your guidance here, it’s very much appreciated.
    I was intending to have a closer look at the actual code in EE, as well as digging into codeigniter, but sadly the next big project has just been handed over with a rush on it and all my reading time has vanished… <sigh>

    Just a quick scan of my deliverables list shows me at least one larger plugin I’m going to need, and I absolutely won’t be able to fit that into things. Can the core team be approached about plugin devel, or is that something for which I’ll need to turn to the community?

    Andy

  • #8 / Dec 23, 2011 3:42pm

    Dan Decker

    7338 posts

    Andy Kelly,

    If you are looking for custom add-on development, be sure to look into the awesome Pro Network! There are plenty of developers listed there that can help with your custom code.

    Is there anything else we can assist you with?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases