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.

setting up search results - simple

February 10, 2011 4:56pm

Subscribe [7]
  • #1 / Feb 10, 2011 4:56pm

    grounded

    138 posts

    Hello, I am trying to setup a search box in the header of my website, and I’m confused as to where to place the search results tag. I am using the simple code in the header:

    {exp:search:simple_form channel="news"}
    <label for="keywords">Search </label><input type="text" name="keywords" id="keywords" value="" size="18" maxlength="100" /><input type="submit" value="submit" class="submit" > {/exp:search:simple_form}

     

    i am using search-results code:

    <table border="0" cellpadding="6" cellspacing="1" width="100%">
    
    <tr>
    
    <th>{lang:title}</th>
    
    <th>{lang:excerpt}</th>
    
    <th>{lang:author}</th>
    
    <th>{lang:date}</th>
    
    <th>{lang:total_comments}</th>
    
    <th>{lang:recent_comments}</th>
    
    </tr>
    
    {exp:search:search_results switch="resultRowOne|resultRowTwo"}
    
    <tr class="{switch}">
    
    <td width="30%" valign="top"><b><a href="http://{auto_path}">{title}</a></b></td>
    
    <td width="30%" valign="top">{excerpt}</td>
    
    <td width="10%" valign="top"><a href="http://{member_path=member/index}">{author}</a></td>
    
    <td width="10%" valign="top">{entry_date format="%m/%d/%y"}</td>
    
    <td width="10%" valign="top">{comment_total}</td>
    
    <td width="10%" valign="top">{recent_comment_date format="%m/%d/%y"}</td>
    
    </tr>
    
    {/exp:search:search_results}
    
    </table>
    
    {if paginate}
    
    <div class='paginate'>
    
    <span class='pagecount'>{page_count}</span>  {paginate}
    
    </div>
    
    {/if}


    What is the proper method to display the search results? Where dodi need to place the search-results tag?

    Moved to CodeShare Corner by Moderator

  • #2 / Feb 10, 2011 7:49pm

    Cheif

    626 posts

    You should read the “simple search” entry in the instructions.

    Basically you need to redirect the results to another group/template and on that template use the results tag.

    http://ellislab.com/expressionengine/user-guide/modules/search/simple.html#par_result_page

  • #3 / Feb 10, 2011 8:57pm

    grounded

    138 posts

    Thanks you, setting up now… will let you know how it goes

  • #4 / Feb 11, 2011 10:53am

    Ingmar

    29245 posts

    Very good, please do keep us in the loop. Thanks.

  • #5 / Feb 16, 2011 2:57pm

    grounded

    138 posts

    OK, so no luck yet. This is what I am doing:

    I have a search field in my header.
    Search field code:

    {exp:search:simple_form channel="About|commercialization|economicImpact|pressreleasearchive|Research|facilities|events|nanonetwork|"}
            
    
        
    <label for="keywords">Search:</label><input type="text" name="keywords"  result_page="home/searchresults"   id="keywords" value="" size="18" maxlength="100" />
    <input type="submit" value="submit" class="submit" />
    
        
    
    {/exp:search:simple_form}

    1. The results are not going to my specified page of ‘home/searchresults’ they are going to the default ‘search/results’ page, (which pops up my ‘404’ page i have set in my global preferences)

    2. if I enter in giberish, i do get a :

    Search Results:

    Your search did not return any results.
    Return to Previous Page
    message

    In the results page, I have the following code the results code:

    <table border="0" cellpadding="6" cellspacing="1" width="100%">
    
    <tr>
    
    <th>{lang:title}</th>
    
    <th>{lang:excerpt}</th>
    
    <th>{lang:author}</th>
    
    <th>{lang:date}</th>
    
    <th>{lang:total_comments}</th>
    
    <th>{lang:recent_comments}</th>
    
    </tr>
    
    
    
    {exp:search:search_results switch="resultRowOne|resultRowTwo"}
    
    
    
    <tr class="{switch}">
    
    <td width="30%" valign="top"><b><a href="http://{auto_path}">{title}</a></b></td>
    
    <td width="30%" valign="top">{excerpt}</td>
    
    <td width="10%" valign="top"><a href="http://{member_path=member/index}">{author}</a></td>
    
    <td width="10%" valign="top">{entry_date format="%m/%d/%y"}</td>
    
    <td width="10%" valign="top">{comment_total}</td>
    
    <td width="10%" valign="top">{recent_comment_date format="%m/%d/%y"}</td>
    
    </tr>
    
    
    
    {/exp:search:search_results}
    
    
    
    </table>
    
    
    
    {if paginate}
    
    
    
    <div class='paginate'>
    
    
    
    <span class='pagecount'>{page_count}</span>  {paginate}
    
    
    
    </div>
    
    
    
    {/if}

    Any ideas why this is not working for me?

  • #6 / Feb 16, 2011 3:16pm

    mz91184

    100 posts

    I am pretty sure your “results_page” tag was in the wrong place.

    Try this.

    {exp:search:simple_form channel="About|commercialization|economicImpact|pressreleasearchive|Research|facilities|events|nanonetwork|" result_page="home/searchresults" }
            
    
    <label for="keywords">Search:</label><input type="text" name="keywords"   id="keywords" value="" size="18" maxlength="100" />
    <input type="submit" value="submit" class="submit" />
    
        
    
    {/exp:search:simple_form}
  • #7 / Feb 16, 2011 3:48pm

    grounded

    138 posts

    Great! I am able list the documents from the site that match the search criteria.
    There seems to be an issue now with getting those links to those pages to properly load the page though….

    For instance my search results load the wrong page URL..

    When I click on the link for the search result, it loads:(looks like page title ammended to the basic onami.us/index.php/...
    http://www.onami.us/index.php/safer_nanomaterials_and_nano_manufacturing

    When the real page URL is:
    http://www.onami.us/index.php/research/snni

    Is there a setting i need to change to load that pages’ ‘real’ URL?

  • #8 / Feb 16, 2011 3:55pm

    mz91184

    100 posts

    Use a If or Switch statement to accomplish the correct urls.

    {if channel_short_name == 'example_channel_name'}
    
    {if:elseif channel_short_name == 'example_channel_name2'}
    
    {if:else}
    
    {/if}

    This make sense?

  • #9 / Feb 16, 2011 4:04pm

    grounded

    138 posts

    I think i understand the concept, but kind of confused on the syntax .. so, for my example listed above, (if the channel for that page is in my ‘research’ channel,
    could you give me an example of how I would plug my info into that ‘IF’ statement?

    my example was :

    When I click on the link for the search result, it loads:(looks like page title ammended to the basic onami.us/index.php/...
    <a href="http://www.onami.us/index.php/safer_nanomaterials_and_nano_manufacturing">http://www.onami.us/index.php/safer_nanomaterials_and_nano_manufacturing</a>
    
    When the real page URL is:
    <a href="http://www.onami.us/index.php/research/snni">http://www.onami.us/index.php/research/snni</a>

    thanks again,

  • #10 / Feb 16, 2011 4:22pm

    mz91184

    100 posts

    I think this should do it.

    {if channel_short_name == 'research'}
        <a href="http://{title_permalink=research}">{title}</a>
    {if:elseif channel_short_name == 'other-channel'}
        <a href="http://{title_permalink=other-channel}">{title}</a>
    {if:else}
        <a href="http://{title_permalink}">{title}</a>
    {/if}
  • #11 / Feb 16, 2011 6:51pm

    grounded

    138 posts

    Sorry another question - So where do I stick this code then? In the results I would assume, but where in the results?

  • #12 / Feb 16, 2011 7:38pm

    mz91184

    100 posts

    Maybe this?

    <table border="0" cellpadding="6" cellspacing="1" width="100%">
    
    <tr>
    
        <th>{lang:title}</th>
        
        <th>{lang:excerpt}</th>
        
        <th>{lang:author}</th>
        
        <th>{lang:date}</th>
        
        <th>{lang:total_comments}</th>
        
        <th>{lang:recent_comments}</th>
    
    </tr>
    
    {exp:search:search_results switch="resultRowOne|resultRowTwo"}
    
        <tr class="{switch}">
        
        <td width="30%" valign="top"><b>
            {if channel_short_name == 'research'}
                <a href="http://{title_permalink=research}">{title}</a>
            {if:elseif channel_short_name == 'other-channel'}
                <a href="http://{title_permalink=other-channel}">{title}</a>
            {if:else}
                <a href="http://{title_permalink}">{title}</a>
            {/if} 
        </b></td>
        
        <td width="30%" valign="top">{excerpt}</td>
        
        <td width="10%" valign="top"><a href="http://{member_path=member/index}">{author}</a></td>
        
        <td width="10%" valign="top">{entry_date format="%m/%d/%y"}</td>
        
        <td width="10%" valign="top">{comment_total}</td>
        
        <td width="10%" valign="top">{recent_comment_date format="%m/%d/%y"}</td>
        
        </tr>
    
    {/exp:search:search_results}
    
    </table>
  • #13 / Feb 16, 2011 8:09pm

    grounded

    138 posts

    no, the only thing that did was repeat the title information into the excerpt collumn..

  • #14 / Feb 16, 2011 8:22pm

    grounded

    138 posts

    also, there is no ‘excerpt’ summary that is populating that column, do you know how I adjust the parameters for the excerpt summary?

  • #15 / Feb 16, 2011 8:26pm

    mz91184

    100 posts

    Pretty sure this is where you set the search except -  Admin -> Channel Administration -> Channels -> Edit Preferences -> Administrative Preferences

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

ExpressionEngine News!

#eecms, #events, #releases