Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by daniel_puehringer

  1. Servus Bernhard! Thank you so much - that seems like a way better approach ☺️
  2. Hey community! I would love to combine the functionalities of a Cronjob (using Lazycron Module) and the Processwire $cache API. Idea: I want to fetch a big amount of data (HTML-Markup; many <table>-Elements) from one single website (https://www.targetwebsite.com/) at around 05:00 am each day (every 24hours) and store this fetched information for around 24hours. I then want to display this information in one template of my website (https://mywebsite.com/subpage-where-cached-data-should-be-shown) and ideally (since I bought ProCache) cache the entire Page for 24hours to be superfast. After those 24hours a new request should fetch the data from https://targetwebsite.com/, overwrite the existing day from the day before and the whole cycle starts again. I also thought about only using the $cache->get(...) method like this $cachedVariable = $cache->get('foo', 86400, function() {// 86400 = 1day //call target website and store data directly as $cachedVariable instead of using a hook }); However using a cronjob for this somehow seems technically better and more advanced because the first user calling the website in the morning would suffer a very long loading time. However, if nothing works I'm thinking about calling my own website as a hook and therefore beeing the first but only user who suffers a long loading time. Anyways, my current code snippet looks like this: // create your hook function function fetchDataDaily(HookEvent $e) { // Get an instance of WireHttp $cache->delete('foo'); $http = new WireHttp(); // Get the contents of a URL $response = $http->get("https://targetwebsite.com/"); if($response !== false) { $cachedVariable = $cache->get('foo', 86400, function() {//86400seconds refer to 1 day $responseFromWebsite = $sanitizer->entities($response); return $responseFromWebsite; }); } else { //echo "HTTP request failed: " . $http->getError(); } } // add a hook to your function: wire()->addHook('LazyCron::everyMinute', null, 'fetchDataDaily'); When I render the page this error is printed: Notice: Undefined variable: cache in /html/.../site/assets/cache/FileCompiler/site/templates/home.php on line 52 I would really appreciate your thoughts on this - have you every had a similar problem? If so, how did you solve it? Sadly I could not find any matching posts to this problem so far. All the best, Daniel
  3. Hi @kongondo Thanks for your reply ? Sadly this did not work either, however I have now found an error message which sounds promising: 2021-11-29 10:20:35 guest https://example.com/processwire/contentelements/ce-33/ Fatal Error: Uncaught Error: Call to undefined function __() in /var/www/html/site/templates/components/home-content.php:75 Stack trace: #0 /var/www/html/site/templates/ce-includer.php(10): include() #1 /var/www/html/wire/core/TemplateFile.php(327): require('/var/www/html/s...') #2 /var/www/html/wire/core/Wire.php(414): ProcessWire\TemplateFile->___render() #3 /var/www/html/wire/core/WireHooks.php(951): ProcessWire\Wire->_callMethod('___render', Array) #4 /var/www/html/wire/core/Wire.php(485): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array) #5 /var/www/html/wire/modules/PageRender.module(554): ProcessWire\Wire->__call('render', Array) #6 /var/www/html/wire/core/Wire.php(417): ProcessWire\PageRender->___renderPage(Object(ProcessWire\HookEvent)) #7 /var/www/html/wire/core/WireHooks.php(951): ProcessWire\Wire->_callMethod('___renderPage', Array) #8 /var/www/html/wire/core/Wire.php(485): ProcessWire\WireHooks->runHooks(Object(ProcessWire\PageRender), 'renderPage', Array) #9 /var/www/html/wir (line 75 of /var/www/html/site/templates/components/home-content.php) It seems to me as if there was a problem with the scope:, however I don´t know what to do with this information since I have little experience with the Wire Objecs and Hooks. Maybe someone else does ? Greetings, Daniel
  4. Hey community, first of all: I love this CMS! But unfortunately my Code Internationalization (i18n) doesn´t work within included php files: I´m using the module Pro Fields Page Table, the regular Languages Support Module and no template caching. The website has 2 Languages (DE as default, EN as second language) Problem: Using <?php echo(__('Test')); ?> within /site/templates/home.php works without any problems and gets translated correctly However using <?php echo($this->_('Headline'));?> within /site/templates/components/component.php does not work. Note: using <?php echo(__('Headline'));?> in .../component.php throws an error and therefore cannot be used. Example: /site/templates/ce-includer.php (Template with the dynamic text-field 'filepath'): include('components/'.$page->filepath); this correclty includes the file "/site/templates/components/home-content.php" Code in home-content.php: <h1><?php echo($this->_('Headline'));?></h1> Output for both pages (DE and EN version - the string was translated to "Headline DE" in german and "Headline EN" in english): <h1>Headline</h1> Does anyone know how to use Code Internationalization in such a szenario? All the best and keep up the great work! Daniel
  5. Hi community, I am using the "PageTable" Module (also called "ProFields: Page Table") and the built in "Language" Module (also called "Languages Support"). With the help of PageTable I was able to create several content elements which should usually be displayed in German(default language) and English. However some Content Elements should only be shown in German and NOT in English. Well sounds easy, right? Not so fast. I really love this CMS, but I have not found a solution for this problem yet. As you can see in the screenshots attached I tried to uncheck the "active" Checkbox for the english language to completely hide the content element for english users. However no matter what I do the german text shows on the english page. If I leave the "content-should-not-be-shown-in-english"(see Screenshot Number 2) blank and save the page, the page will inherit the german page url "content-element-with-simple-text-which-should-only-be-shown-in-german". My question therefore is: How can I hide a specific content-element for only one language? I´m using the latest processwire & module versions. The code which I use to render the content elements looks like this: //Info: contentelements is a field of type "ProFields: Page Table" <?php foreach ($page->contentelements as $element): echo($element->render()); endforeach; ?> filename: basic-page.php I would really appreciate your help since I haven´t found a solution after reading through quite a lot of forum posts. All the best, Dani
  6. Hey, so we all know about SEO and the importance of performance. Basically we do it, because if no one finds the website we just built, it´s frustrating. We all try to write clean markup, css and js code and most might have a webpack/gulp/whatever pipeline to minimize css&js. But when thinking about it, optimizing your pipeline might save you a few (hundreds) of kb, compared to loading an image with 1 mb that´s literally nothing and frankly just ridiculous. Don´t get me wrong, frontend pipelines are great and should be used, but let´s shift your "I will optimize the shit out of that 3 css lines" focus to something different: try to serve images as fast as possible, this is where the performance boost really happens. I´m no pro on processwire so far, but I built a very easy to use picture element, which some of you could find interesting: 1. the picture comes with 3 different sizes: one for mobile (keep in mind the double dpi, therefore width of 828px), one for tablet and one for desktop 2. the picture generates a webp version and the original file extension as a fallback 3. the filesize of each element is rendered within the "data" attribute 4. lazy loading(sooo important!!!) is done via the native 'loading="lazy"' attribute. Please try it out and see the difference ? I posted this so others can easily optimize their images, but I would also like to hear your suggestions in making it better. Maybe you could decrease the rendering time or maybe you have some easy improvements. Please let me know. Greetings from Austria! <picture> <source data="<?php echo($oElement->repeater_image->width(828)->webp->filesize);?>" media="(max-width: 414px)" srcset="<?php echo($oElement->repeater_image->width(828)->webp->url) ?> 2x" type="image/webp"> <source data="<?php echo($oElement->repeater_image->width(828)->filesize) ?>" media="(max-width: 414px)" srcset="<?php echo($oElement->repeater_image->width(828)->url) ?> 2x" type="image/<?php echo($oElement->repeater_image->ext)?>"> <source data="<?php echo($oElement->repeater_image->width(767)->webp->filesize) ?>" media="(min-width: 415) and (max-width: 767px)" srcset="<?php echo($oElement->repeater_image->width(767)->webp->url) ?> 2x" type="image/webp"> <source data="<?php echo($oElement->repeater_image->width(767)->filesize) ?>" media="(min-width: 415) and (max-width: 767px)" srcset="<?php echo($oElement->repeater_image->width(767)->url) ?> 2x" type="image/<?php echo($oElement->repeater_image->ext)?>"> <source data="<?php echo($oElement->repeater_image->webp->filesize) ?>" media="(min-width: 768px)" srcset="<?php echo($oElement->repeater_image->webp->url) ?>" type="image/webp"> <source data="<?php echo($oElement->repeater_image->filesize) ?>" media="(min-width: 768px)" srcset="<?php echo($oElement->repeater_image->url) ?>" type="image/<?php echo($oElement->repeater_image->ext)?>"> <img data="<?php echo($oElement->repeater_image->filesize) ?>" class="img-fluid" loading="lazy" src="<?php echo($oElement->repeater_image->url) ?>" alt="<?php echo($oElement->repeater_image->description) ?>" type="image/<?php echo($oElement->repeater_image->ext)?>"> </picture>
  7. Hi Fruid, my .htaccess file is attached. Search for the lines #the 2options underneath throws the 500error #Options +FollowSymLinks #Options +SymLinksifOwnerMatch Greetings, Daniel .htaccess
  8. Hi community, thanks for the great work you do ? I´m looking for a global field which can be used in the footer and has only one instance for all pages. So I´m kind of looking for "One field to rule them all". Reason for my question: The website I´m currently building has one footer for all pages. The content of the footer should be dynamic - therefore I made a global field which is automatically inserted into each page. Problem: if I want to change something in the footer, I have to do it for all fields, because each field has it´s own instance. Question: is it possible to have one global field in which changes the content for the footer of all pages? In most CMS Systems a simple solution to this is often impossible, I hope that processwire is different ? All the best, Daniel
  9. Question: What solutions would you have to navigate to the parent page of a dropdown menu? Hi, thanks for the great tutorial - I tried it out (slightly adjusted it) and it worked very smoothly ? But I do have one question about the dropdown: Imagine you have a site structure like: A B B1 B2 B3 C Then B would be a Dropdown Menu because it has 3 Subpages. If you click on "B", the Dropdown Menu opens and you can navigate to B1, B2 & B3. Problem: How can you navigate to "B"? Can you create a new Subpage of B and make a redirect within processwire like B B1 B2 B3 B4 (--> this page redirects to /B because B only opens the dropdown) I would really appreciate your help, all the best!
  10. Hi Dragan, thanks for the advice: Actually, the rewrite base was not the problem - but the #Options +FollowSymLinks #Options +SymLinksifOwnerMatch was. I found this error by checking the error logs. Now it works fine!
  11. Hi Community, Sadly I cannot intall ProcessWire on my webserver (Hosted at https://www.world4you.com/de/startseite.html, a small hosting provider in Austria) Here is the Problem: 1. I downloaded the current masterbranch as a .zip file (After a few tries I also downloaded the code via the git clone command, that led to the same error), unzipped it and transferred it to my server. Since there is already a wordpress site installed on the root directory, I transferred the processwire files into /relaunch and created a subdomain. 2. I tried to install the language starter kit. As soon as I navigate to that folder Screenshot1 (see attached file 'processWireBug1') is shown. Everything looks nice, except the red text referring to the 'mod_rewrite' rule. The webserver provides the 'apache mod_rewrite' rule. 3. As soon as I want to press 'Check again' or 'Continue to next step' an error Page with 500 error (see Screenshot 'processWireBug2') occurs. 4. You can find my .htaccess file attached to this post..htaccess How could I solve this issue? Some additional information: 1) the webserver provides the apache mod_rewrite (I checked that several times) and has php version 7.3. installed. 2) since there is a wordpress site installed on the root directory, there is also a .htaccess file on the root directory. Could this .htaccess file have an impact on the .htaccess file for my processwire website? Thanks for your help and greetings from Austria, Daniel
  • Create New...