Jump to content

snobjorn

Members
  • Posts

    159
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by snobjorn

  1. Hi @Zeka. I tried this, and it worked when I was viewing the counted number on a page with my default language. But when I switched to viewing it with my non-default language, I was not able to do the opposite. I could not get the "status1023" where the ID was of my default language to work. Any suggestions here?
  2. I found no other simpler solution, so I went for a loop through of languages, and summarized the count. // Save current language $savedLanguage = $user->language; // Loop through languages // Find the other language // Code is only for two languages as of now foreach($languages as $language) { if ($language->id == $savedLanguage->id) continue; if(!$page->viewable($language)) continue; $user->language = $language; $languageCount = $pages->count("template=post"); } // Revert to saved language $user->language = $savedLanguage; // Total count // Add up current language count and the other $postCount = $pages->count("template=post") + $languageCount; // Output number echo $postCount;
  3. Say I have a blog with 50 blog posts in Norwegian, and 10 of them are also translated into English. How do I use $pages->count() (or another method) to count them and show the total in a template file? I have only gotten as far as getting the number 50 when viewing the Norwegian version, and the number 10 when viewing the English version of the page.
  4. As of today, the email sent contains the TFA-code alone. Is it possible for a function to add the timout, such as: "The code will expire at 08:00:35 (HH:MM:SS)" or something similar? I have older users for a project, and many do think the code has expired when sometimes the email takes a while to reach the inbox. So an expire timestamp would help along the way.
  5. I use the TfaEmail module to send emails with the Tfa code. The reason is that my users are familiar with email, not very technical otherwise, so that other Tfa solutions is a bit too advanced. Sometimes the email service is a bit slow, and the sending of email with codes might take a minute or two, so the users try again because they think the code has expired. So I was looking to implement another sentence in the email, after the code, that says "This code will expire at HH:ii". But I am at a loss on how to do this. At https://github.com/ryancramerdesign/TfaEmail/issues/1 I have requested this, but there might be easier ways like a hook or something? Any answer to put me in the right direction would be helpful. Other solutions that could help me with the issue (slow emails) is also very welcome.
  6. Can you paste the code from your template, related to the output of this textarea field, as well, @modifiedcontent?
  7. I got an answer to the issue. It was already fixed: https://github.com/processwire/processwire/commit/4d04aac2a646d6c387d1afff28253225dace8474 – and I can confirm that it works for me now as well.
  8. Currently version 4.7.0 of Font Awesom is used in ProcessWire for icons for templates and fields. Since its release, both version 5 have come – and version 6 is in the making. I would like to see a newer version in the future in ProcessWire, @ryan 4.7.0 (in ProcessWire) has around 675 icons as far as I can tell. The current Font Awesome version has around 1600 icons. When version 6 comes, theres around 2200 icons I have read.
  9. I can also recommend this course. Currently I am 40 % into it, and I have learned a lot.
  10. I have the following setup: Pages with two level URL segments, e.g. /this-page/urlsegment1/urlsegment2/ More than often, due to changes in the data set, the part of the url that is /this-page/ changes name to /this-page-something-else/ PagePathHistory (the modules is installed) saves previous names and handles all the redirects when it comes to the URL without URL segments. URL segmented pages returns 404 errors though Looking for a solution, I was thinking of using the information in the PagePathHistory like this: First, look for /this-page/urlsegment1/urlsegment2/, if it gives an 404 error: Second, look for /this-page/ in any pages PagePathHistory, if it exists: Third: Redirect to /this-page/'s new URL (/this-page-something-else/) I have tried: $pages->get("path=/this-page/") without luck (expecting no luck here) $pagePathHistory->getPage("/this-page/"), but this returns Fatal feil: Uncaught Error: Call to a member function getPage() Has anyone tried anything similar, with PagePathHistory, or maybe any third party modules?
  11. Thanks, @kongondo, I found it now. I did not try the console at first. I looked in /cache/WireTempDir/ though. Thinking I would see it since the default maxAge was 120 seconds, but it disappears after a second.
  12. I ran PHP 7.4 for a while, and ProcessWire ran fine. I had to downgrade to PHP 7.1 because of some issues in Matomo though. And they are both on the same host for me.
  13. So I have been looking in the core files for a clue on how $files->tempDir() works and where it is located, without any luck. Can anyone help me with where this is? I have gotten the method to work and all that, and have also set the maxAge to a lot (in order to have time to look for the temporary directory). But I am at a loss. I just want to know a little bit more about this.
  14. This sounds interesting. I will give it a try.
  15. $articles = $pages->find("template=article, fieldAuthors=$page"); foreach ($articles as $article) { // something like echo $article->title; } You could also skip a few lines of code if you put the extra fieldAuthors=$page in your selector. Then your pages->find only returns pages where the current page's author is present in fieldAuthors.
  16. I found a solution. At least the solution still works after some testing: Logging in, typing tfa, logging out, closing browser. The solution was to hook the redirect after ProcessLogin::afterLogin. $this->addHookAfter('ProcessLogin::afterLogin', null, function($event) { if($this->wire('user')) $this->wire('session')->redirect("/"); });
  17. I think I got a step closer. I have a few lines of code in a ready.php file to redirect the user to the front end after login. When I removed these lines, the browser login session at my ProcessWire page remembered me the next time, and did not ask for the two factor authentication code. There are the lines of code. I'm not sure about the first part being relevant, but they are part of ready.php anyway. $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->name == 'avdeling') { $event->return = $event->pages->get("id=$event->user")->editor_unit; } }); $this->addHookAfter('Session::loginSuccess', null, function($event) { if($this->wire('user')) $this->wire('session')->redirect("/"); }); Does anyone know why these lines of code would make the login ask for the TFA code every time?
  18. if ($page->parent->template->name == "tags") { $field_name = "tag"; I guess this could work for what you are describing, on the child template (i.e. tag_and_category.php template). Just remove the space after parent->, and you might be good to go. 👍
  19. To find the template for the page you are currently at ($page), you can use the information with $page->template. Then you can use a if/else statement to set a variable that would be the field name. if ($page->template->name == "tag") { $field_name = "tag"; } elseif ($page->template->name == "category") { $field_name = "category"; } $items = $pages->find("template=project, $field_name=$page"); It might be other ways as well, but this should be good enough.
  20. If I get specific questions about WordPress, WordPress plugins and/or other services, I will (sometimes, not always) ask the client (or client to be), something like: I understand that you have the need for [general tool description, i.e. SEO editing tools ]. What part(s) of [specific tool name, i.e. Yoast SEO] do you find most useful, and would like to use? Maybe a custom solution would fit your needs better, and save you time on a daily basis. Also, we could look at what could be done automatically when it comes to [short tool description, i.e. SEO] if we look at a custom solution.
  21. If I understand you correctly, you want every individual project page to list all other project pages that has the same tag? If yes, then the following code could work: $items = $pages->find("template=project, tags=$page"); Just to expand further on that: In your code line, if your code would work, would return something like a random project page's child pages of any template that is tagged with $page (current page). But then, ->children is supposed to be used with $page, not $pages.
  22. Five years after I started translating, I have completed all translations for the core / core modules. Hurrah! From now on, translations for upcoming versions of ProcessWire will be tagged as releases with the ProcessWire version name at Releases – processwire-norwegian-language-pack-nb-no – GitHub.
  23. As mentioned in the topic Tfa module not remembering me, I have som issues with getting Tfa codes to be remembered on a website on a subdomain. I have about $70 (US Dollars) to solve this issue. Please PM me or answer this thread. Here are all my previous posts from the linked topic above. On what the issue is and what I know.
  24. Google Tag Manager is useful to track form events. It is how I have tracked visitors use of forms earlier. In addition to the method @MoritzLost suggest, there are ways to track this in the Google Tag Manager admin based on IDs and classes.
×
×
  • Create New...