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.

Help with search results

December 19, 2010 4:27pm

Subscribe [7]
  • #1 / Dec 19, 2010 4:27pm

    Mark Jackson

    60 posts

    I’m adding search to a client site. At the moment I have the default search results page - just while I’m testing.
    What I can’t fathom is how do you get the results page to show urls to an entry in a categorized weblog.

    For example, I have a downloads weblog that is categorized: SOA, EAM, and PD with entries assigned to each category.

    What do I need to add to the search result page to pull the url that points to the individual page: www(dot)mysite(dot)com/download/category/soa/soa1/

    Will the same results page work with weblogs that have no categories?

    Do I have to provide some logic that tests for categories or not.

    Thanks in advance

    Regards

    Mark Jackson

  • #2 / Dec 20, 2010 4:07pm

    Ingmar

    29245 posts

    What do I need to add to the search result page to pull the url that points to the individual page: www(dot)mysite(dot)com/download/category/soa/soa1/

    Will the same results page work with weblogs that have no categories?

    Yes. That said, the default is to link to a single entry page, i.e. not using the “category” indicator in your result URL.

    Do I have to provide some logic that tests for categories or not.

    How would the returned URLs differ?

  • #3 / Feb 03, 2011 5:37am

    Mark Jackson

    60 posts

    Hello

    I’m still confused by the search module configuration.

    Here’s my scernario:

    The site has a weblog, amongst others, called “download” Entries to to downloads are categorized:

    (Category group 4): Downloads
    (Category ID 9) Datasheet
    -> (sub Category ID 14) SOA
    -> (sub Category ID 15) EAM
    -> (sub Category ID 43) MSOA
    (Category ID 19) Fact sheets
    (Category ID 44) Application Notes

    The URL to a datasheet in (ID 14) is mysite.com/download/category/datasheet/soa/datasheet1.pdf

    However, when I use the search module “out-of-the-box” and search for datasheet1, the results return a url of mysite.com/download/datasheet1.pdf

    As I expect, clicking this link returns a 404 page, as “/category” and segments “/datasheet/soa/” are missing in the returned search url.

    How do I get the search module to recognise the category segment(s) and include it the search url?

    Thanks in advance

    Regards

    Mark Jackson

    EE1.6.9

  • #4 / Feb 03, 2011 5:03pm

    Ingmar

    29245 posts

    The URL to a datasheet in (ID 14) is mysite.com/download/category/datasheet/soa/datasheet1.pdf

    That is not standard EE URL structure. The search module does not, by default, link back to category style URLSs. It links back to single entry pages, using the Search Results URL.

    How do I get the search module to recognise the category segment(s) and include it the search url?

    How are you linking to your entry now? You’ll probably need to provide “category” etc. manually.

  • #5 / Feb 03, 2011 5:32pm

    Mark Jackson

    60 posts

    Hello Ingmar

    Interesting. How is that not a standard EE URL structure?

    Does that mean that catgorized items cannot be searched?

    Regards

    Mark

  • #6 / Feb 03, 2011 5:56pm

    Ingmar

    29245 posts

    Can you identify the various parts in this URL for me?
    http://example.com/download/category/datasheet/soa/datasheet1.pdf

    An EE URL normally looks like http://example.com/index.php/group/template/url_title for a single entry. The search will create links for such single entry pages by default.

    Categorized items can be searched, but the link is normally not back to a category page (which is usually an index page, showing all entries of one category) but to a single entry page.

  • #7 / Feb 03, 2011 6:09pm

    Mark Jackson

    60 posts

    Okay, I’ll have a go:

    I’ve removed index.php using .htaccess
    /download/ is the template group
    /category/ is the trigger word
    /datasheet/ is the top level category
    /soa/is a subcategory (an index page showing the avaiable download links)
    /datasheet1.pdf - the file itself

    So should search results return http://example.com/download/category/datasheet/soa/
    and on that page there will be link (the entry) to datasheet1.pdf

    If that’s the case then am I using category incorrectly?

    Regards

    Mark

  • #8 / Feb 04, 2011 11:13am

    Sue Crocker

    26054 posts

    Mark, ignoring the search results page for right now.. what would be the link for a single entry?

    In other words something like:

    http://example.com/index.php/download/datasheet/datasheet1_download where datasheet1_download is the entry that holds the link to the .pdf file.

  • #9 / Feb 04, 2011 11:35am

    Mark Jackson

    60 posts

    Hello Sue

    I think (as you’ve been hinting) this is the problem: I don’t have a single entry page defined.

    For example, http://example.com/download/category/soa/

    shows a table of items with entries with associated links to the pdf files. Clicking the links downloads the associated PDF file, so i never show one entry on a single page.

    I have managed to force the search to return a result by setting the “Search Results URL” for the weblog to

    http://myexample.com/download/category/

    which then tries to use the download index page to show the single entry.

    I’m not sure what to do now…

  • #10 / Feb 05, 2011 3:32pm

    Greg Salt

    3988 posts

    Hi Mark,

    By default unless you have changed its behaviour a weblog entries tag will respond to both a category URL title (like category/soa) or a single entry. So, even though you have categorised these entries each should still have a URL Title that the entries tag will display at /download/single_entry_url_title. The latter form is what the Search module will return by default. If you change the Download Weblog search path preference back to http://yourdomain.com/download/ then this should work. Can you please post the weblog:entries part of your download template?

    Cheers

    Greg

  • #11 / Feb 06, 2011 6:13am

    Mark Jackson

    60 posts

    Hello Greg

    Here’s the portion of the “library” template that displays links to datasheets. I’ve sent you a message with the site URL if you want to look at the section of the site in question.

    Thanks in advance.

    Regards

    Mark Jackson

    {if segment_2=="category" && segment_3=="datasheets"}
    <!-- categorised list of all data sheets -->
    <div class="section">
    <div class="column w8">
    <h3>Datasheets</h3>
    <p>{exp:weblog:categories weblog="downloads" show_empty="no" category_group="4" show="not 80|79|45|11|10|44|19" parent_only="no" disable="member_data|pagination|trackbacks"}<br />
    {if {parent_id}!=0}</p><h4>{exp:weblog:category_heading weblog="downloads"}{category_description}{/exp:weblog:category_heading}</h4>
    <p><table cellpadding="0" cellspacing="0"><br />
    <thead><br />
    <tr><br />
    <th class="w6">Title</th><th>Datasheet</th><br />
    </tr><br />
    </thead><br />
    {/if}<br />
    <tbody><br />
    {exp:weblog:entries weblog="downloads" status="Open" category="{category_id}" sort="desc" track_views="one" disable="member_data|pagination|trackbacks"}<br />
    {if {parent_id}!=0}<br />
    <tr class="{switch='even|odd'}"><br />
    <td>{dl_file_name}</td><br />
    <td><a href="http://{dl_file_location}">{if dl_file_size!=""} {dl_file_size} {dl_file_type}{/if}</a></td><br />
    </tr><br />
    {/if}<br />
    {/exp:weblog:entries}<br />
    </tbody><br />
    </table><br />
    {/exp:weblog:categories}<br />
    </div><br />
    <div class="column w4 nrg"><br />
    {embed="includes/library-navigation"}<br />
    </div><br />
    </div><br />
    {/if}

  • #12 / Feb 07, 2011 4:11am

    John Henry Donovan

    12339 posts

    Mark,

    You can use conditionals in you search results page to show correct href

    {if weblog_short_name == 'downloads'}
    <a href="http://{dl_file_location}">{title}</a>
    {if:else}
    <a href="http://{auto_path}">{title}</a>
    {/if}

    Also your above chunk of code has several nested tags which is not recommended for performance reasons.

    When you get time have a look at this article

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

ExpressionEngine News!

#eecms, #events, #releases