• Content count

  • Joined

  • Last visited

Community Reputation

21 Excellent

About laban

  • Rank
    Full Member

Contact Methods

  • Website URL

Profile Information

  • Gender
  1. A couple of days ago my site went down for about 3–4 hours, due to what Cpanal calls EPf faults. There was over 300.000+ faults in total over the span of a few hours, resulting in a 508 error. I talked to my shared host support, which did not say anything about attacks or high traffic (this is a low traffic site on a decent shared host solution). But they said that the problem was the .htaccess file. Thing is, I've been using the same .htaccess file for months. Being said, I updated the file to a «out of the box» ProcessWire file with a few uncomments, and htaccess files from other installations of mine, but it did not seem to work stopping the 508. I ended up with a htaccess file from another installation, with the ProCache code implemented. And just when I removed that part, the page started working again. It might be coincidental, that it was just some processes that stopped or services that restartet. I don't know. What I do know is that ProCache was mostly turned off on my templates, which I have later turned on. All in all, I don't exactly know what the problem was, or what the solution could be. I'm hoping ProCache will work. If it even could help solve such a problem. What I am actually asking is, have anybody else had this problem? (Attacks, bad coding, cache turned off …?) Could ProDevTools shine a light on the issue if the webpage shows 508 due to a high number of faults? (Sorry for the messy post by the way, a lot of unstructured thoughts.)
  2. Here is my solution for large sitemaps containing thousands upon thousands of pages, without the trouble of timeouts and such. I'm currently running this on website with 170.000+ pages. Relying only upon the ProcessWire API. Just a sidenote: I have no actual need to add all my pages to a sitemap … The keywords here are sitemap index, sitemap and ProcessWire's page numbers. Two templates: sitemap-index.php sitemap-xml.php (with page numbers activated) The structure of mine is this: sitemap-index.php is sitemap-xml.php is And the code for each of them: sitemap-index.php <?php namespace ProcessWire; $out = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<sitemapindex xmlns="">'; $templates = "basic-page|blog-post|tag"; $key = $pages->count("template=$templates"); $limit = 200; $pageNum = ceil($key/ $limit); $post = $pages->get("template=sitemap-xml"); $i = 1; while($pageNum >= $i){ $out .= "\n<sitemap>" . "\n\t<loc>" . $post->httpUrl . "page$i/</loc>" . "\n\t<lastmod>" . date("Y-m-d", $post->modified) . "</lastmod>" . "\n</sitemap>"; $i = $i + 1; } $out .= "\n</sitemapindex>"; header("Content-Type: text/xml"); echo $out; ?> sitemap-xml.php <?php namespace ProcessWire; $out = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<urlset xmlns="">'; $pageArray = $pages->find("template=basic-page|blog-post|tag, limit=200"); foreach ($pageArray as $post) { $out .= "\n<url>" . "\n\t<loc>" . $post->httpUrl . "</loc>" . "\n\t<lastmod>" . date("Y-m-d", $post->modified) . "</lastmod>" . "\n</url>"; } $out .= "\n</urlset>"; header("Content-Type: text/xml"); echo $out; ?>
  3. Now that Google is closing down the paid service Google Site Search, and only the free ad version of their search will be available within a year, I have started looking around. It seems that DuckDuckGo has an API that delivers data as JSON. Has anyone used this with ProcessWire and have some code and guidance to offer? Such as listing the results, open for pagination and any other tricks?
  4. Is there a way to append $rss->itemLinkField = ''; ? For use with campaign url or other tracking methods. E.g. such as this: $rss->itemLinkField = 'httpUrl' . '?utm_source=RSS_Feed&utm_medium=RSS&utm_campaign=RSS_Syndication'; Except that this wont work … I have also tried: $rss->itemLinkField = 'httpUrl'; $rss->itemLinkField .= '?utm_source=RSS_Feed&utm_medium=RSS&utm_campaign=RSS_Syndication'; Just to show what is not working, and what I am trying to achieve.
  5. I have been trying to tweak the example from the blog post about repeater depth to work with a two level repeater. Where each "first level" should indicate the start of a Bootstrap column (e.g. col-md-4). And the last item of each "second level" should indicate the end of the previously "opened" column. Examples: Repeater input: Repeater level 0 - Repeater level 1 - Repeater level 1 Repeater level 0 - Repeater level 1 - Repeater level 1 Output example: <div class=col-md-4> <h2>Repeater level 0</h2> <p>Repeater level 1</p> <p>Repeater level 1</p> </div> <div class=col-md-4> <h2>Repeater level 0</h2> <p>Repeater level 1</p> <p>Repeater level 1</p> </div> Even though I could imagine other solutions to this exact problem, the code would be helpful because of the whole detecting and closing opened <div> tag based on level. How would one approach such a problem?
  6. Thank you for your suggestions. I see now that there are methods that could work with fewer pages, so I have added some additional information in my initial post. I should have mentioned this in my question: I have over 170 000 pages to check. It seems either method suggested is too much to handle.
  7. I have a web page where all templates have Norwegian (default language) and English (secondary language, ID 1036). Many of my pages have been imported using the API, and so I used a method from How to set language = active via API? to set the secondary language active. Now I want to output a list of pages where the secondary language is inactive. I have tried the following without luck: $pages->find("template=basic-page, status1036=0") But this gives an error: Field does not exist: status1036 Is there another way that makes this possible? Additional information: basic-page was just an example, I should have been more clear from the beginning. I have multiple templates and a totalt of 170 000 pages to check.
  8. This is great. I was just looking for a way to nest repeaters a few weeks ago for a three level menu. My result was messy. But now I was able to do it better, with more options, easier editing and less code. Thank you for the time you are putting in to create this! I can see some future possibilities: Such as where the nesting depth level defines the width of repeater matrix items on the front end. Making it possible to create a dynamic template where each item can have a different column widths (Uikit or Bootstrap). It would eliminate the need to set the width as a value (or page field value). Making the back end a little more visual (good for the overview). Perhaps with flexbox in css on the front end …
  9. Nice. I'll check it out tomorrow! Edit: I can confirm that the fix is working. I've been able to set up multi instance with multiple language without problems. I'm a web editor at a university college's web page. And we'll be using this to integrate parts of a study guide (academic presentation of study programs and its subjects) into our main web page where our primary focus is marketing of these programs.
  10. No luck with your language suggestion, BitPoet. At least not like this on my main site: switch($user->language->name) { case 'default': setlocale (LC_ALL, $homepage->locale); break; } $mi_studiehandbok = new ProcessWire('/Users/asbjornness/documents/vid/studiehandbok', '/studiehandbok/'); $mi_studiehandbok->user->language = $mi_studiehandbok->languages->get('default'); And also repeating the switch-part on my secondary (multi-instanced) site. Both nb_NO to be precise in my case. Still getting a list of the text Array with this code: $subjects = $mi_studiehandbok->pages->find("template=subject, limit=10"); foreach ($subjects as $s) { echo "$s->title<br>"; }
  11. I'm trying the recently added multi-instance support in a local environment, and has encountered some problems. There's not much code, so I'll paste all I have and some info on the installations (both are ProcessWire 3.0.33), and pinpoint the issues as I go: In a template on (local through MAMP) <?php // Server path to the PW installation $path = "/Users/name/documents/testdomain/studiehandbok/"; // The root URL for the PW installation $url = "/studiehandbok/"; // Create a new ProcessWire instance $mi_studiehandbok = new ProcessWire($path, $url); // get study pages $subjects = $mi_studiehandbok->pages->find("template=study, limit=2"); // output list foreach ($subjects as $sub) { echo "<a href='$sub->httpUrl'>$sub->title</a><br>"; } ?> Issues: The echo will show the correct Url. But as for title, only a list of the text Array will show. But echoing name instead of title works. Comment: as for $url, when I had as the root URL for the PW installation, the first slash "/" after disappeared. In config-dev.php on the /studiehandbok/ multi-instance installation $config->httpHosts = array(''); Comment: This multi-installation is located in a subfolder of my main PW installation. The subfolder is as shown in $path above, called /studiehandbok/ PS: I've also tried with another local installation as the multi-instance, also giving an error on the line of the ->title Notice: Array to string conversion in my template. PS2: I tried to find template=home and others. With home the title actually showed, but only then (tested a few). I'll provide more details if necessary, but I didn't know exactly what to include.
  12. This one worked. Thanks Robin S and LostKobrakai.
  13. I am able to select hidden pages, and save, and they are still there in the page field in the page edit mode. The field settings for custom_menu are "nothing special". A standard page field, with a custom name, title as label, PageListSelectMultiple*+ as input fieldtype. No custom values in other input fields. I understand, so I should really unselect it from the page field if I want to do i correctly? I also tried your option, but the pages are still shown.
  14. I have a page that are either ) showing an automatic list of all pages with a certain template, if no pages are selected in a page field. 2) Or showing the selected pages from the page field. if ($page->custom_menu->count == '0') { $subjects = $pages->find("template=subject-page, sort=title"); } else { $subjects = $page->custom_menu; } When I set these "subject-page"-pages to hidden. The first option excludes these from the list as they should. But the second manually selected list will still show hidden pages. I have checked that these are actually hidden, with the following code: if ($subject->status & Page::statusHidden) { echo "I'm hidden!"; } else { echo "And I'm visible!"; } If I am not wrong, hidden pages have been removed from page fields by themself before, because of their status. But I'm not sure. I haven't used include=hidden. I am on ProcessWire 3.0.32, the page field is using PageListSelectMultiple*+.
  15. How would I go about if I wanted to be able to custom sort pages referenced in a Hanna Code? Example, I want to sort the output that is the title for pages these ids, in the order specified below: [[houses id=10|20|40|30]] I have tried different sort options, such as sort=sort or without sort, in the PHP. But these will look for the order in the page tree and such.