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.

Problem with Search and Ampersands

January 21, 2009 6:36pm

Subscribe [1]
  • #1 / Jan 21, 2009 6:36pm

    Jake Liddell

    6 posts

    Hi all,

    I’ve got a website page that uses ampersands.  You can see it live here:

    http://brandspace.co.uk/spaces/detail/p_and_o/

    If you view the source, EE has properly escaped all the ampersands in the text.

    If I use the search box, and search for P&O, I get no results.  But if I search for

    P&O

    , I get the two results I’d expect.  The search isn’t translating the ampersand before searching (or perhaps it is, but shouldn’t!)?  Any idea how I can get it to find the results when the user types in P&O?

    Thanks a lot,
    Jake.

  • #2 / Jan 21, 2009 8:35pm

    Greg Aker

    6022 posts

    Jake:

    Are you using something like TinyMCE, or another editor to input your entries?

  • #3 / Jan 21, 2009 8:38pm

    Jake Liddell

    6 posts

    No.  The title of the weblog post is just a text box field, and the content fields have the built-in xhtml processing setting.

  • #4 / Jan 21, 2009 8:53pm

    Greg Aker

    6022 posts

    Jake,

    In your title field, are you using & amp; or just the & when you author the entry.

  • #5 / Jan 25, 2009 6:11pm

    Jake Liddell

    6 posts

    It’s currently

    P&O

    in the title field of the weblog.

  • #6 / Jan 26, 2009 1:03pm

    Greg Aker

    6022 posts

    Jake:

    ExpressionEngine will convert P&O to the proper markup of

    P&O

    when it’s rendered on the screen.  So if you leave it like that, you can search for P&O and return results.  Make sense?

    -greg

  • #7 / Jan 26, 2009 2:08pm

    Jake Liddell

    6 posts

    Hi Greg,

    So, I’ve changed it so that the title is now

    P&O

    The search result still doesn’t find it.  But if I look at the source produced for the page, I’m using {title} in 3 different places, and only the actual <title> has been properly encoded - the :

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html >
    <head profile="http://gmpg.org/xfn/11">
    <title>P&O | Spaces | Brandspace</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    </head>
    
    <body id="brandspace-co.uk" class="spaces">
    
    
    <div id="container">
    
    <div id="branding">
    <h1><a href="http://brandspace.co.uk/" title="Home page">Brandspace</a></h1>
    
    <ul>
    <li><a href="http://brandspace.co.uk/about_us/">About us</a></li>
    <li><a href="http://brandspace.co.uk/news/">News</a></li>
    <li><a href="http://brandspace.co.uk/contact_us/">Contact us</a></li>
    <li><form method="post" action="http://brandspace.co.uk/"  >
    
    <div class="simple-search"><label for="keywords">Search:</label><input type="text" name="keywords" id="keywords" value="" size="18" maxlength="100" />
    <input type="submit" value="search" class="submit" />
    </div></form></li>
    </ul>
    
    </div>
    
    <div id="nav_main">
    <ul>
    <li><a href="http://brandspace.co.uk/spaces/">Looking for Venues?</a></li>
    <li><a href="http://brandspace.co.uk/case_studies/">Case Studies</a></li>
    <li><a href="http://brandspace.co.uk/our_services/">Our Services</a></li>
    <li><a href="http://brandspace.co.uk/our_services/promotional_space_management/property_owners/">Property Owner?</a></li>
    </ul>
    </div>
    
    <div id="content">
    <div id="content_main">
    
    
    
    <ul id="breadcrumb">
    <li><a href="http://brandspace.co.uk/">Home ></a></li>
    <li><a href="http://brandspace.co.uk/spaces/">Search for spaces ></a> </li>
    <li>P&O</li>
    </ul>
    
    <h2>P&O</h2>
    
    <p>P&O Ferries boasts the largest fleet of ships offering a wide range of services and facilities, the most comprehensive route network and the most frequent passenger and freight services to the Continent.</p>
    
    <p>

    That li in the breadcrumb and the following h2 are both being derived from the {title}, but they aren’t encoded correctly.  Here’s the code for the template:

    <?
    session_start();
    ?>
    {embed=includes/head title="{exp:weblog:entries limit="1"}{title}{/exp:weblog:entries} | Spaces | Brandspace" bodyclass="spaces" quote=""}
    
    <div id="content">
    <div id="content_main">
    
    {exp:weblog:entries weblog="spaces"}
    
    <ul id="breadcrumb">
    <li><a href="http://{homepage}">Home ></a></li>
    <li><a href="http://{path=spaces}">Search for spaces ></a> </li>
    <li>{title}</li>
    </ul>
    
    <h2>{title}</h2>
    
    <p>{intro}

    That’s why I originally put in the full version - so it got encoded everywhere I used {title}.  Any ideas?

    Cheers,
    Jake.

  • #8 / Jan 26, 2009 2:12pm

    Greg Aker

    6022 posts

    Jake:

    I’d probably use the Find & Replace plugin on the other areas to make them encode correctly.

    What version and build of ExpressionEngine are you running?

  • #9 / Jan 26, 2009 2:23pm

    Jake Liddell

    6 posts

    No, what I mean is that I’m using {title} in three places, and one is getting encoded correctly, and the other two are not.

    It’s build 1.6.4

  • #10 / Jan 26, 2009 2:31pm

    Greg Aker

    6022 posts

    Jake,

    You’re a couple versions behind.  Can you please update to 1.6.7 to blow the dust off, and we can see if the behavior changes.

    Thanks,

    -greg

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

ExpressionEngine News!

#eecms, #events, #releases