Jump to content

opalepatrick

Members
  • Posts

    233
  • Joined

  • Last visited

Posts posted by opalepatrick

  1. I wonder if someone could give me an idea how to use the attachment aspect to WireMailSmtp? I am doing a simple form that allows the upload of pdf's only. I am unsure how to access the file size, type, etc. so that I can sanitize things a bit.

    Thanks in advance.

  2. Still struggling with this. I have followed the video on code internationalisation step by step and cannot see that I have missed anything. The admin area seems to recognise the fields from the template as I added some translation for them after choosing the particular file. Other than the __("word") code is there anything else that needs to be on a page? Maybe doctype/header or something?

    This is typical code:

    <label class="inline"><?=__("Your Name")?></label>
    
  3. Sérgio, On the settings for the page concerned /home/contact-2/ is default but French is /contact-2/ - Is this the problem?

    I have checked the settings for the page and the home page, Sérgio, and they are fine in the sense that they have the option for a French url if needed. I have also checked using Firefox, marcus, set to prefer French content and it still does not show anything in French.

  4. I am doing a simple translate English to French for a contact form using the code internationalisation syntax. Your Name, Your Email, Your Comments. I have used: 

    __("Your Email")
    

    for instance. Then I added French to languages under set-up>languages and added the template. The fields show up in English. I add some translations. Change the profile to French, view page, everything is still in  English.

    Bear in mind this is the first time I have done this, what am I missing?

  5. Following up on this. I was so focussed on getting a result on multiple word search as above that I did not realise I was getting an error on single words:

    Call to a member function last() on a non-object

    I have checked and there is a dump that appears to be exactly the same format as the multi word search. The line above is the last piece of code before this call.

    $intersect = array_reduce($results, function($carry, $item){
    if(is_null($carry)) return $item;
    return array_intersect($carry, $item);
    });
    
    $search_result = $pages->get("id=" . implode("|", $intersect));
    
    foreach($search_results as $m) { if($m->images->last()){ $img = $m->images->last()->width(300); } }
    

    As I say, this works for more than one word but not for one.

  6. Thanks to you both for your replies. Just working on LostKobrakai's one first. Could you explain the logic particularly around the function with array_reduce as I am only getting a single result regardless of search? I would expect many id's in this case.

    edit: Actually, the one result is because of this line

    $search_result = $pages->get("id=" . implode("|", $intersect));
    

    And it worked perfectly with $pages->find !

    Thank you once again LostKobrakai and everyone who helped.

  7. Honestly Macrura and everyone else, I am just banging my head against a brick wall due to my lack of knowledge. So say my search is 'green vinyl', I have:

    $selector = ''; 
    $parts = explode(' ', $search);
    $p = new PageArray();
    $fs = array('hue.title','pattern.title','pattern_type.title','usage.title','title','collection.keywords');
    if(count($parts)) {
    		foreach ($parts as $pt) {
    			foreach ($fs as $f) {
    				$selector = ", collection.title!=Clearance, " . $f . "~=" . $pt;
    				// echo $selector . "<br />";
    				$ps = wire("pages")->find("template=fabric" . $selector);
    				// echo "Page ids are: " . $ps . "<br />";
    				$p->import($ps);
    			}
    		}
    	} 

    I get every page id if any word is available in any field.

    What I actually need is to get both words from a concatenation of content from all of the specified fields. I need to narrow the results so that for instance, I only get results when both 'green' and 'vinyl' appear in any field but not necessarily the same field. 'green' maybe from hue.title and 'vinyl' from collection.keywords?

    As mentioned previously the concat fieldtype would let me specify things like hue.title for page fieldtypes (single) but is not available at runtime. Cache fieldtype does not allow page fieldtypes. I am just getting tangled in my head and going down rabbit holes. Any help or questions to help me explain more clearly would be appreciated.

    I do find it hard to believe that I cannot query all fields on a page even if they are page fieldtypes (single).

  8. In this thread https://processwire.com/talk/topic/11754-search-not-working-as-intended/ there is a really nice solution for dealing with 3 letter words in search. However I am having a problem with selectors.

    $selector .= ", title|body|collection.title|hue.title|pattern.title|pattern_type.title|usage.title~=" . $sanitizer->selectorValue(implode(' ', $parts));

    The problem is that if I have, for example, a search that is looking for myfabric (in title or title.collection) yellow (in hue.title) I get zero results. If I do either separately then I get results. So the search is myfabric yellow.

     

    It seems to me as if the query is saying IF EITHER OF THESE WORDS are in EITHER title OR title.collection OR hue.title then show results but not if they are in separate fields. I need it to be IF EITHER WORD is in any field. If both words are in one field then I get results as well.

     

    Baffled or dense. Any help appreciated.

  9. I want to link to an external site via mysite.com/demo - the problem with the 301 redirect solutions I have seen is that they go to the new url. I would like the url to remaIn mysite.com/demo. It was suggested that I drop a .htaccess file with some proxy settings into /demo, but I can't see how I would do that with Processwire. Any ideas?

    PS. I know that I can do this with a subdomain and changing the A record, but I have an existing ssl cert that needs to be used on the main domain.

×
×
  • Create New...