Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/04/2020 in all areas

  1. Thanks, but not necessary. Pretty much all my modules get created because I have a need for them in work that I get paid to do, and it doesn't cost me anything to make them available for others to use too.
    4 points
  2. Where exactly? "on the admin page" is a bit vague... In the top menu? In a particular page when in page-edit mode? In the page-tree? elsewhere? For use-case 2, you could try https://modules.processwire.com/modules/fieldtype-runtime-markup/ Another very useful module is https://modules.processwire.com/modules/page-field-info/ - especially if you need to provide contextual information based on your selection (checkboxes, radio buttons, page fields, options...).
    2 points
  3. Hello all, wasn't sure where to put this, so it goes in General section. Ryan shows a hook that we can use to mirror files on demand from live server to development environment to be up to date with the files on the server without having to download complete site/assets/files folder. I just implemented this but had problems getting files to load from a site in development that is secured with user/password via htaccess. First I tried to use WireHttp setHeader method for basic authentication like this function mirrorFilesfromLiveServer(HookEvent $event) { $config = $event->wire('config'); $file = $event->return; if ($event->method == 'url') { // convert url to disk path $file = $config->paths->root . substr($file, strlen($config->urls->root)); } if (!file_exists($file)) { // download file from source if it doesn't exist here $src = 'http://mydomain.com/site/assets/files/'; $url = str_replace($config->paths->files, $src, $file); $http = new WireHttp(); // basic authentication $u = 'myuser'; $pw = 'mypassword'; $http->setHeader('Authorization: Basic', base64_encode("$u:$pw")); $http->download($url, $file); } } But, unfortunately this didn't work. So now I am using curl to do the download. My hook function now looks like this function mirrorFilesfromLiveServer(HookEvent $event) { $config = $event->wire('config'); $file = $event->return; if ($event->method == 'url') { // convert url to disk path $file = $config->paths->root . substr($file, strlen($config->urls->root)); } if (!file_exists($file)) { // download file from source if it doesn't exist here $src = 'http://mydomain.com/site/assets/files/'; $fp = fopen($file, 'w+'); // init file pointer $url = str_replace($config->paths->files, $src, $file); $u = 'myuser'; $pw = 'mypassword'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 50); // crazy high timeout just in case there are very large files curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, "$u:$pw"); // authentication curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); // authentication curl_setopt($ch, CURLOPT_FILE, $fp); // give curl the file pointer so that it can write to it curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); } } Now I can load files and images from the htaccess protected development server ? If anyone knows how to get this to work with WireHttp, please let me know. Thank you.
    2 points
  4. Hello @gebeer (and @grimezy) and thanks for the info! I was able to reproduce this and it was purely silly mistake I made when I was rearranging stuff. The is_array check in this condition is there only to prevent such a warning in array_key_exists function. This is now fixed in 1.2.1 version. And finally in 1.2.2 version. While I was there I also added conditional autoload to block admin pages which is proposed by @tpr in this thread already long ago. Thanks!
    2 points
  5. @thomasaull It seems I found what was the mistake. It was necessary to transfer the dispatch from Insomnia to the multipart format and set the file name. After that, in the $_FILES variable you can find all the data to get the file. $_FILES Array( [upfile]=>Array( [name]=>hot-pizza.jpeg [type]=>image/jpeg [tmp_name]=>/localhost/tmp/phptAUnX5 [error]=>0 [size]=>65639 ) )
    1 point
  6. Have you also installed the FieldtypeToggle module?
    1 point
  7. Update - Version 0.0.6 Minor CSS-Debugging (hiding the choose button when no cookie group is selected) Added ProCache support for the script tag, when ProCache is installed
    1 point
  8. Thanks a lot, dragan. You’re right, I should have specified the "where" a bit more – in this case I meant the page itself in edit mode as in your case 2. Anyway, I checked out the runtime markup field and it does exactly what I was looking for with very little effort. Perfect solution!
    1 point
  9. You are why the internet thrives. Thanks, Robin.
    1 point
  10. You can check $page->prev() and $page->next() to find siblings matching a selector. You need of course some criteria to identify the "Completed" page – if using an ID is not an option, you could use the name or title of the page. Here are some code examples (those assume $page is the "In Progress" page): // will be true if the "Completed" page is somewhere before the current $page $CompletedIsBefore = $page->prev('title="Completed"')->id !== 0; // will be true if the "Completed" page is somewhere after the current $page $CompletedIsAfter = $page->next('title="Completed"')->id !== 0; // will be true if the "Completed" page comes directly before the current $page $CompletedIsPreviousPage = $page->prev()->matches('title="Completed"'); See $page->prev() and $page->next() in the API reference.
    1 point
  11. v0.3.0 released. Notable changes in this version: 1. Fix for page clone issue reported by @a-ok in the post above. 2. The module now hooks Pages::save() and Pages::saveField() instead of Pages::saveReady() and Pages::saveFieldReady() in order to work around this core issue. Hopefully that issue gets resolved and then the module can go back to saveReady hooks because those would be preferable, but for now something had to be done because the issue was making page changes unsaveable when "single" Page Reference fields were configured in this module.
    1 point
  12. I think the question should be what type of application are you looking to build that requires MVC ? because I find PW appropriate for making proper CMS sites, anything other than that, then you should be using a proper MVC for such, there will be scenarios you will encounter, I doubt you would want to tweak PW to fit uncovered scenario.
    1 point
  13. porl thank you very much I also had a few doubts about this but you dispelled them thank you very much!
    1 point
  14. Have you tried it? There is already support for strtotime strings for datetime fields in PageFinder selectors, and your example query works just as you wrote it. ? For in-memory (WireArray) selectors you have to use a timestamp in the selector.
    1 point
  15. Another perspective: The API acts as the model, with the $page / Page class giving you access to page data through a generic interface. By default, the PHP template file for the current content type / template acts as Controller and View, though you can easily seperate Controller and View by using, for example, a frontend templating library like twig. That's close to my usual setup: View: Twig acts as a View layer, since it gets pretty privileged access to API variables, you can get anything done you'd usually do in a PHP View class. Controller: The PHP template file acts as the Controller, for example processing input and rendering the correct Twig template. Usually, I just keep the template logic procedural, because ProcessWire already does a lot of work in determining the correct template file and setting up API variables. Though you could also use a custom Controller class and just use the template file to instantiate it. Model: As mentioned above, the $page API variable is already a kind of generic model for your data, and for sites that are mostly brochure sites / presentational in nature, this is really all you need. But if you want to go further, you can create custom page classes by extending the Page class and set your template to use that, this way you can make your model as smart as it need to be. I have written two tutorials on how to integrate Twig if you're interested ? Part 1: Extendible template structures Part 2: Custom functionality and integrations
    1 point
  16. I only ever use BS or Foundation just for the grid, mixins and helper / utility classes (.visuallyhidden et al) + normalize (S)CSS. There's nothing wrong with it, and I don't understand people who claim that "every site built with BS looks the same" (or that is has to). It's just a tool. It doesn't dictate anything. As for components, I'm cherry-picking and choose the "best in class" (e.g. PhotoSwipe for lightboxes, Flying Focus) or build my own. An accordion or tab component is a trivial thing to build, and at some point (if you have a very custom design) it's easier than tweaking an existing solution. But of course - it all depends... on budget, deadlines etc.
    1 point
  17. I use BS all the time and my websites never look the same. I change everything I need, it's very easy to use SASS, and its grid and utilities classes are great. Maybe the sites look the same because you/they leave it with the "out of the box" style and layouts. You simply adjust colors, borders, sizes, spaces, fonts, icons, shadows, pictures, backgrounds, etc. and create designs/layouts in a creative/useful way and that's it. But never ever copy and paste the examples and start throwing code on it... and this will happen with any framework you use. You should always start with a good (useful) design of the page, without thinking about its implementation and then use BS or any other tool to do it as it was designed, as simple as that. PS: Ah.. I forgot.. I'm a graphic designer LOL
    1 point
  18. @MarkE - The events just have a page field multiple where you select the works being performed. Some events come in through Boosey and those have a reference ID we store so those are auto assigned. Works pages just have a section that searches for upcoming events and outputs them. But there are a ton of other ways that works are connected to each other, using versions, members and custom taxonomies that focus the relationships that are specified...
    1 point
  19. Hi guys, I was very excited for this module, but my life took a huge direction change and I no longer have the time to invest in module development. I am gonna leave the files here. You guys can take it and run. Maybe there might be something useful here. Maybe not. I still think it's a good idea to do drag and drop modal building in PW. So hopefully one day something like that can come to light. I love this community and I love ProcessWire. Live long and prosper. - Joshua Designme 2.zip
    1 point
  20. sure - i can definitely post a tutorial on how that is put together, will post soon..
    1 point
×
×
  • Create New...