Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/25/2020 in all areas

  1. Hello fellow ProcessWire people! I published an article explaining how I migrated three years worth of running data from Garmin to ProcessWire: https://francescoschwarz.com/articles/running-on-my-own/ Have a great day! Cheers.
    4 points
  2. I really like the input api variable syntax: https://processwire.com/blog/posts/pw-3.0.125/#input-api-variable-upgrades $q = $input->get('q', 'text'); +1, just a little note that you don't need the ELSE and you could also do an include to keep things organized: if($config->ajax) { include("your/ajax/file.php"); $this->halt(); // or use die() } // your template code regarding $this->halt() vs. die() see https://processwire.com/blog/posts/processwire-2.6.8-brings-new-version-of-reno-admin-theme-and-more/#new-this-gt-halt-method-for-use-in-template-files
    3 points
  3. For what I see it appears to be loading the ogv or webm versions and they seem to be encoded like that, try removing the other files and leave mp4.
    2 points
  4. The below assumes that your Page Reference field on the child pages is named "categories". If you want duplicates or don't care about duplicates: foreach($page->children() as $child) { foreach($child->categories as $category) { echo $category->title; } } If you don't want duplicates: // Create empty PageArray that will hold the categories // By default each page can only exist once in a PageArray (hence no duplicates) $categories = new PageArray(); foreach($page->children() as $child) { $categories->add($page->categories); } foreach($categories as $category) { echo $category->title; }
    2 points
  5. $user is not in scope inside a module method. You would use $this->wire('user') in a Wire-derived class (i.e. in a PW module). Info: https://processwire.com/docs/start/api-access/
    2 points
  6. This is one of the most common solutions, but as in everything with PW, it's your call how you do it! What you could do with your approach is place that php script outside of the sites directory which is protected by apache from being accessed directly for security reasons. So on your ajax request, the url is just /archive-list-render.php?q=etc Now, on you archive-list-render.php, load the PW API: <?php //This is the index.php in the web root directory, sibling to site, wire, etc. include("./index.php"); $q = $sanitizer->text($input->get('q')) $foundPages = $pages->find("somfield=$q"); //imaginary doSomethingWithPages method.. $response = doSomethingWithPages($foundPages); echo $response; Another approach for simple cases is using the same page where the ajax requests originates from, and detect if it's an ajax call otherwise render the site. This can get tricky depending on appending or prepending files into the template. (Very well exemplified on Ryan's post bellow) <?php if($config->ajax){ //ajax processing/render stuff } else{ //normal render stuff } Ryan's post:
    2 points
  7. Well, I'm feeling pretty ridiculous that I did not discover that. Nothing like taking the long way around the block. Thanks much elabx, I'll recompress better versions and most likely the issue will be resolved.
    1 point
  8. Thank you Robin S! You've saved me many times over the years.
    1 point
  9. Brain fart. There we go, dot accessed subfields ? Cheers.
    1 point
  10. Try {testimonial.author}, the dot accessed sub-fields or properties, so this should work for most nested fields.
    1 point
  11. There is a setting in the Input tab, where you can set the year range!
    1 point
  12. AJAX request detection is based on the X-Requested-With header. You need to set its value to XMLHttpRequest: // via default settings: axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; // or via config object when making the request: axios.post('/post/', { pageID: this.pageID, text_heading: this.text_heading }, { headers: { 'X-Requested-With': 'XMLHttpRequest' } }) Written in browser and untested, but that's the general idea anyway ?
    1 point
  13. It’s both! A user is a special kind of page. If you look at ProcessWire’s source code, you will see that the User class extends the Page class. At first it’s a little confusing, but it’s pretty cool because you roughly always deal with the same (or quite similar) things in PW. For example, you can find users using selectors just like finding pages of content. You can also modify and save them the same way, as you did in your hook. And if you want to add a field to your user (maybe a profile picture) you know just what to do: create a field and add it to the template, just like any other content.
    1 point
  14. Thx Sergio, sure I'm happy to share some insights. The library is mPdf (version 7) https://mpdf.github.io/ and I created a little helper module and just set it to public if anyone is interested: The custom design is just a regular PDF done by a designer and it is then imported into the pdf as needed (see line one in the next screenshot). My helper module provides a possibility to create only the HTML (not the pdf) so debugging is a lot easier: This is the result. The second logo would be the logo of the actual client of course... CSS is done with LESS, so it is easy to style and modify variables. LESS is compiled via AIOM on the fly without the need of any other compilers/setup. widows/orphans are controlled by a .nopagebreak class that can be applied so some blocks that should stay together: Charts have a fixed size so the amount of text above those charts is limited so that everything stays on one page. To get the TOC working with the custom design without page numbers etc. was quite tricky but finally it works very well. Also the "annex" feature is very nice, where they can upload a custom PDF without background and page numbers and the text is imported in the document automatically with the correct background and page numbers: We just created a word-template with the correct colors, fonts and headline sizes and that's it ?
    1 point
  15. // save user default language $savedLanguage = wire("user")->language; $emailLangauge = wire("languages")->get("german"); wire("user")->language = $emailLangauge; $mail = $yourpage->render(); // restore the original language setting wire("user")->language = $savedLanguage; Not tested
    1 point
  16. <moderator hat: on> Hi everyone, Just want to point out that discussion of Ben's module really belongs in its own thread and not under this one - which is specifically for discussing pwFoo's module. If anyone wants to discuss a possible merger between the two modules, please start a new thread to discuss the possibility and then post a single pointer to the new thread here and in Ben's module's thread. Many thanks! <moderator hat: off>
    1 point
  17. $config->urls->httpRoot https://processwire.com/blog/posts/processwire-2.6.18-updates-pagination-and-seo/#new-http-prefix-available-for-all-config-gt-urls-properties
    1 point
  18. Bumping this old thread to shine some light on an obscure fact about that whitelist for domain names. Here's my story: Moved site from development server to real server. Some users (not all) reported View links sending them to the development server. Never happened to other users. Clearing browser cache did not help. Dumping DB and searching text for the development server domain name did not turn up anything. The only place I could find the development server domain name was in the config file in the array defining $config->httpHosts. Documentation calls $config->httpHosts a whitelist so I assumed I could put both the dev and real domain names in the list and maintain a single config file to use in both places. It's not just a whitelist!! The source code of ProcessWire.php explains that If you have not explicitly set $config->httpHost (note: no "s" on end) and the PHP vars for $_SERVER['SERVER_NAME'] and $_SERVER['HTTP_HOST'] don't match anything in $config->httpHosts (with "s") the getHttpHost function defaults to... "no valid host found, default to first in whitelist" The server's environment variables had the domain with www on it but the server accepts URLs with or without the www and people use either one. My dev site was the first one in the list.
    1 point
  19. Thanks! FormHelper and FrontendUser are my first PHP modules. Written with a really basic knowledge of PHP and also PW (just after my first steps with it ). That's why the first approach ignored the PW hooks and used custom code for that... I learned how to use the power of the PW API and PW hooks. I surprised about the powerful and simple module creation with the PW API and PW hooks! At the moment I moved to some other topics (Linux, Docker, change IDE, ...). But I'll come back to PW soon, because I love PW and also the awesome community here!
    1 point
  20. sort=random in the selector should work.
    1 point
  21. Hi valan, I've found a solution. The translations of the labels (not default) are stored in the 'data' field in the 'fields' table, as JSON. Example: {"label1012":"Weight"} where 1012 is the ID of the language. You can try this code: $label = 'label'; if ($user->language->name != 'default') { $label = "label{$user->language}"; } // Output label in correct language echo $user->fields->get('field')->$label;
    1 point
×
×
  • Create New...