Jump to content

gebeer

Members
  • Posts

    1,489
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by gebeer

  1. Could you please share a link to the mailgun docs where this is mentioned. Thank you. EDIT: Never mind. I found it: https://documentation.mailgun.com/en/latest/api-intro.html#mailgun-regions
  2. From the API side it is still valid and working code. I don't think there is one best way to go. This tutorial shows one possible approach. There are many different other approaches possible. But at least it shows the basics of implementing a REST API. You can also have a look at https://modules.processwire.com/modules/rest-api-profile/ which is the most recent approach I'm aware of.
  3. @Peter Knight What do you want to do with products that do not have images? In your foreach you define the $image variable only when there are images. Then you echo the images even if there are none. This will give you a PHP notice for $image is undefined. You'd need another if condition within your echo to check for isset($image) and only output the image if there is one. The way you setup your images field it should definitely return an empty array if there are no images so the if (count($prod->images)) should work as expected.
  4. This is an option only for visitors with JS enabled. I decided to copy the module to site/modules and extend it there. Though it would be really nice if we could extend the comments form with hooks.
  5. Hello, I need to add a checkbox to the comments form to make it GDPR compliant and I guess I'm not the only one... Doing a search and looking at the FieldTypeComments module file it seems that the only way to add custom fields to the form is by copying the module to site/modules and apply the changes there. I am just wondering why the comment form is not driven by the PW form API and also why none of the methods in that module are hookable? Would be much appreciated if you could share your approaches on handling this.
  6. don't think so since the error method is not hookable nor is any other method in that class that would give you access to what you need.
  7. If you don't want to change the core Inputfield.php that @PWaddict points to, you can copy the whole Inputfield module folder to site/modules and apply your changes there. When you then refresh the modules in the backend PW will ask you from which location the module should be loaded.
  8. Have you tried <?php // get all pages in page field sorted by manual sort order $resultsAllSorted = $page->my_page_field->sort('sort'); // filter $resultsCategory = $resultsAllSorted->filter('category=1474'); // loop foreach($resultsCategory as $result) { // ... } ?
  9. @Fantomas Thank you for letting me know. I had tried the second notation that you mentioned with exactly the same code I put in Rest.php. But on my server environment this wouldn't work. Because HTTP_AUTHORIZATION was always empty. I never tried REDIRECT_HTTP_AUTHORIZATION. It did not occur to me since in the .htaccess rewrite rule it defines HTTP_AUTHORIZATION. So you pointed me to the final piece of the puzzle. Thanks again for that. I now can implement this in a way that it will properly work in most server environments.
  10. @uliverse You can still use the Leaflet module and read through this thread from the link I recommended in my last post. Then have a look at how BrendonKoz and patman solved it in their forks. Seems like they have a readily available solution.
  11. This module is meant to give a lt/lng position of an address so we can display a marker on a map. It is not an address field type. When you set the marker on the page that you edit, it will get the address for the lat/lng that you have set in the GUI by reverse geocoding it through the Google geocoding API. This returns the long address string that you can get in your template with $page->mylocationfieldname->address. To answer your question, there are ways to get a properly formatted address but all of them involve some work: 1. extend the module yourself to store address parts. Or read posts in this thread from here on and than use @BrendonKoz or @patman forks: 2. add fields to your template for postcode, street address, city, country. Fill them manually when you edit the page. Then you can render them in your templates. This should be the easiest way. 3. switch to the Map Marker Module which uses Google Maps and read from this post on where @adrian has extended the functionality to give you exactly what you want:
  12. Unfortunately this is not well documented in the API reference?
  13. You can send an $options array with the render method and use that in child.php So in your Hanna code echo $child->render(array("useMain" => false)); Then in child.php before your other markup <? if(isset($options['useMain'])) $useMain = $options['useMain']; // this will give you false when rendered from Hanna code ?> and somewhere in the top area of your your _main.php <? if(isset($useMain) && !$useMain) return; ?> This will take care of not rendering _main.php
  14. @Fantomas @Batyr Place this at the top of your .htaccess and try again SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0 This should make $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] available in fastcgi/cgi environments. It works in my server setup. Please report back if this fix also works for you.
  15. @Fantomas Is you server setup Apache with PHP running in fast cgi mode? Then $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] will not be populated. I just setup my tutorial in a fast cgi environment and could reproduce your problem. I also found the problem and a possible solution and will implement that into the Rest.php gist and let you know once it is updated.
  16. @Fantomas can you post your request header please?
  17. very good writeup and great website! Would you be willing to share your rsync setup for uploading changed files? I love rsync and use it a lot. Does your setup connect to git commit in any way?
  18. if ($prod->images) will always return true, since your images field can hold more than one. Use if ($prod->images->count) instead. That should resolve the error for empty image fields.
  19. @Karl_T Glad it works. Using markup regions implies the use of the delayed output strategy. So your good to go ? $useMain was introduced in the advanced site profile that ships with PW and has been around for quite a while. Since many people adapted that, you see $useMain mentioned a lot throughout the forum. But it has nothing to do with the API.
  20. PW is still supoorting it if you are using the delayed output strategy in your templates. $useMain has become kind of a convention when using this strategy, but infact, it is just a user defined variable. You could call it $includeMain or whatever you want. How I use $useMain: 1. in my _init.php I define $useMain = true; So it is true by default and the _main.php will be appended to all template php files. In the top area of the _main.php I do somethinmg like this if(!$useMain) return; // if $useMain is set to false in a template php file, then do not render _main.php Then in the template where I don't want _main.php to get appended, I set $useMain = false; In your case, when you don't want to have _main.php appended for AJAX calls you can do this in the template that receives the AJAX request if($config->ajax) $useMain = false; Of course this concept only works for the delayed output strategy.
  21. @Zeka you need to go to Gmail settings and allow access for less secure apps there. Then it should work.
  22. I am right now working on a quite similar project. In my case I import from an XML that I get through an API and populate product pages, check for there status etc. I can encourage you to go on the way you started. It is all pretty straight forward and nice to handle with the PW API. Your import code looks basically fine. So you shouldn't have major problems there. I set up a process module that creates a page in the backend where admins can manually trigger imports. If you would like to go that route, there is a skeleton Hello Process module that you can use and @bernhard wrote a great article on building admin pages with process modules. I find this approach much cleaner than doing all the logic in a template file. Regarding your concerns Use lazy cron module for automation. Each time you get a new JSON, loop through it and compare it to the single-movie pages you have and act on them (modify/delete) or create new ones. You can use custom fields on the single-movie template to store that Have a look at https://github.com/webcreate/infinite-ajax-scroll You can use kongondos Blog module or at least get a lot of inspiration from it ;-)
  23. What makes you think that this is an ongoing work? I have used the techniques outlined in that post in many occasions and it works fine, be it in the admin or even on the frontend with forms built by API. EDIT: As long as your using the default admin theme you should be fine
  24. Up until now not one of the many softwares on github that I have been using even had branding attached. With pro modules the user knows exactly what to expect: buy and then use. With free modules that ask for money to remove brandings, the user could feel tricked. I'd rather prefer that for the same reason mentioned above. I happily pay for pro modules and use them a lot. I totally respect the way you see things in this matter and it is your freedom as a module developer to handle things like you do. Just wanted to share my thouights and feelings about it and explain some negative views people might have on your approach, especially since it is the first time I come across this in the PW module world. Enough said. Thank you for everything you're giving to the community and keep up the great work!
  25. Hi, just wanted to share something I came across while working on an import module for XML data from a web service. The XML I got was not huge, but still, loading around 3.5 MB of XML with 250+ large child nodes into memory at once with simplexml_load_file() and then looping over it had significant impact on performance. I searched for a solution and found this great article about how to parse large XML files. It basically explains how to utilize the native XMLReader class together with SimpleXMLElement to handle such situations in a memory efficient way. After implementing it I got a significant improval on perceived performance. No comparison in numbers to share here as I'm a bit short on time.
×
×
  • Create New...