Jump to content

godmok

Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by godmok

  1. Hi @Zeka, thank you for your answer, and I am very sorry for my late feedback. Your code is working fine if there are not any other fields next to the product_cache field. But if i want to add another one that has to find the same values from the query, then it fails. What I got right now is this: $q = explode( " ", $q ); // create array foreach ( $q as $key => $word ) { $q[ $key ] = $sanitizer->selectorValue( $word ); } $q = implode( "|", $q ); My search input is "berlin massagen 10629 esalen" and the selector selector looks like this: $matches = $users->find( "search_profile_cache|method.title*=berlin|massagen|10629|esalen" ); In this case I get a bunch of results. If I search for "berlin" I get less results than with more words. What I wanted to have is to filter out results with every added word. Let's do it this way: $matches = $users->find( "search_profile_cache*=berlin|massagen|10629|esalen, method.title*=berlin|massagen|10629|esalen" ); There are less results, and that is a good thing. But still not the result I need, because the word "esalen" is only in one profile availible. So if I search only by that word I get one result. I don't know any more how to work that out. A single field is easy to handle but if there are more it gets ugly with multiple words. How would it be possible to search like "berlin AND massagen AND 10629 AND esalen" in multiple fields to reduce to the results and not add?
  2. Hi everybody, I am working on a project where I have a search form with an input field, that should search over a lot of PW fields (text and pagefields). What I am trying to get is something like this: $pages->find("title|body|sidebar|summary|intro|keywords|country.title%='word1 word2 word3'"); The problem is now the search input. If I insert two words (word1 word2) it should look into every field, just like: $pages->find("title|body|sidebar|summary|intro|keywords|country.title%=word1, title|body|sidebar|summary|intro|keywords|country.title%=word2"); So far so good. but there is the possibility to add up a lot of words, and then MySQL is at its join limit and quits with an error. Is there a possibility to prevent this? I even limit the words for the input but this is not good. On the more complex site I tried the fieldtype "cache". So far so good, but now there is the problem with pagefields that are searched too like "country.title". This is not working, as I read in the forum, and in the database there is only the ID of the pagefield in question. On a normal search by selector I would definitely use that, but here it is not the point, because the input is a word, not an ID. Example: $pages->find("cached_fields_in_fieldtype_cache|country.title%=word1, cached_fields_in_fieldtype_cache|country.title%=word2"); I know the second example is not the best for this kind of search. It is easy to put an OR selector with the values together, but an AND selector (third example) is limited to the MySQL functionality. I want to is a search ability like some might know from Joomla (no I am not a Joomla fan or developer, but the client is ). In Joomla there are the three possibilities to search from an input text: any word (same as selector operator "~=" ?) all words (same as selector operator "*=" or "%=" ?) exact wording (same as selector operator "*=" ?) There is no limitation of words in the search input, so I am wondering how this is working. So, what I got at the end are two options for the selector: 1: $pages->find("cached_fields_in_fieldtype_cache|country.title*='wor d1 wo rd2 word3'"); // mostly no results at all if word is only part of the complete word. Word length limitation to at least 4 characters The first option here is only working if the word is complete. If the search is "wor" and not "word1" then I get only result on one word input, but do I add another word to it, it gets no result. 2: $pages->find("cached_fields_in_fieldtype_cache|country.title%=word1, cached_fields_in_fieldtype_cache|country.title%=word2, cached_fields_in_fieldtype_cache|country.title%=word3, ..."); // result limited by word count Now I am almost on the model to remodel the search and limit it only to some parameters (as it should be...), but this would question the the clients "wish" for the search. Another point is to extend the selector with more pagefields ("cached_fields_in_fieldtype_cache|country.title|method.title|town.title" etc.) that can not be put into the cache fieldtype. So the MySQL limit is coming back again... is it even possible to store the subfield of a pagefield in the cache field? Does anyone know how it would be possible to get that kind of search running? Maybe a direct MySQL search? filter results by adding part or complete words (to find the one and only result) search with multiple words (no MySQL error because of join limitation -> I am already cutting off too many words) Thanks for your help!
  3. I am very interested in the demo site. Will there be some list what functions/modules have to be inside (SEO, hanna code, blog, ProCache and others, etc.)? Layout: a competition? Or a free template put into it? PW strength points shown in any way. Some ideas? Maybe a simple example with $pages->find() results and a code block content how it was done. Putting up some polls for this would be nice. What do you think? (Of course there should be a limit on content )
  4. I have a similar problem. In my case I try to change a page and save a value from this page in the user profile. Here my code: $u = $users->get(123456); $u->setOutputFormatting( false ); $u->user_activation = true; /** * get the only invoice and mark it paid * Payment if there is one invoice */ $invoices = $pages->find( "template=invoice, user_select=$u->id" ); $invoice = $invoices->first(); if ( count( $invoices ) === 1 && $invoice->id ) { $invoice->setOutputFormatting( false ); if ( $invoice->payment_rate === (float) $input->get->amt ) { /** * ERROR occurs if reloading the page with changed value (true/false) * set $u->setOutputFormatting( false ) later before the pass */ $invoice->user_activation = true; $invoice->save(); $u->payment_rate = $invoice->payment_rate; } } $pass = activationAndPassCode(); $u->setOutputFormatting( false ); // have to set it again, without it will create an error $u->pass = $pass; $u->save(); My error message was similar but there was: ... modified and saved. [pass] ... The only fix I could made for now is to put $u->setOutputFormatting(false) again before changing the password ($u->pass = $pass), even if was set in first line. Weird behaviour on my side was: after the first time the error was shown it disappeared after the second. It triggered only on the change of $invoice->user_activation = true|false. So if the value changed in $invoice->user_activation it could not run without the error. Maybe it helps to set you to set setOutputFormatting(false) before your change on the field "return_time" as the error hints to it.
  5. Hi, sorry for late feedback. You are both right. It is running now and set to the sandbox. I still got this error on PaymentModule when I look into the module settings: "Method PaymentGatewayPayPal::getTitle does not exist or is not callable in this context". It seems to be alright on the frontend. On the frontend i get an error where I finish the transaction and get to the success site, but there i get this: I get from PayPal an post input with a lot of data from the payment process, but after the payment forwarded to the process/success page it always gives me this error.
  6. Hi apeisa, will there be a compatibility for PW 3.0? Or is there a way to force it to run?
  7. I put up your code and set some outputs to it with no result in the end. $customUserRoles = $roles->find( "name^=member-" ); echo $customUserRoles->first()->name; // output: member-gold (OK) echo count($customUserRoles); // output: 2 (OK) $profileTemp = $users->find( "roles=$customUserRoles" ); echo count($profileTemp); // output: 2 (OK) echo $profilesTemp->first()->name; // output: "" (nothing, not OK) It seems as a guest I can get some information but not filtered with roles (even with "check_access=0" or "include=all"). Another test was also successful, as long as I do not use "roles": $profilesTemp = $users->find( "name^=a" ); // find user beginning with "a" in the name echo count($profilesTemp); // output: 1 (OK) echo $profilesTemp->first()->name; // output: "adam-..." (OK) $profilesTemp = $users->find( "user_firstname^=a" ); // find user beginning with "a" in the field user_firstname echo count($profilesTemp); // output: 1 (OK) echo $profilesTemp->first()->user_firstname; // output: "Adam" (OK) Edit: Thank you LostKobrakai, that's it! It worked out like it should and is displaying on the page. Will do that with the other pages after some food input!
  8. Hi Wanze, thanks for the welcome and your feedback! I don't like the idea to change the permission in the system template. As you suggested I tried that and still no result. But I found the problem within the selector. You put me on the "right" track with "check_access=0", and should read the cheatsheet more carefully... I simplified the selector like this: $profilesTemp = $users->find("roles=member-gold"); echo $profilesTemp->first()->name; Without check_access it is still working (system template "user" -> guest has no view rights!) for visitor (strange?) and shows the name from the user. I can get output on every field from the user profile. This is good, but then it gets problematic again. $profilesTemp = $users->find("roles^=member-"); echo $profilesTemp->first()->firstname; The difference is "roles^=member-". I want to have all users that have the role starting with "member-". This one fails. The problem seems to be in the selector: If the role is not selected with the "=" operator it fails (even for logged in members). I tried every operator for the string, but no luck.
  9. Hi everyone, this is my first post here, please be gentle to me I am using ProcessWire for a the second time, running it for a project site that has a little trouble on its way. It is my fist time to work so intense with the user profiles in PW. I have extended the user template with additional information (avatar, postal address,etc.) that the user can fill in. The user have the roles of one of these: member member-x member-y The information from the profile has to be shown on various pages, even on the home page. So, if I get the profiles like this: $profiles = $users->find( "roles^=member-, limit=4, sort=random" ); // get only "...-x" and "...-y" member The output should show some profile information, but it does not. Only logged in as superuser the profiles are shown. Now my question: how can I output information from the user to a guest/visitor/everyone? For now I have created for the test site a /profile/ page and duplicated the user profile into this, so the information can be found by a simple $pages->find(). This is working for now, but makes the maintenance troublesome. On another part of the site there is a little confusion situation. Here the background: Every user can create a calendar (event) post. The structure is like this for the calendar page: /calendar/ | - /calendar-1/ (by user1) | - /calendar-2/ (by user2) | - ... (by userX) I can get the posts in /calendar/ by: $calendarPosts = $page->children("sort=date_start"); foreach ( $calendarPosts as $calendarPost ) { //... $member = $users->get( $calendarPost->created_users_id ); // get the user information //... //HTML output with user information echo $member->lastname; //... } Here the user information is reachable for the guest. For now this is quite "dirty" code (or maybe clean?) but it is working. Could this be a bug or is it because of "get()" and not "find()"? So I can get a user profile information about another page but not directly from the profile itself. Is there a solution to get the profile information from the user without creating a additional profile page or is the additional profile page a better solution? PS: Originally my client wanted this to be on Joomla, but that would bring a lot of other trouble That is why I like PW a lot! So simple, clean, mighty. Love it!
×
×
  • Create New...