-
Posts
115 -
Joined
-
Last visited
Everything posted by JoshoB
-
Searching for numbers throws Exception: Operator '~=' is not implemented
JoshoB replied to joe_ma's topic in General Support
This is an older thread, but since I have a problem that's related to this I figured I'd post in here. I am having the same problem with search. I want the search field to include the names of authors, but this causes an error when you type in a number. Here's part of the selector I use: $selector .= ", title|subtitle|summary|body|product_isbn|authors.authors_name%=$q_word"; The problem is with authors.authors_name -- this is a repeater field (authors) and authors_name is a PageArray. Now, when you type in a number, ProcessWire gets confused and thinks you might be asking for an ID (as explained earlier in this thread). Obviously, this is not what I want -- people should be able to e.g. search for an ISBN (as you can see in the list) or something similar. How can I ensure that ProcessWire searches through the proper fields of authors_name? Ideally, it would be the fields title, name_first, or name_last. I tried doing this: $selector .= ", title|subtitle|summary|body|product_isbn|authors.authors_name.title%=$q_word"; But that didn't work. Any ideas? Thank you! -
Oh man, what an idiot I've been! Thanks abdus -- you're correct, it wasn't loading $product correctly since order_products is a repeater field. That part now reads: <?php foreach($orders as $order): ?> <?php $product = $pages->get("id=" . $order); ?> <article class="order"> <header> <h2><?php echo _('Ordered on'); ?> <?php echo $order->datetime; ?></h2> </header> <table> <?php foreach($order->order_products as $order): ?> <?php $product = $pages->get("id=" . $order->order_product_id); ?> <tr> <td><?php echo $product->title; ?></td> </tr> <?php endforeach; ?> </table> </article> <?php endforeach; ?> So yeah...
-
Thanks, kixe, but it didn't solve the issue. In this particular case, the user is also the superuser (i.e. me), which makes it even stranger.
-
So, I'm building my own webshop using ProcessWire. Everything is coming together nicely. Users can now place an order and the details are saved to a page with template "shop-order". This template has no file, since it's not supposed to output anything on the frontend except via the API. Now, when a user is logged in, they can go to their account page. There's an option to list their previous orders. It's a markup file (account-orders.php) that gets loaded via TemplateFile(). Here's the full code of the markup: <?php namespace ProcessWire; /* ========================== Markup: account-orders.php ========================== */ // Get the orders $orders = wire('pages')->find("template=shop-order, order_user_id=$customer, sort=-datetime, limit=10, include=all"); ?><h1><?php echo $page->title; ?></h1> <?php echo $page->body; ?> <?php if($orders->count > 0): ?> <?php foreach($orders as $order): ?> <article class="order"> <header> <h2><?php echo _('Ordered on'); ?> <?php echo $order->datetime; ?></h2> </header> <table> <?php foreach($order->order_products as $product): ?> <?php $product = $pages->get("id=" . $product); ?> <tr> <td><?php echo $product->title; ?>test</td> </tr> <?php endforeach; ?> </table> </article> <?php endforeach; ?> <?php else: ?> <p><?php echo _('No orders found.'); ?></p> <?php endif; ?> $customer is defined in the template (= $user->id). It all works. There's one order for this user, and when I use print_r($order) it's listed. The code also cycles through the products (since I can see the word "test" three times, top to bottom, in the table that I created in HTML). The only problem is: no output from the order is actually displayed. So instead of printing the date and the titles of products, ProcessWire displays nothing. And yet, it does load the data and cycles through it in my foreach loop. Now, the orders are pages that have, as rootparent, a page called "Shop" that is hidden from lists/searches and not accessible to anyone except superusers. I've changed this to make it accessible, but still no luck (have changed it back now). I also created files for the templates to see if that was the problem, but the results are the same: for some reason, ProcessWire doesn't output the data (I've removed the files again). So, I'm a bit at a loss. But experience tells me that there's undoubtedly something that I've missed that a forum user here will note almost immediately. As always, I'd be extremely grateful for any assistance in solving this issue! Edit: BTW, "include=all" makes no difference.
-
Search to find pages containing ALL search terms across different fields
JoshoB replied to JoshoB's topic in General Support
Perfect -- that seems to be exactly what I'm looking for! Thanks very much. (Edit: as always, ProcessWire makes things a lot easier than I initially thought -- I was seriously overthinking this problem. Thanks again!) No, it's precisely what I want. -
Search to find pages containing ALL search terms across different fields
JoshoB replied to JoshoB's topic in General Support
Thanks for the suggestions! And @RobinS -- thanks for the less verbose version of the author selector: I had no idea. I want to use the %= operator, so that it also matches partial words. I want lazy visitors who search for "milton paradi" to get the results they want, too (more pertinently perhaps, this also matches singular and plural nouns: a search for "dog" will also return books with the word "dogs" in them, etc.). For the same reason, I want ProcessWire to separate out the query string. If I don't, ProcessWire will look for the phrase rather than individual words. Perhaps to deal with this more specifically: this doesn't work for me, because it searches for the keywords as a phrase (with the ~= operator). It also doesn't mix and match authors and titles, e.g. "Milton Paradise" won't yield any results unless one of the fields contains that specific phrase. If I split the $q again, as I have done, I get results, but it's again a broad selection, matching either or both, but never exclusively both of the keywords. Current version, which results in too broad a selection: $q = str_replace(' ', '|', $q); $selector = "template=product, limit=10, title|subtitle|summary|body|product_isbn|authors.authors_name%=$q)"; Thanks again! -
How so? PW doesn't use SOAP, as far as I know. What does the error log say, specifically? Where does the error occur? What code is being executed when the error pops up?
-
^ Templates seem the most likely option. I usually have parent pages a different template from children, so you could do "template!=example", or specify the child templates, i.e. "template=child-example". If the child pages don't have any child pages of their own, you can also exclude them on that basis?
-
Could it be a connection error? You said you're using a webservice (third party?), so that would be my guess.
-
Hello again. So, I'm building a website that features a catalogue of books. I have different product pages (with template "product"). The key fields here are the following: title (= text) subtitle (= text) summary (= textarea) body (= textarea) product_isbn (= text) In addition, there's a repeater field with author data. It looks like this: authors (= repeater) authors_name (= PageArray) The authors_name field is populated with pages with template "author". So that means that authors_name stores the ID of the page in question. Now, what I want visitors to be able to do is to enter a search and the system will spit out the proper results, e.g. "Milton Paradise" should give the visitor ALL pages that contain both of these terms. Now, the problem is that I can't seem to be able to get ProcessWire to do this. Here's what I have right now as far as the selector is concerned: $q = str_replace(' ', '|', $q); $selector = "template=product, limit=10, (title|subtitle|summary|body|product_isbn%=$q), (authors=[authors_name=[title%=$q]])"; The problem is obvious, I think: this will list all pages where EITHER the title, subtitle (etc.) match any of the keywords, AND/OR which match the author's name (title, in this case; ideally, I should also like to include name_first, name_initials, and name_last). Anyway, the result is that this selector includes pages with both "Milton" and "Paradise", or just "Milton", or just "Paradise". If it functioned as I would like it to, I would get e.g. 4 results. But with the selector as it is now, I get e.g. 11 results. I've been at this for a while now and I can't seem to fix it. There are some threads here that deal with the same problem, but without an obvious fix. Perhaps there is none. I started working with PageArrays and then matching IDs and that sort of thing, and ended up with an unsightly mess of code that untangled as soon as I tried to correct some issue or other. I think that the solution is probably simple, but it eludes me. I hope the above is clear. Any help would, as always, be greatly appreciated!
-
In the end, I integrated phpMailer without using any modules; it works like a charm now. Thanks for the help and suggestions.
-
Yes, but the settings worked fine with phpMailer. I'll try something else, and will roll my own module if necessary.
-
It's a simple matter of reading about the required SMTP settings for your mail server. Wish it were that simple! The client's IT guy gave three pieces of information: SMTP server, port, and user; no password or authentication required. I've entered that data into the module and get the rather cryptic error: "it is not supported any of the authentication mechanisms required by the server". But no authentication methods have been specified by me in the module.
-
Yeah, I already had to use phpMailer because the client's server was flagging all incoming mail as spam. I've installed the module, but it's not working. I keep getting SMTP errors and have no clue how to fix this.
-
No errors at all. The email doesn't appear to be sent. I'm thinking it's probably some server error, but I can't find the logs. ProcessWire doesn't register a problem in the logs.
-
For a client's website, I've installed the "Forgot password" module from core and set the email address to use as one from the website's domain name. However, it doesn't work, not when used from the backend (the login page), nor from the frontend. That's a bit of a pain to put it midly. I've written my own password recovery thing for another website, but would like to make use of the default password retrieval for this one. I figured it would work, but sadly no. Any idea what the problem could be, or where I should look to located the issue?
-
Thanks for all the suggestions everyone! Wow, that was the thing that was tripping me up: the UTF-8 encoded non-breaking space. Thanks so much! Works perfectly now.
-
Greetings! I'm trying to develop a module that automatically strips out empty paragraphs from a textarea (CK Editor) field. I don't think I did anything wrong, but the below code doesn't seem to have any effect. Can anyone tell me what I'm doing wrong? class TextformatterStripEmptyParagraphs extends Textformatter { public static function getModuleInfo() { return array( 'title' => 'Strip empty paragraphs', 'version' => 1, 'summary' => "Removes empty paragraphs from a field, including <p></p> and <p> </p>. Apply after all other text formatters have been applied to a field." ); } public function format(&$str) { $pattern = "#<p[^>]*>(\s| |</?\s?br\s?/?>)*</?p>#"; $str = preg_replace($pattern, '', $str); } } I figured this ought to work, but it doesn't. It's getting applied after all other Textformatters (Video Embed for YouTube by Ryan, my own Lightbox module, and SmartyPants). My Lightbox module works fine with preg_replacing stuff from image tags, so this ought to work, too. But whenever someone has entered an empty paragraph (with breaking space added by CK Editor), it just doesn't do anything.
-
Yes, that was it! What a stupid mistake to make. I'd renamed the field "picture" (instead of "images"). It works! Huzzah!
-
Some more clarifications: as far as I know, you need a path to upload an image (URLs don't work anyway when trying to upload), and I've tried various forms of those (full Windows paths, since I'm using XAMPP on my computer instead of the live website). I've already shifted all the photos to /site/assets/ and used $config->path to have the system located the photos, but that's not working. I keep getting the error that ProcessWire cannot add NULL (whatever I try), so the path isn't working. Any suggestions would be great to get me moving. Thanks. Edit: creating the PictureList pages works, by the way, and the system does create the first regular Picture Page, too, but then the fatal error (NULL as file) causes the system to die.
-
Thanks, I know. But for some reason it's not working. I'm unable to come up with a decent path. Any hints what it should look like? Edit: this is the error I get, with line 85 = $picture->images->add($fullfilename); Error: Call to a member function add() on null (line 85 of D:\Websites\example.org\www\site\templates\conversion.php) And this is the complete, revised code that is not working: function listFolderFiles($dir, $root) { $pages = wire('pages'); $ffs = scandir($dir); echo '<ol>'; foreach($ffs as $ff){ if($ff != '.' && $ff != '..'){ echo '<li>'.$ff; // This is a directory if(is_dir($dir.'/'.$ff)) { // Set title and template $title = $ff; $template = "pictures"; // Set parent $parent = explode("/", $dir); $parent = end($parent); $parent = trim($parent); // Set selector $selector = "name=$parent, template=pictures, id>16521, include=all"; // Create page $pictureList = new Page(); $pictureList->template = $template; $pictureList->parent = $pages->get($selector); $pictureList->title = $title; $pictureList->save(); // Output echo ' [DIR - title = ' . $title . ' and template = ' . $template . '; parent = ' . $parent . ']'; listFolderFiles($dir.'/'.$ff, $root); } // This is a picture else { // Remove extension from filename for title $filebroken = explode( '.', $ff); $extension = array_pop($filebroken); $title = implode('.', $filebroken); $title = str_replace("_", "-", $title); // Set parent $parent = explode("/", $dir); $parent = end($parent); $parent = trim($parent); // Set template $template = "picture"; // Set selector $selector = "name=$parent, template=pictures, id>16521, include=all"; // Get the file name with relative path $fullfilename = $dir.'/'.$ff; $fullfilename = str_replace("/", "\\", $fullfilename); // $config->paths->root . '/photos/' . $ff; //$fullfilename = str_replace("/", "\\", $dir) . '\\' . $ff; //$fullfilename = dirname($fullfilename) . '\\' . $ff; // Download link for debugging purposes echo ' <a href="' . $fullfilename . '">download</a>'; // Create page $picture = new Page(); $picture->template = $template; $picture->parent = $pages->get($selector); $picture->title = $title; $picture->save(); // Upload picture $picture->images->add($fullfilename); $picture->save(); // Output echo ' [FILE - title = ' . $title . ' and template = ' . $template . '; parent = ' . $parent . ']'; } echo '</li>'; } } echo '</ol>'; } // Create output echo '<pre>' . "\n"; echo '==================' . "\n"; echo 'Picture conversion' . "\n"; echo '==================' . "\n\n"; // Set directory $dir = $config->paths->assets . 'a2'; // Parent (root) page $root = $pages->get("name=a2, template=pictures, id>16521, include=all"); echo 'Parent is located <a href="' . $root->url . '">here</a>.' . "\n\n"; // Go through directories and files listFolderFiles($dir, $root); // Close output echo '</pre>' . "\n";
-
You're right. That was the problem. Thanks! I am now left with figuring out how to get the images uploaded. I cannot, for the life of me, figure out what kind of URL/path the system wants... This sorry excuse of code is what I'm using now to figure out the path to the picture, and it doesn't work: // Get the file name for upload $fullfilename = str_replace("/", "\\", $dir) . '\\' . $ff; $fullfilename = dirname($fullfilename) . '\\' . $ff; It's something simple. I've done it before, but I'm stuck now. (This is on a test server, XAMPP, running on Windows.)
-
I run it as a template. (Edit: I've updated the function to create a new page as parent of a recently created page, based on ID being larger than the otherwise youngest page. Doesn't make a difference, but hope springs eternal!) The error I'm getting is as follows: Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in D:\Websites\example.org\www\wire\core\Selectors.php line 281) #0 D:\Websites\example.org\www\wire\core\Selectors.php(318): Selectors->create('pictures', '', '') #1 D:\Websites\example.org\www\wire\core\Selectors.php(115): Selectors->extractString('pictures') #2 D:\Websites\example.org\www\wire\core\Selectors.php(104): Selectors->setSelectorString('pictures') #3 D:\Websites\example.org\www\wire\core\Pages.php(203): Selectors->__construct('pictures') #4 [internal function]: Pages->___find('pictures', Array) #5 D:\Websites\example.org\www\wire\core\Wire.php(387): call_user_func_array(Array, Array) #6 D:\Websites\example.org\www\wire\core\Wire.php(325): Wire->runHooks('find', Array) #7 D:\Websites\example.org\www\wire\core\Pages.php(310): Wire->__call('find', Array) #8 D:\Websites\example.org\www\wire\core\Pages.php(310): Pages->find('pictures', Array) #9 D:\Websites\example.org\www\wire\core\Pages.php(325): Pages->findOne('pictures This error message was shown because you are logged in as a Superuser. Error has been logged.
-
Thanks! I already looked at that, but the problem -- unless I'm missing something -- is how to get the directory structure to keep the same. Also, unless I'm mistaken, the solution you posted would require me to drag and drop 4900 pictures into the upload field? I don't think that would work.
-
E-Commerce site with ProcessWire - Optimal approach?
JoshoB replied to Neo's topic in General Support
The general consensus seems to be to use a third-party solution rather than code something from scratch (or based on the abandoned module). You could always try to build a bridge between the shop and ProcessWire to facilitate user management.