I’m 99.9% sure that the domain you actually load jQuery from has nothing to do with this error, but I’m open to being proven wrong 😊. Are you sure there is no mixing of subdomains happening whatsoever? The error says outright that it’s http://yourdomain.com trying to pull from www.yourdomain.com. What does the error say after you browse to the site using www?
Oh, no you must have misunderstood: it is actually the www. If I open the website with the www it works just fine. If I leave them out it doesn’t. So you were right! It doesn’t really matter where I load jQuery from.
However I don’t like the workaround of forcing the www. Isn’t there something else I can do?
Thanks, Max
I am finishing up integration of this plugin on my site now- and I wanted to check about getting the paths correct for different entries/pages.
I found out that the core search feature {exp:search:search_results…}, I could check if an entry has the ‘page_url’ field set, and use this to generate the path, rather than the {auto_path} variable.
like this:
{if page_url != ""}
<td width="30%" valign="top"><a href="{page_url}">{title}<a></td>
{if:else}
<td width="30%" valign="top"><a href="{auto_path}">{title}<a></td>
{/if}
I’m trying to wrap my head around how this is possible using the live search plugin.
I’m using the Structure module (not pages), to handle my ‘static’ content/pages. I’d like the livesearch to link to the proper {page_url} when appropriate.
I could use some help finding out how to get the {page_url} value into the pi.live_search.php file. I will keep looking into this.
Perhaps this could be a new feature for the next version of this plugin? To pass a parameter into the {exp:live_search:results} call in order to indicate which url to use as the ‘$link_to’ path.
Many thanks!
Rowan
FYI dj-rowan, I answered your question here: http://ellislab.com/forums/viewreply/530472/
@slapshotw - thank you for your help! With a bit of persistance and mucking about, I’ve managed to modify the livesearch plugin to suit my needs.
For the information of anyone wanting to extend this plugin- or Pascal (to maybe add in some more flexibility), here’s what I did.
I have an extensive section of my site based on the Solspace Users module. So- custom profile fields and information about people are displayed like weblog entries.
Queries:
$sql = "SELECT distinct(a.entry_id), a.url_title, a.title, b.blog_url, b.comment_url
FROM exp_weblog_titles a, exp_weblogs b
WHERE a.weblog_id = b.weblog_id
AND a.status != 'closed'
AND (a.expiration_date > '".$LOC->now."' OR a.expiration_date = '0')
AND a.title LIKE '%{$search_phrase}%' AND (b.weblog_id = 3 OR b.weblog_id = 1 OR b.weblog_id = 12 OR b.weblog_id = 4 OR b.weblog_id = 5 OR b.weblog_id = 11)
ORDER BY a.title ASC LIMIT 0,10";
$query = $DB->query($sql);
$membersql = "SELECT distinct(m.member_id), d.m_field_id_4, d.m_field_id_5, d.m_field_id_8 FROM exp_members as m, exp_member_data as d WHERE m.member_id = d.member_id AND (d.m_field_id_4 like '%{$search_phrase}%' OR d.m_field_id_5 like '%{$search_phrase}%' OR d.m_field_id_8 like '%{$search_phrase}%')";
$memberquery = $DB->query($membersql);
I extended the first query to search multiple weblogs (some i did not want searched). For the member query- I am searching name and location fields. Pretty straight forward.
The next issue had to do with accessing the ‘site_pages’ array to find out where to link to with each entry. Thanks to slapshotw, his tip in the ‘Structure’ thread helped me out.
Here’s my code:
global $PREFS;
$site_pages = $PREFS->ini('site_pages');
$data = '[';
foreach($query->result as $row)
{
if (false !== $site_pages
&& isset($site_pages['uris'])
&& isset($site_pages['uris'][$row['entry_id']])
)
{
$path = $site_pages['uris'][$row['entry_id']];
}
else{
$path = $row[$link_to];
}
$data .= '{ "title" : "'.$row['title'].'", "path" : "'.$path.$row['url_title'].'" }, ';
}
foreach($memberquery->result as $mrow){
$data .= '{ "title" : "'.$mrow['m_field_id_4'].' '.$mrow['m_field_id_5'].' ('.$mrow['m_field_id_8'].')", "path" : "/instructors/'.$mrow['member_id'].'" }, ';
}
I hope this helps someone! Thanks for the great plugin Pascal!
cheers,
Rowan
I’ve installed it and got it running on a site I’m working on.
However, I’d love to be able to get it to search 1 custom field as well as the title (or search those fields I mark as ‘searchable’).
Has anyone got any thoughts on how to do this? (I’ve zero php knowledge!).
Thanks Euan
Is this type of configuration susceptible to a type of DOM attack threw that form input? Not sure if my terminology is correct but basically I mean that each time the user adds or minuses a character, there is a round trip to the server DB and then back to client. Is there not a possible load issue here?
Euan, I can help you change the query a bit - do you only want it to search through one weblog (as shown earlier) with an added field? Or do you want it to search all weblogs and the extra field where it exists?
DVB, The autocomplete plugin that this was built on has a client side cache, so only the first few characters should run a query, once the result set is smaller than the cache limit it will be filtered directly from the js. It also has support for the ajaxQueue plugin which will cancel any running requests when a new character is added so as not to flood the server. Adding apc or memcached support might be an option down the road, but not everyone has those 😊 .
where does the following line of code go?
{exp:live_search:results link="comment"}
I dont think I understand how the implementation works. Here is what I did:
1.) upload the pi file to ee plugin folder 2.) add the general jquery link to the head. like so:
<scr*pt src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript" charset="utf-8"></scr*pt>
3.) upload the jquery.livesearch.js to root and add the file to the head like so:
<scr*pt src="mysite.com/jquery.livesearch.js" type="text/javascript" charset="utf-8"></scr*pt>
4.) create a template called livesearch and add the following code:
<?php
global $IN, $DB, $LOC;
if (!$IN->QSTR)
{
exit;
}
$search_phrase =& urldecode($IN->QSTR);
$query = $DB->query("SELECT distinct(a.entry_id), a.url_title, a.title, b.blog_url
FROM exp_weblog_titles a, exp_weblogs b
WHERE a.weblog_id = b.weblog_id
AND a.status != 'closed'
AND (a.expiration_date > '".$LOC->now."' OR a.expiration_date = '0')
AND a.title LIKE '%{$search_phrase}%'
ORDER BY rand() LIMIT 0,10");
if ($query->num_rows == 0)
{
exit('No Results');
}
foreach($query->result as $row)
{
echo '<a href="http://.$rowblog_url">.$row['url_title'].'"]'.$row['title'].'</a>
';
}
?>
5.) Create a new template called test and add teh following: (I copied this from this thread from a post Mark did earlier)
{exp:search:simple_form search_in="everywhere"}
<h2 class="sidetitle">Search</h2>
<input type="text" name="keywords" id="keywords" value="" class="input" size="18" maxlength="100" />
<a href="http://{path=search/index}">Advanced Search</a>
<input type="submit" value="submit" class="submit" /></p>
{/exp:search:simple_form}
<sc*ipt type="text/javasc*ipt">
// The trailing slash is important
$('#keywords').livesearch('{site_url}site/livesearch/');
</sc*ipt>
these are the steps I did. When I go to the test page in the browser it looks like the attached screenshot and nothing happens when I type in the search field.
what am I missing? I also dont quite understand why script is spelled scr*pt ??
Regards, Florian
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.