Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by strandoo

  1. Do you have ‘scf-website’ as one of the fields in the module settings > Select Form Fields settings? If so, try removing that.
  2. Thanks @Guy Incognito. Yes, now that I've dived in a bit, I can see that handling the communication may be tricky. (Logged-in sales rep initiates a 'stock query' > check if exists, creates a new DB record > writes file > waits for response > checks if new response file matches my stock query > parse file and update DB record > display result > rinse and repeat.) The php module 'Inotify' looks promising as far as checking for directory/file changes, but I haven't gotten there yet. Thanks again.
  3. Hi folks. I wonder if anyone has built or encountered an API-like FTP system of interacting with another computer. My client wishes to exchange product information (primarily stock quantity) via small text files that they will get/put via FTP to their website. (Currently, they FTP 10 csv files every day which I parse and use to update their website, so hopefully I can build on that). I think writing the files won't be difficult, but I imagine that I'll have to somehow monitor a directory, looking for new files and/or changes to existing files. I'd instigate the action on my end, then wait for a response via ftp and respond by parsing the new file and responding accordingly. I'm most worried about detecting the incoming files: any ideas on how this can be done? Maybe only start 'watching' after the initial action? Any other thoughts about parsing/writing/deleting the files? I'd appreciate any thoughts, ideas, etc. - Paul
  4. Hi all. I've used this module loads of times but I'm having a problem now. I've imported a long list of redirects that I've grabbed from a sitemap.xml file. They imported fine and looked good. When I came back a few days later, many (if not most) of the 'redirect to' entries turned into 5 digits preceded by a carat character (^). See screen shot. I've tried a few times since, including pasting in the list in small chunks. Any idea what is going on?
  5. @Jan RomeroThanks. I did try that with limited success. For some reason, it would only return the same 12 category pages then stop. I ended up doing something completely different (getting the categories, then getting the products for each by converting those spaces to pipes ( | ) and using the text as a selector. Much simpler and more 'ProcessWirey'. Thanks for leading me there.
  6. I'm sorry if this has been covered before. I can't seem to get my head around how I do this. I have a bunch of Product pages with product codes (just say P1, P2, P3, etc). Different products may be displayed on the site depending on many criteria, including what region you are in (EU, USA, GB). Each product belongs to a Category page, but this relationship is set in a Category page field called product_codes which contains a number of product codes separated by spaces (P1 P2 P5 P6 ...). I need to display only the Category pages for those products in my found products list. If I were doing this from scratch, I probably would have structured this differently, but the data comes from frequently updated CSV files. Is this a case of creating an array from $category->product_codes and searching through those or creating a selector from that field with pipes (P1|P2|P3)? Thanks all.
  7. Ok, a little more research turned up a topic about merging different arrays and that led me to explode my page array then use the above-mentioned json_decode/encode thing to convert to a standard array. I don't quite understand how that works, but it does, so I'm a happy camper. $entriesList = wire('pages')->find("template=options-page, title=$id, limit=1")->explode(['title', 'sku_code', ... ]); $entriesList = json_decode(json_encode($entriesList), true); /// CONVERT TO STANDARD ARRAY
  8. Hi all. This is where my lack of actual PHP knowledge is getting to me. I've inherited a never-completed WordPress website that I'm trying to redo in PW. There are products, categories and product options all supplied as separate CSV files. (These will be edited and uploaded every day, so I will need to eventually import the data with a chron script). Importing and displaying the category and product data isn't a problem, but the product options files contains numerous fields with comma- and pipe-delimited strings which need to be converted into arrays. So, when viewing the product-page (template) for 'Chair 123' (product code 'c123'), I'd normally get all the options like '$options = $pages->find('template=options-page, pcode=c123'); But since there are fields in the options-page that look like "505|501|512" (for color codes), I'll need to get these into an array. Thats' very simplified; the actual options page has about 45 fields, used to present various options in 3 worldwide territories with multiple parts/color combinations for each conditional territory! I should also mention that I have the old WordPress site and can see the custom functions the previous guy had set up and (for me) it's very complicated. Most of it is standard PHP, so I was hoping to use much of it 'as is' as I can. For instance, there's a function on the products page that returns an associative array that looks like this (in the WordPress php): $bt_options = bt_get_product_options($entry["code"]); foreach($bt_options['spec_docs'] as $key => $bt_spec_doc) { $bt_show_download = ""; if($bt_options['spec_docs_territory'][$key] == "E" && $bt_this_territory == "EU") { $bt_show_download = "Y"; } elseif($bt_options['spec_docs_territory'][$key] == "U" && $bt_this_territory == "US") { $bt_show_download = "Y"; } ... } And the bt_get_product_options function starts with this (again from WordPress) function bt_get_product_options($id) { global $wpdb, $bt_colours, $mysql_table; $entriesList = $wpdb->get_results("SELECT * FROM ".$mysql_table['options']." WHERE web_product_code = '".$id."' ORDER BY id ASC LIMIT 1"); $entriesList = json_decode(json_encode($entriesList), true); /// CONVERT TO STANDARD ARRAY if(count($entriesList) > 0){ $output = array(); $output['jquery'] = ""; foreach($entriesList as $entry) { ... /// COMBINATION TERRITORY elseif($key == "comb_territory" || $key == "addnl_subtabs_territory" || $key == "spec_docs_territory"){ $ter_array = explode("|", $tt); foreach ($ter_array as $k => $tr) { $output[$key][] = $tr; } } ... loads more like this ... } } return $output; } TL;DR: Can I use the above in my PW code, provided I swap the WP MySQL bit with $entriesList = $(wire)pages->find("template=options-page, product_code=$id, limit=1) ? (I tried this on a limited set of fields but didn't return anything). Or do I need to do a MySQL request too? And from what I can tell, thet json_decode/encode line should covert the page object to an associative array, correct? Should that work in this case? Thanks for reading this far.
  9. @Robin S Ok, that is concise, clear and – now that I see it – much simpler than I thought. As usual, things are always easier with PW. Many, many thanks.
  10. Hi. Sorry about the confusing title. I suspect this might be a case for the owner selector, but I can't figure it out. I've got Video pages (about 140) where each video can be tagged according to subject (tags are a Page Field displayed with checkboxes). Videos are then added to a Client page, also with a multiple checkbox Page field. A client logs onto his/her page to see a number of videos selected for this client, displayed in a grid with a list of the aforementioned tags in a sidebar. Clicking the tags displays/limits the videos via Ajax. All pretty simple (getting all tags, selecting vids by tag page field). Now the client wants to limit the tag list based on the clients' available videos (so they only see the categories of 'their' videos). I'm not sure how to select just the tags that are included in the videos that are included in the client page. It's probably simpler than I think. I suspect I need to get the 'owners' of the PageField for the videos of the client, but I'm not sure how to construct that. Any pointers? Thanks in advance. Oh, and these are fitness videos. Although, I suppose they could be just about anything... Paul
  11. @AndZyk Thanks for the response, but this doesn't work. I'm using the Body field, a CKEdit textarea field. When the text was imported, wasn't formatted with <p> tags. Those tags are added (via javascript presumably) when a page of that field type is loaded for the first time in the admin. I think one solution might be to just do a find/replace on that field using the API and add <p> and </p> tags, maybe replacing double line breaks with </p><p> or something. Of course, while working on the site, many of those fields are now properly formatted, so I may make things worse on those pages. I'll have a look at the database content before proceeding.
  12. Hi folks. I've just imported about 200 entries into a site. There's a 'biography' text field that imported into a Body field using the CKEditor. My problem is that when I visit any page with this biography field, the text doesn't look properly formatted (the line-spacing is too tight) because it isn't contained by <p> tags. It looks like the <p> tags are added by CKEditor only when you open/save that page in the Admin editor. I don't want to have to open and save every one of those 200 pages. Does anyone know of a way to do this in the API or something? Cheers!
  13. @Zeka I had a chance to try this. Your selector worked perfectly, thanks again!.
  14. Thanks @Zeka! I didn’t know about ‘owner’. That sounds awesome. I’ve clocked off for the day (with a large Negroni) but look forward to trying this first thing in the morning. Reading that post was enlightening.
  15. Hi. Sorry if this has been covered someplace. I've got a Conventions site with Events pages. Among other things, each Event has a bunch of Topics and each Topic can have one or more Speakers. The same Speakers crop up again and again, so I've set up a page field for them. I'd like to display all the Speakers involved in the Event (basically, 'crawl' all the Topics and retrieve the Speakers, deal with duplicates and display them). And, the Topics are 'grandchildren' of the Events page (since I have other items on the Events page and want to keep things tidy?). Speakers -- Jane Doe -- John Smith -- Bob Jones Events -- Event One (Event Speakers: Jane Doe, Bob Jones, John Smith) ---- Topics ------- Topic 1 (Speakers: Jane Doe, Bob Jones) (assigned with a Multiple Page field from Speakers) ------- Topic 2 (Speakers: Bob Jones, John Smith) -- Event Two ... Once I found out how to access data on a grandchild page, I did used this selector: $speakers = $page->find('template=topic-page')->event_speakers(); That returned an array which when looped gave me this: 1840|1843 1843|1841 So, that's the IDs of the 3 speaker pages, with one duplicate, but I don't know what to do with this! Any ideas folks? Or is there another way that I'm missing? Thanks!
  16. @Flashmaster82 I've just had a look at how I did this before. I used a select option field to list a booking times (10:00am, 10:30am, etc). I probably got this from someone else on these forums because my comments for the code were more detailed than I usually do! Rather than use the message in the module settings, override it and use a message.php file: $scf = $modules->get('SimpleContactForm'); include("./message.php"); $options = array( 'emailMessage' => $emailMessage, ... Note: you shouldn't need 'offert_typeoffacility' => 'offert_typeoffacility->title' in the options. In message.php, sanitise and get the field title like this: $facility = $sanitizer->int($input->post->offert_typeoffacility); // (other fields)... // To get the value of an Options Field Type, you need to // first get the id submitted // then get all the options for that field // then use the eq for that option to get the title (eq starts with 0, so subtract 1 from the id) $field = $fields->get('offert_typeoffacility'); $all_options = $field->type->getOptions($field); $theFacility = $all_options->eq($facility - 1)->title; $emailMessage = "Hello, Option: {$theFacility} ... "; I try to use Page Reference fields for SimpleContactForm selects now because it's even easier: $theFacility = $pages->get($facility)->title;
  17. I've just encountered the same issue. Tried to install a module on a site I had finished about 5 months ago. Tried adding the various config settings, etc. k07n's suggestion to check the php zip rang a bell. Only then did I see that I was on php 5.x (which I updated to 7.3) and had zip disabled. That did the trick!
  18. Sorry folks. I've decided to restore and do over. Please disregard; I was a bit stressed when I first posted!
  19. Hi all. I'm in a bit of a jam: I've been working on a site and suddenly received the following error (TraceyDebugger installed): Exception: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined (in ....... /public_html/clients/omnia/wire/core/PageFinder.php line 627) I get it on all front end pages. I'm not sure what I did to trigger it but I desperately need to fix it. I do have a backup from yesterday, but I've done loads of updates. Any ideas where to start? Or should I restore and do over?
  20. My 2cents worth: I frequently add a credit line in the footer of my sites and like to provide a field in my settings to add links. To keep the rich text capabilities but strip out the paragraph tags so the content can be used inline, I use this function on the field: function stripParas($string) { $string = str_replace(array("<p>", "</p>"), "", $string); return $string; }
  21. @PWaddict Happy to help. SimpleContactForm and FlyDev's ReCaptcha did all the real work.
  22. @PWaddict Yes, I've got it working. I made a simple InputField that works with FlyDev's MarkupGoogleRecaptcha module so the reCaptcha can be added to the SimpleContactForm. Then, using the info on the SFC instructions page, I added the following hood to my ready.php file. I've attached the zip file of my field type if you want to take a look. I'm no expert, but I based it on another simple module. $this->addHookBefore('SimpleContactForm::processValidation', function(HookEvent $event) { $form = $event->arguments(0); $recaptcha = $form->get('recaptcha'); if (!$this->input->post->{'g-recaptcha-response'}) { // attach an error to the field $recaptcha->error(__('You didn\'t pass the reCaptcha test.')); // it will be displayed along the field } }); FieldtypeRecaptcha.zip
  23. @Zeka No problem, thanks for the suggestion. I'll have a look. ?
  24. Hi @Zeka Thanks, but I probably haven't explained it correctly. The Category pages are not actual page trees (the products are already organised under as pages under the product type pages; I use sort=sort on those). The Category pages have no children and fetch their related content not as children but with a 'find' selector. The client wishes to reorder pages differently under Categories than their 'natural' order under Product Type.
  25. I've got an existing site where the client wants to add a custom sort order to his products when viewed on the Categories page. Categories are a Page field type and the products are already manually sorted by Product Type. And a product can appear in more than one category. If it were a 1-to-1 relationship, I'd just add an integer field to the product for a custom sort order field. But some products have 1 category, some have 4. Some categories apply to only a dozen or so product; some apply to 300 or 400. (He's supplied a spreadsheet to import). Even if I figure out how to sort these, will the client be able to add new products and alter/insert a sort order? Here's an illustration: Products (Actual page hierarchy in the Admin. These are sorted manually and appear in this order on the front end when viewing a 'Product Type' page) - Bracelets -- Product 1 -- Product 2 -- Product 3 - Earrings -- Product 4 -- Product 5 ... In the front end, when viewing by Category, we'd like to display the products in a custom order per category: - Amber - $pages->find("template=product, category=$page->title, sort ???") -- Product 1 -- Product 4 -- Product 3 - Silver -- Product 2 -- Product 5 -- Product 3 ... When I thought he was only going to sort the first page of results (18 or so), I was going to add a new page field type for each category so the client could select a limited amount of products to display first (I do this for the 'related products' section of the product page). Then I would select these first, then select the unsorted products (minus the first batch) and append them. But since the client wants to sort hundreds of products this way, I don't think this method would be practical. I've seen a similar post where Teppo uses a single field as an array, but I'm not sure if this would work or if I could populate the field from my spreadsheet. I welcome any ideas! Thanks.
  • Create New...