Jump to content

Search the Community

Showing results for tags 'search'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. Hello guys, I am building a sort of an archive. Relatively simple, although I have about 8000 records, each with 15 fields (text, int, images, url). I created a crude search system with a form (emulating the famous Skyscrapper example) to filter through the system. Everything works but it is quite slow... I have 2 questions which are related: 1. How can I search through the database? 2. What is a good practice to display many records like these? ----------------------------------------- 1. I am retrieving the results with $songs = $pages->findMany('template=nk-song'); Then I do a foreach to render them all. I am unsure if that is a good way. If I render all of them on the page, it creates thousands of divs with a bit of text, and this can take a while (10s-15s). 2. This one is even worse :D as every time I retrieve my desired records with something like this: $page->find("field_to_search_through~=my_query_string") I get between 20 and 200, but when I render them I am creating iframes with YouTube videos and that can take up to 10s to finish. I "solved" it by only loading the iframes if they are in view with IntersectionObserver on the client-side. But I feel there is a more precise PHP / ProcessWire approach. Just to clarify, I started doing all of this custom rendering and querying because tools like ElasticSearch or SearchEngine were a bit complicated and I needed a simple to retrieve information and then display it in my own way. Thank you!
  2. If a user searches (frontend) for words with german umlauts like ä, ö, etc. no results are given back. Do you have any solution? Thanks.
  3. Hi all I have a text search based upon Ryans search template. Unfortunately, I can't make it work with Repeater Matrix fields inside repeaters. I have a repeater field called "content_sections" and inside, there's a repeater matrix field called "items". As I understand it, the selector for a textfield inside the repeater matrix should be: content_sections.items.textfield But this does not deliver any results at all. Any ideas anyone? Thanks Roli
  4. Hello, how would I do a multi-language website search with just a selector? I have many multi-lang fields and I want to do a search through all of them at once and through all of their language values. Is there a "selector way" of doing this? Maybe something like `title|title:de|title:it`? It seems I have seen this somewhere a long time ago but can't find in any documentation or forum search... Or the only way of doing it is by running separate searches for each language with output formatting off and then consolidating it all in one single results array? Because I still want to give users a result, even if it is in another language than current $user. Visitors mostly will be searching for specific terms that are very similar in all languages, but might be not used in one language version of a single page, for example. Or the user might not have switched language tohis prefered and did the search first, etc.. (many use cases in my situation) Example: $pages->find('title~='.$q) - maybe different operator is needed? /en/search/?q=visit = 1 results /it/search/?q=visit = 0 results Thanks for any advice!
  5. Hi In my search page, I used a selector like this : $searchQuery = $sanitizer->entities($input->get('q')); $searchQuery = $sanitizer->selectorValue($searchQuery); $selector = 'title|subtitle|summary|html_body_noimg~=' . $searchQuery; $matches = $pages->find($selector); I don't have the same results if $searchQuery contains accent or not. For example, with « bâtiment » I have no result with « batiment » I have onea result : « Les bâtiments et les smart-city » Normally I should have the same results? How can I do that ? Thanks for your help
  6. Hi there! I want to implement a "simple" full text search (no ajax needed) into a webpage that's built with processwire. I couldn't find any threads, tutorials or modules helping with this. Can anyone help me with this or point me to a place where I find information how to implement this? Thanks in advance! Jonas
  7. I have a website with multiple content types that I want to be accessible through search. I really like the live search on processwire.com, that sorts content types while typing. I tried to find the code to recreate this, with no luck. Does anyone know if this is jquery, specific jquery plugins, json/xml cached files, and what kind of PHP code is used? Any tip that point me in the right direction would be much apperciated. The search result listing seems fairly easy to create with sorting through parameters.
  8. Hello everyone! I am trying to add my repeater matrix fields to the search selector, but unfortunately nothing seems to work for me. I have following search code in my search.php: <?php namespace ProcessWire; // look for a GET variable named 'q' and sanitize it $q = input()->get('q'); // sanitize to text, which removes markup, newlines, too long, etc. $q = sanitizer()->text($q); // did $q have anything in it after sanitizing to text? if($q) { // Make the search query appear in the top-right search box. // Always entity encode any user input that also gets output echo '<input id="search-query" value="' . sanitizer()->entities($q) . '">'; // Sanitize for placement within a selector string. This is important for any // values that you plan to bundle in a selector string like we are doing here. // It quotes them when necessary, and removes characters that might cause issues. $q = sanitizer()->selectorValue($q); // Search the title and body fields for our query text. // Limit the results to 50 pages. The has_parent!=2 excludes irrelevant admin // pages from the search, for when an admin user performs a search. $selector = "title|body~=$q, limit=50, has_parent!=2"; // Find pages that match the selector $matches = pages()->find($selector); } else { $matches = array(); } // unset the variable that we no longer need, since it can contain user input unset($q); ?> <main pw-replace='main'> <?php include('./includes/_pageheadersearch.php'); ?> <div id='content-body' class='uk-section uk-section-large uk-section-large'> <div class='uk-container uk-container-small'> <?php // did we find any matches? if(count($matches)) { // yes we did, render them echo ukAlert(sprintf(_n('Found %d page', 'Found %d pages', $matches->count), $matches->count), "default", "check"); echo ukDescriptionListPages($matches); } else { // we didn't find any echo ukAlert(__('Sorry, no results were found'), "danger", "warning"); } ?> </div> </div> </main> I have tried to add my fields to the selector code (repeater_matrix.aboutsblock_repeaters.mytextfield) . But I didn't get any results. What I am doing wrong? Thanks for your help!
  9. Hi all, Hope that there is a quick tip that someone already know... Is it possible to search in multilanguage fields only in the current language values without to search in the default language as fallback? See the quote below. In other words.. I would like to search only in the current language (Dutch), no matter if some of the Dutch language values are empty. Is it possible? Thanks
  10. I want to allow full text search on my site. There is a very nice solution that comes right out of the box: $selector = "title|body~=$q, limit=50"; This works, but to make it even better I would want to give higher weight to pages where the search term occurs in the title, than if it just occurs in the body. After all, a page with the title "Wine from France" is probably the best match for the search "france wine". How do I accomplish this in ProcessWire? I can see three possible paths, but I am not very fond of any of them: Do a direct SQL query, circumventing the API, along these lines. But I would prefer to abstract away the database layout if at all possible. Use something like ElasticSearch, but to be honest that would be to complicated to set up and maintain in the long run. Make multiple lookups, first for matches in the title, then for matches in the body, and merge and sort in PHP. My suspicion is that this would get complicated quite quickly. For instance, how do you deal with a page that has two of the three search terms in the title and the third in the body? Is there a magic option four I should look into? Or are any of the above options better than the others? Any input is welcome!
  11. Hello, I have a search page loosely based on Skyscrapers where I'm parsing a selector with options 'beds', 'bathrooms', 'size' fields. It is working well until I select 'Any' after I've run a search. This is where no results are returned (/?beds=&bathrooms=&size=&submit=). I want it to reset and show all results. I hope this isn't too vague.
  12. Hello everyone, I always wanted to try out an ajax autocomplete search function, but never knew where to start. Of course there is the Ajax Page Search module by soma, but it seems that it was build around the basic site profile. In my case I wanted something more custom and I discovered in this thread the jQuery Plugin Typeahead by RunningCoder, which seemed to be nice. After many hours figuring out, how to combine this Plugin with ProcessWire, I finally got it implemented and want to share my solution with anyone, who also struggles with this topic. 1. Set-Up Typeahead Download the Typeahead-Plugin from the website (I prefer via Bower) and include the following scripts and stylesheets in your templates: <html> <head> ... <!-- Optional CSS --> <link rel="stylesheet" href="/vendor/jquery-typeahead/dist/jquery.typeahead.min.css"> <!-- Required JavaScript --> <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> <script src="/vendor/jquery-typeahead/dist/jquery.typeahead.min.js"></script> ... </head> As next step we need the JSON data. 2. Install Pages to JSON To get the necessary data of all pages as JSON, I use the module Pages to JSON, which provides an easy way to output pages as JSON objects. Of course you can achieve this without this module, but I am not very experienced with JSON, so this module was really helpful. After you downloaded and installed the module, you can configure in the module settings page, which fields you want to output. You can select between own and system fields. For my purpose I selected only title and url to be outputted. 3. Output JSON Now, that we have the module configured, we have to output our search suggestions as JSON. I did it in my template file search.php like this: <?php namespace ProcessWire; // Check if ajax request if($config->ajax) { $results = $pages->find("has_parent!=2"); // Find all published pages and save as $results header("Content-type: application/json"); // Set header to JSON echo $results->toJSON(); // Output the results as JSON via the toJSON function } else { // Your own front-end template } To sum up, we search the pages we want as search suggestions and save them in a variable. Then we output them with the toJSON-Function by the Pages to JSON-Module. All of this happens in a Ajax-Request, that is the reason why we check first, if the page is called via an Ajax request. 4. Insert Form We can now embed the HTML form anywhere you want. Either in an header-include or a specific template. Also you can use your own classes, for this example I used the Typeahead-demo-mark-up and extended it a little. <form id="searchform" method="get" action="<?= $pages->get("template=search")->url ?>"> <div class="typeahead__container"> <div class="typeahead__field"> <span class="typeahead__query"> <input id="q" name="q" type="search" placeholder="Search" autocomplete="off"> </span> <span class="typeahead__button"> <button type="submit"> <span class="typeahead__search-icon"></span> </button> </span> </div> </div> </form> The action-attribute in the form-tag is the url of your search-site. This attribute is of course necessary to know where the form redirects you and where the JSON data is located. 5. Initialize Typeahead As last step we have to initialize the Typeahead-plugin jQuery like this: $(document).ready(function() { var actionURL = $('#searchform').attr('action'); // Save form action url in variable $.typeahead({ input: '#q', hint: true, display: ["title"], // Search objects by the title-key source: { url: actionURL // Ajax request to get JSON from the action url }, callback: { // Redirect to url after clicking or pressing enter onClickAfter: function (node, a, item, event) { window.location.href = item.url; // Set window location to site url } } }); }); We save the action url of the form in a variable, then we initialize Typeahead by selecting the input-field inside the form. As the source we can pass the action url and I included the callback, to link the search results with the site urls. Now you should have a nice ajax autocomplete search form, which of course you can further style and configure. I hope I didn't forget anything, but if so, please let me know. Regards, Andreas
  13. Hey there, i am trying to add a kind of "intelligent" search. Is there any way to ignore punctuation and extra chars. e.g. When I type "somebody elses" that I still get the result "SOMEBODY ELSE´S CAR, 2005" The problem is the extra ´ … if I don't type it I don't get the result. So far I am using %=query (which isn't enough, I know) So the idea would be something like that: $selector = "sanitize(title|text)%=$q, limit=50"; I know, it's not gonna work like that … just to illustrate. Best, Stefan
  14. Hello! I'm making my way through my first encounter with ProcessWire, and I'm very near the end of my tasks! I've searched Google, these forums, and for add-ons, but I haven't found any documentation or reference work for implementing boolean searching in the native CMS? Am I missing a thread, add-on, or docs that can point the way? I'm sure I'm not the first to have a need like this? Thanks in advance!
  15. Hi guys, I would like to realize a search function on my site that follows some clear rules: 1 – Search is performed in the two fields 'tite' and 'body'. 2 – If a user searches for 'foo' and 'bar' he can select whether both terms have to be in at least one of the fields (AND) or at least one of the terms has to be in at least one of the fields (OR). 3 – 'foo' should match words like 'food' or 'foolish' as well as 'foo' (LIKE). 4 – Search results where 'foo' or 'bar' are found in the title should be displayed first, followed by the results found in 'body' only. This is what I have: <?php if($input->get->q) { $q = $sanitizer->text($input->get->q); if($q) { $input->whitelist('q', $q); $qs = explode(" ", $q); foreach($qs as $key => $q) : $qs[$key] = $sanitizer->selectorValue($q); endforeach; $selector1 = "title%=".implode("|", $qs).", template=entry, limit=50"; $selector2 = "body%=".implode("|", $qs).", template=entry, limit=50"; // Trying to separate 'important' title matches from 'less important' body matches $matches = $pages->find($selector1); if ($matches->count) < $limit)) $matches->import($pages->find($selector2)); if ($matches->count) { foreach($matches as $m) : // Output matches title & body excerpt endforeach; } else { // Output no matches } } } else { // Output no search term(s) } ?> First problem is regarding rule 2: I don’t know how to do an AND search. As far as I can see, it’s always an OR. Second problem is the order of the search results (rule 4): I split the queries to separate them nicely, but they appear mixed up. Output starts with a few title matches as I would expect, followed by some body matches, then some further title matches appears. I don’t understand how this happens: $matches->import adds array 2 to array 1 without mixing them, isn’t that true? And just in case I will get the job done someday: how could I avoid doubled matches? Matches in body aren’t that interesting anymore, when the terms was already found in the title field. I will appreciate any helping hand – thanks. Ralf
  16. Hi everyone, I want to start a new project that is community-based and would like to use PW for that. Some of the requirements: User management User sign up by email, google, linkedin, facebook User management by admin each user gets a profile page each user can define his own custom URL for his profile page users can password protect their profiles anti-spam: Flag button for profiles, track number of login attempts then block users can specify arbitrary user fields (!) (self-defined) - I did this once in another framework by a meta-table: "userid | title | value" Search users can find other users, search must index all user fields Misc Logging of all users events (e.g. user A accessed profile of user B, user C logged in, user D got blocked by admin, etc.) all pages via https Let's imagine there would be 100 000 users - Will it still be fast enough? Can ProcessWire fulfill all those requirements?
  17. I've been trying to figure this out... It seems like I'm probably missing something really simple, but I'm still puzzled as to how to move forward with this. I'd appreciate any help or suggestions anyone can give. Aim: I'm trying to modify the default search template so that my search results come out sorted firstly with those which contain the search term in the title and secondly with those that contain it in the body. The basic code where I made sure everything was working first was: $selector = "title|body~=$q, template=BN-article|BN-infopage, sort=-published, limit=15"; // Find pages that match the selector $matches = $pages->find($selector); // did we find any matches? if($matches->count) { // yes we did $entries = $matches; include("./INC-main-blogroll-panels.html"); } It gave me the search results sorted by publication date, as I expected. Next I modified the first portion of the code by using the following to generate the matches as follows: $matchest = $pages->find("title~=$q, template=BN-article|BN-infopage"); $matchesb = $pages->find("body~=$q, template=BN-article|BN-infopage"); $entries = $matchest->and($matchesb); However, the problem is that $entries in my resultant displayed list did NOT start with those matches that were in the title first from $matchest. It seemed like $matchest->and($matchesb) sorted the resultant list its own way. This is even without the added complication of trying to use unique() afterward to remove duplicates - which appears to have its own default sort. Would anyone please point me in the right direction for what what I'm seeking to do? Thank you so much!
  18. I'm getting an error from sending a search in the search box: "Notice: Trying to get property of non-object in /home/mekanoinsa/www/site/assets/cache/FileCompiler/site/templates/_func.php on line 45Fatal error: Uncaught Error: Call to a member function each() on null in /home/mekanoinsa/www/site/assets/cache/FileCompiler/site/templates/_func.php:49 Stack trace: #0 /home/mekanoinsa/www/site/assets/cache/FileCompiler/site/templates/search.php(42): renderNav(Object(ProcessWire\PageArray)) #1 /home/mekanoinsa/www/wire/core/TemplateFile.php(287): require('/home/mekanoins...') #2 /home/mekanoinsa/www/wire/core/Wire.php(380): ProcessWire\TemplateFile->___render() #3 /home/mekanoinsa/www/wire/core/WireHooks.php(723): ProcessWire\Wire->_callMethod('___render', Array) #4 /home/mekanoinsa/www/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array) #5 /home/mekanoinsa/www/wire/modules/PageRender.module(514): ProcessWire\Wire->__call('render', Array) #6 /home/mekanoinsa/www/wire/core/Wire.php(383): ProcessWire\PageRender->___renderPage(Object(ProcessWire\HookEvent)) #7 /home/mekanoinsa/www/wire/core/WireHooks.php(723): ProcessWire\Wire->_callMethod('___renderPage', Array) #8 /h in /home/mekanoinsa/www/site/assets/cache/FileCompiler/site/templates/_func.php on line 49 This is the code part in _func.php // markup for the text $programme = "{$item->stu_programme->title}"; $out .= "<div class='list'><div class='listtext'><span class='verdana_18_bold'><a href='$item->url'>$item->title</a></span><br><br><span class='verdana'><b>$programme</b><br>"; $out .= $item->workshops_list->each( "<font color='green'>| {title}</font>" ); // if the item has summary text, include that too if($item->summary) $out .= "<br><br>$item->summary"; // end markup for the text $out .= "</div>"; Weird, it doesn't happen all the time and I can't figure out what makes the difference....
  19. Hello I tryed to modify the search template so as to search also descriptions of an upload field. $selector = "title|body|upload->description~=$q, include=hidden, limit=50"; That throws the following exception: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? So how is this correctly done? Thanks.
  20. I've built a site that uses parent pages as the "container" for child pages: Parent page [page.php] -- Child page [unit-child-a.php] -- Child page [unit-child-b.php] ---- Grandchild page [subunit-grandchild-a.php] ---- Grandchild page [subunit-grandchild-b.php] -- Child page [unit-child-c.php] The child pages are displayed as content on the corresponding parent page using the render method. Some child pages also include their own child pages. (Internally the child page template names start with "unit-" and the grandchild page template names start with "subunit-".) Example: foreach ($page->children("template=template-name,sort=sort") as $child) echo $child->render(); This approach allows content administrators to add and reorder child pages as necessary, but I've come across an issue that I'm not sure how to address. The site includes search functionality, but when a visitor searches for content and it is found in a child or grandchild page, the Parent page should be the one that is displayed in the search results, since the child and grandchild pages are not directly viewable. Since some searches could include more than one child or grandchild page of a parent page, this sometimes means that a parent page could be included more than once. How do I easily redirect the child and grandchild pages to the parent page, and only include the parent page once in the search results?
  21. I was thinking about writing a module: Enabling PW to index and search contents of uploaded files. I know the easiest way to include search-inside-files capability is to use Google CSE. Developers who have a dedicated server may of course use of of the "big boys" of search like Lucene, ElasticSearch, Solr etc. For ES you'll need Apache Tomcat, which most people don't have at their disposal, etc. So, my question is, first of all: Would such a feature be used at all? I know you can create some sort of meta-search with file-descriptions, or when using the "one page per file" approach. After some brainstorming, I came up with this: Idea: Make it possible to search file upload content (PDFs, Word, Excel) Approach: Build a module (d'oh) Config settings: select templates / file-fields (what to index) - list all inputfields type "file" “index now” button or “index each time a file is added” or cron? Performance? Where / how to store indexes? As a separate, new field inside each page? On the file-system? In the module folder, each file has a related JSON file? (similar to language files) A new, separate DB-table? What we need: filename / path / URL filetype (to customize search results with file-icons) page id extracted content timestamp of last index-build? MD5/SHA hash or some such? How to handle user roles when doing actual search? Inherit from page? Inherit from file-field? So, what do you think? Not worth it? Does something like this already exist (I searched, but found nothing)?
  22. In my search.php template, I am using $selector = "title|body%=$search_term, limit=50"; to find the top 50 search results for the page. I implemented this following this link https://processwire.com/api/selectors/ My question is how does the selector sort its results? Does it look at the number of time the $search_term has occurred in the page or does it start searching from the root page to all the children. Also, will this change if I do not put any limits to the search results?
  23. I have about 50 pages which are just containers for their child pages. What's the most efficient way to exclude these parent pages from Searches? I'm using Ryan's code here I guess I have a few options but is number 2 here the best way or is there anything I haven't considered which would be better? 1. Mark as 'Hidden: Exclude from lists and searches" Isn't an option because it hides from lists which I use. 2. Tell the selector to ignore a particular template(s) Sounds like a good approach 3. Create my own checkbox called "Search Ignore" and add it into a selector Could work but it seems like a ton of work to manually edit all the pages I want to ignore Cheers
  24. HI all. I recently built a web shop with PW and it works pretty good. I love the simplicity and freedom working with templates and how stuff works and the client loves the back-end. However, the part I am unhappy about is the site search. Beside the API selectors work fine, it seems not be suitable for that kind of search. People search for words, phrases, they mix spaces, hyphens etc., add measurements … so a lot of searches end up in 0 results. I know of the ElasticSearch module and other external things like Sphider, Google CSE, algolia.com … but some are quite complicated and limit my control or bring google's ads on the site So perhaps you have any improvements, ideas how to get a better search engine on my website. Most problems come from spelling issues, singular/plural, hyphenated words/searches. <?php $vars['q'] = $q; $input->whitelist('q', $q); $q = $sanitizer->selectorValue($q); // 1. // Item Number // If there is a number in it that matches a product's numbers, redirect to product directly $q_numeric = preg_replace('/\D/', '', $q); $prodcut_item_number = $pages->get("template=product|product_variation, product_item_number=$q_numeric"); if ( $prodcut_item_number->id && $prodcut_item_number->template == 'product') { $session->redirect($prodcut_item_number->url); die(); } elseif ( $prodcut_item_number->id && $prodcut_item_number->template == 'product_variation') { // variations are saved as sub-pages, but have no public web-page $session->redirect($prodcut_item_number->parent->url); die(); } // 2. // Product title and description // Search the product's title, headline and summary $matches = $pages->find("title|headline|summary~=$q, template=product, limit=50"); // 3. // Categories // If search is a category, append all its products $categories = $pages->find("title%=$q, template=category, limit=10"); if ( count($categories) ) { $category_ids = $categories->each('id'); $category_ids = implode('|', $category_ids); $append_products_from_category = $pages->find("template=product, has_parent={$cat_ids}"); $matches->append($append_products_from_category); } // 4. // Split search phrase // If nothing above matches, try each word separatly if( !count($matches) ) { $q_separate = preg_replace('/\PL/u', ' ', $q); // "Remove" everything but letters $q_separate = preg_split('/\s+/', $q_separate); foreach ($q_separate as $q_word) { if ( $q_word != '' && strlen($q_word) > 4 ) { $append_products_separate = $pages->find("title|headline|summary~=$q_word, template=product, limit=50"); $matches->append($append_products_separate); } } } // PLEASE NOTE – this doesn't come from my production code, but is a current idea I have // There is no highly need of weighting results and order best results on top, because there are just a few products for each keyword :-)
  25. Hello! I have pages that have separated fields for first name and last name. I'm working on a search form that has one single input field, so that if someone search for "John Doe" it should find all pages that have "first_name = John" and "last_name=Doe" or, of course, "first_name=Doe" and "last_name=John". What would be the best use of selectors and operators in this case? I came up with first_name=John|Doe, last_name=John|Doe so that i should split the search key with | I'm not sure this is the best solution. What would you suggest? Thank you!
×
×
  • Create New...