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.

Simple search: mismatch between titles and URLs from static pages

October 03, 2014 4:38pm

Subscribe [3]
  • #1 / Oct 03, 2014 4:38pm

    USC Chan

    81 posts

    This is an odd one. It *feels* like a bug in EE, but if it is a lot of people would be hitting it, which doesn’t seem to be happening, so I’m putting it up here to see if anyone has any thoughts.

    Results from simple searches on a site I manage are hitting frequent issues where the titles of search results don’t match URLs. Specifically, mismatches seem to occur where the URL of a static page is included twice in the search results, once with its page_url, from the Pages module, and again with its title URL, as returned by {auto_path}.

    Here’s a real example of search results from the site. I’ve included the first ten results, both titles and URLs, and numbered them so you can see which title corresponds to which URL:

    [1] Self-Care Among Latinos with Diabetes Studied
    [1] chan.usc.edu/news-and-events/news/usc-researcher-studies-self-care-among-latinos-with-diabetes

    [2] Summer Occupational Therapy and English Program for International Students and Therapists
    [2] chan.usc.edu/academics/summer-english

    [3] Shain Davis, OTD ‘13, MA ‘12
    [2] chan.usc.edu/academics/summer-occupational-therapy-and-english-program-for-international-students

    [4] Chantelle Rice, OTD ‘09, BS-MA ‘08
    [3] chan.usc.edu/about-us/family/shain-davis

    [5] Health and Wellness
    [4] chan.usc.edu/about-us/family/chantelle-rice

    [6] Interdisciplinary Health Fair
    [5] chan.usc.edu/admissions/student-blog/health-and-wellness

    [7] Life Management Series
    [7] chan.usc.edu/academics/continuing-education/life-management-series

    [8] Student Research
    [8] chan.usc.edu/research/student-research

    [9] Occupation Renewal
    [6] chan.usc.edu/admissions/student-blog/interdisciplinary-health-fair

    [10] Our Faculty Expertise
    [10] chan.usc.edu/faculty/expertise

    You can see that things start to go wrong with the 3rd search result, which incorrectly returns the title URL from the *2nd* search result. Here, a single page has returned two separate URLs: the page_url in the 2nd search result, and the title URL in the 3rd. Things continue to be offset until the 7th search result, which is correct. The 9th search result then incorrectly gives the title URL from the 6th search result.

    So, in essence, pages created using the Pages module are sometimes returning two separate URLs in the search results, the page_url, and then the title URL, and this is causing mismatches.

    The code I’m using here is very simple, and doesn’t seem to be leaving room for any problems. The form code is:

    {exp:search:simple_form search_in="entries" results="10" status="open" where="all" channel="about-us|academics|admissions|alumni|campaign|faculty|home|news-and-events|patient-care|research|jobs|news|profiles|student-blog|vacancies" result_page="search/index" no_result_page="search/fail"}
    <input type="text" name="keywords" id="keywords" value="search" maxlength="100" />
    {/exp:search:simple_form}

    And the code to handle the search results is:

    {exp:search:search_results}
    <div class="searchitem">
    <a href="http://{if">{title} →</a>
    <?php echo strip_http("{if page_url}{page_url}{if:else}{auto_path}{/if}"); ?>
    {excerpt}
    </div>
    
    {paginate}
    <div class="paginationcontrols">
    {if "{total_pages}" != 1}Page {current_page} of {total_pages} pages {pagination_links}{/if}
    </div>
    {/paginate}
    {/exp:search:search_results}

    To be clear, this isn’t the result of duplicated channel entries. Single entries are returning multiple URLs. I also tried deleting and re-entering entries, just in case there was some database corruption.

    I’m running EE 2.9.0. (I’ve just checked the release notes for 2.9.1, and I don’t see anything that’s relevant.)

    Thanks for any input.

  • #2 / Oct 03, 2014 9:54pm

    shawnblc

    17 posts

    Is it possible that your channel default status is anything other than “open”?

    Also see:

    where=

    where=“all”
    This parameter allows you to specify how matching in searches are performed. The options are:

    any: results containing any of the specified words will be returned.
    all: only results containing all of the specified words will be returned.
    word: only results containing the exact phrase specified will be returned.
    exact: only results containing the entire matching phrase will be returned.

  • #3 / Oct 06, 2014 2:23pm

    USC Chan

    81 posts

    Is it possible that your channel default status is anything other than “open”?

    Also see:

    where=

    where=“all”
    This parameter allows you to specify how matching in searches are performed. The options are:

    any: results containing any of the specified words will be returned.
    all: only results containing all of the specified words will be returned.
    word: only results containing the exact phrase specified will be returned.
    exact: only results containing the entire matching phrase will be returned.

    Thanks for the reply. The channel default status is indeed “open” on all of the relevant channels, and I don’t think the “where” parameter is related.

    I can narrow down what works for me, and what doesn’t. Testing for {page_url}, as shown below, returns search results with the title/url mismatch that I described in my first post.

    <a href="http://{if">{title} →</a>
    <?php echo strip_http("{if page_url}{page_url}{if:else}{auto_path}{/if}"); ?>

    But if I take out the test, and always display {auto_path}, there is no mismatch.

    <a href="http://{auto_path}">{title} →</a>
    <?php echo strip_http("{auto_path}"); ?>

    It definitely looks like this is related to the handling of {page_url} in the search results.

  • #4 / Nov 21, 2014 1:22pm

    Addison

    59 posts

    I believe I’m having this same problem. The search results are all mis-matched from the results URLs, plus it does indeed seem that entries from the Pages module are slipping in the entry URL instead of the pages URL.

    {exp:search:search_results}
    
        <!-- {channel_short_name} -->
        <div class="search_output group">
    
            <h3>
    
                {if channel_short_name == 'newsroom'}
                    <!-- {channel_short_name} / newsroom -->
                    <a href="/newsroom/{entry_date">_            {if:elseif channel_short_name == 'store'}_                <!-- {channel_short_name} / store -->_                <a href="/store">_            {if:elseif channel_short_name == 'synagogue_tour'}_                <!-- {channel_short_name} / synagogue tour -->_                <a href="/events-and-tours/group-programs/1876-synagogue-tour/virtual">_            {if:elseif channel_short_name == 'testimonials'}_                <!-- {channel_short_name} / testimonials -->_                <a href="/about-us/testimonials">_            {if:elseif page_url}_                <!-- {channel_short_name} / page url -->_                <a href="{page_url}">_            {if:else}_                <!-- {channel_short_name} / auto path -->_                <a href="{auto_path}">_            {/if}__            {if channel_short_name == 'objects_of_the_month'}_                {title}: {object_name}_            {if:else}_                {title}_            {/if}__            <i class="fa fa-caret-right"></i></a>
    
                
            </h3>
    
    <p>        </p>
    
    <p>            <span class="search_excerpt">{excerpt}</span></p>
    
    <p>        </p>
    
    <p>    </div></p>
    
    <p>{/exp:search:search_results}

    This same setup works fine on previous versions of EE, but 2.9.2 is acting strangely.

  • #5 / Nov 21, 2014 1:39pm

    USC Chan

    81 posts

    It took a while, but I did have this accepted as a bug. You can see more details here:

    https://support.ellislab.com/bugs/detail/20653/incorrect-handling-of-page_url-auto_path-in-simple-search-results
    https://support.ellislab.com/bugs/detail/20593/incorrect-handling-of-page_url-in-simple-search-results

    Given the way your code seems to work, I wouldn’t be surprised at all if you’re seeing the same problem. Any time your search results mix static pages and dynamic entries, it’s likely that the tag replacement will get confused. I’m considering what the best workaround solution might be, until the bug gets fixed.

  • #6 / Nov 21, 2014 1:45pm

    Addison

    59 posts

    Good deal. Glad to know I’m not crazy!

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

ExpressionEngine News!

#eecms, #events, #releases