Forum

Thread tagged as: Question, Problem, Blog

Perch Runway/Blog search result URL isn't working

I've set up multiple blogs in my Perch Runway install, so my Blog post page path is:

/{blogSlug}/{postSlug}

The blogs are working fine, page listings link through to the individual posts fine.

I've now set up a Search results page with the following:

<perch:before>
<div class="row">
    <div class="container">
        <div class="eight columns">
                <h1>Search results for “<perch:search id="search_key">”</h1>

                <perch:if exists="paging">
                    <p><perch:search id="total"> results</p>
                </perch:if>
                    <ul class="plain">
</perch:before>

                <li class="<perch:search id="perch_item_odd">">
                    <h3><a href="<perch:search id="result_url">"><perch:search id="result_title"></a></h3>
                    <perch:if exists="result_excerpt"><p class="excerpt">…<perch:search id="result_excerpt" encode="false">…</p></perch:if>
                    <p><a href="<perch:search id="result_url">">
                        <perch:if exists="result_pageNavText">
                            <perch:search id="result_pageNavText">
                        <perch:else />
                            <perch:search id="result_url">
                        </perch:if>
                        </a></p>
                </li>

<perch:after>
    </ul>
    <perch:if exists="paging">
        <div class="paging">
            Page <perch:search id="current_page"> of <perch:search id="number_of_pages">
            <perch:if exists="not_first_page">
                <a href="<perch:search id="prev_url" encode="false">">Previous</a>
            </perch:if>
            <perch:if exists="not_last_page">
                <a href="<perch:search id="next_url" encode="false">">Next</a>
            </perch:if>
        </div>
    </perch:if>
        </div>
    </div>
</div></perch:after>


<perch:noresults>
    <perch:if exists="search_key">
        <h1>Search results for “<perch:search id="search_key">”</h1>
    <perch:else />
        <h1>Search</h1>
    </perch:if>
    <perch:if exists="search_key">
        <p>Sorry, there are no results for “<perch:search id="search_key">”.</p>
    </perch:if>
</perch:noresults>

The search form, which works fine, is:

<perch:form id="search" method="get" action="/search_results">
    <div>
        <perch:label for="q">Search</perch:label>
        <perch:input type="search" id="q">
        <perch:input type="submit" value="Go">
    </div>
</perch:form>

However, when the search results are displayed, the URL for the blog post is just the slug, minus the blog path and date. They display in the resulting code as (for example):

<a href="//the-gina-monologues-on-building-my-own-maternity-program">

I'm sure I'm missing something obvious, but I've combed through the search documentation and the forum and haven't found an answer. Help?

Timothy Swan

Timothy Swan 0 points

  • 3 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

What do you get if you enable debug?

I get

Debug Message - Perch Runway 3.1.1
[39] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM perch3_pages p LEFT JOIN perch3_page_routes pr ON p.pageID=pr.pageID LEFT JOIN perch3_settings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM perch3_page_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
Matched page: /search_results, so not using routes.
Using master page: /templates/pages/search_display.php
[34] SELECT DISTINCT settingID, settingValue FROM perch3_settings WHERE userID=0
[1] SELECT * FROM perch3_pages WHERE pagePath='/search_results' LIMIT 1
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
Using sub-template: /templates/pages/attributes/social.html
[3] SELECT regionKey, regionHTML FROM perch3_content_regions WHERE regionPage='/search_results' OR regionPage='*' ORDER BY regionPage DESC
Search term: platform curates market-leading
[10] SELECT SQL_CALC_FOUND_ROWS DISTINCT 'PerchContent_SearchHandler' AS source, MATCH(ci.itemSearch) AGAINST('platform curates market-leading') AS score, r.regionPage AS col1, ci.itemSearch AS col2, ci.itemJSON AS col3, r.regionOptions AS col4, p.pageNavText AS col5, p.pageTitle AS col6, regionTemplate AS col7, r.regionKey AS col8 FROM perch3_content_regions r, perch3_content_items ci, perch3_pages p WHERE r.regionID=ci.regionID AND r.regionRev=ci.itemRev AND r.pageID=p.pageID AND r.regionPage!='*' AND r.regionSearchable=1 AND (MATCH(ci.itemSearch) AGAINST('platform curates market-leading') OR MATCH(ci.itemSearch) AGAINST('platform curates market-leading') ) AND (r.regionPage LIKE '/%') UNION SELECT 'PerchContent_RunwaySearch' AS source, MATCH(ci.itemSearch) AGAINST('platform curates market-leading') AS score, c.collectionKey AS col1, ci.itemSearch AS col2, ci.itemJSON AS col3, c.collectionOptions AS col4, c.collectionKey AS col5, c.collectionKey AS col6, collectionTemplate AS col7, c.collectionKey AS col8 FROM perch3_collections c, perch3_collection_items ci, perch3_collection_revisions cr WHERE c.collectionID=cr.collectionID AND cr.itemID=ci.itemID AND cr.itemRev=ci.itemRev AND c.collectionSearchable=1 AND cr.itemSearchable=1 AND (MATCH(ci.itemSearch) AGAINST('platform curates market-leading') OR MATCH(ci.itemSearch) AGAINST('platform curates market-leading') ) UNION SELECT 'PerchBlog_SearchHandler' AS source, MATCH(postTitle, postDescRaw, postTags) AGAINST('platform curates market-leading') AS score, postTitle, postSlug, postDateTime, postDescHTML, postID, sectionSlug, "", "" FROM perch3_blog_posts p, perch3_blog_sections s WHERE postStatus='Published' AND postDateTime<'2018-05-23 21:08:43' AND p.sectionID=s.sectionID AND MATCH(postTitle, postDescRaw, postTags) AGAINST('platform curates market-leading') ORDER BY score DESC LIMIT 0, 10
[73] SELECT FOUND_ROWS() AS `count`
[10] Using template: /templates/search/search-result.html
Request time: 0.1602
Process time: 0.1597
Memory: 1.5178
Drew McLellan

Drew McLellan 2638 points
Perch Support

It sounds like the blog slug isn't making it through to the search results template. Do you see it at all with <perch:showall> ?

No, the blog slug isn't making it through, though I haven't seen anything in the documentation about how the blog slug is used in conjunction with <perch:search id="result_url">. How is the link in the search results created using "result_url", and where are the two slashes coming from in the URL that us being created?

With perch:showall I see:

ID  Value
perch_page_path /search_results
url //natural-methods-to-manage-labor-pain
title   Natural Methods To Manage Labor Pain
excerpt Our friends at Boston NAPS—a private nursing company and team of qualified Registered Nurses that{...}
key saves your company time, helps you
source  PerchBlog
result_url  //natural-methods-to-manage-labor-pain
result_title    Natural Methods To Manage Labor Pain
result_excerpt  Our friends at Boston NAPS—a private nursing company and team of qualified Registered Nurses that{...}
result_key  saves your company time, helps you
result_source   PerchBlog
search_key  saves your company time, helps you
paging  true
total   88
number_of_pages 9
total_pages 9
per_page    10
current_page    1
lower_bound 1
upper_bound 10
prev_url    
next_url    /search_results?q=saves+your+company+time%2C+helps+you+&page=2
prev_page_number    
next_page_number    2
first_page_url  /search_results?q=saves+your+company+time%2C+helps+you+
last_page_url   /search_results?q=saves+your+company+time%2C+helps+you+
first_page  true
not_last_page   true
perch_item_last true
perch_item_zero_index   9
perch_item_index    10
perch_item_rev_index    1
perch_item_rev_zero_index   0
perch_item_odd  odd
perch_item_count    10
perch_index_in_set  10
perch_zero_index_in_set 9
perch_namespace perch:search

Any idea why the blog slug wouldn't be making it through to the search result_url?