Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by froot

  1. how to return an array of the menu items? So far I was not successful. $menu = $modules->get('MarkupMenuBuilder');// $menu is an example echo $menu->getMenuItems('topmenu'); // topmenu is the name of my menu But it only returns Menu|Menu|Menu How can that be?
  2. I'm trying to achieve the following: I already have a selectoptions field with a specific page array. I want to add custom links to that array that I would define as JSON inside another field "menulinks" on this very settings factory page. How can I access the fields value while I'm on the settings page? I understand I would need to save the page first before the value is accessible inside the options field? So how to access the value? It must be stored somewhere… // Assume $fields is your instance of the Fields API in ProcessWire // Fetch the 'menu_allocation' field $menuField = $fields->get('menu_allocation'); // Get the options for the 'menu_allocation' field $menuOptions = $menuField->type->getOptions($menuField); // Create an empty array to store the page arrays for each option $pageArrays = array(); // Loop through each menu option foreach ($menuOptions as $menuOption) { // Convert $menuOption to a string $menuOptionString = (string)$menuOption->title; // Create a selector to find pages with 'menu_allocation' set to the current option $selector = "menu_allocation=$menuOptionString, sort=sort"; // Find pages that match the selector $treePages = $pages->find($selector); // Convert the pages to an array $pageArray = array(); foreach ($treePages as $page) { $pageArray[$page->id] = $page->title; } // Add the page array to the main array $pageArrays[$menuOptionString] = $pageArray; } $inputfields = array( array( 'name' => 'menulinks', 'label' => 'menulinks', 'type' => 'textarea', 'value' => '', 'columnWidth' => 30, ), ); // json_decode the "menulinks" value to an array // merge the resulted array with the pageArrays // Loop through each page array and create 'asmselect' field foreach ($pageArrays as $menuOption => $pageArray) { $inputfields[] = array( 'name' => 'page_select_' . $menuOption, // Unique name based on $menuOption 'label' => 'Select a page for ' . $menuOption, 'type' => 'asmselect', 'description' => 'Select a page from the page tree for ' . $menuOption, 'columnWidth' => 100, 'useLanguages' => false, 'options' => $pageArray, // Use the page array as options for the 'asmselect' ); } return $inputfields;
  3. is there a way to make the options multilingual?
  4. @adrian I get the following error with your fork version: 385: $pageData['og:image'] = $pageData['image'] ? $pageData['image']->httpUrl() : ''; The error only occurs on the "home" page and on direct children to home, not sure if that's important to mention, nor sure if the problem occurs because it cannot find an image to inherit?
  5. I'm facing a similar issue now, this PHP Warning: Undefined array key "EUR" in .../ServiceCurrencyConversion/ServiceCurrencyConversion.module:341 PHP Warning: Trying to access array offset on value of type null in .../ServiceCurrencyConversion/ServiceCurrencyConversion.module:341 and this is what it says in the module settings: ServiceCurrencyConversion: access_restricted - Access restricted until 2024-04-14 (reason: too_many_requests). If there has been a mistake, please contact support@openexchangerates.org. And the site is not even live, I'm still developing locally, so it's just me requesting. I have a free account with Open Exchange Rates. I wonder if I just programmed the request-handling poorly, I assumed the module would make a request to Open Exchange Rates via API and then cache the results somewhere? Or do I need to cache it somehow manually? I don't need real-time exchange rates, maybe just one per day for what ever currency is requested would be more than sufficient.
  6. I did something like this: <div class="grid grid-cols-4 gap-4 border border-green-500"> <div class="col-span-3"> <img src="path/to/image.jpg"/> </div> <div class="col-span-1"> <p>Yada yada yada.</p> </div> </div> But the classes don't get applied. Might that have to do with where in which directories tailwind looks for tw classes? Here's my setup: /** @type {import('tailwindcss').Config} */ module.exports = { content: [ "../*.{html,php,js}", "../../classes/*.{html,php,js}", "./node_modules/tw-elements/dist/js/**/*.js", "../../assets/cache/HannaCode/*.{html,php,js}", "../../assets/*.{html,php,js}", "../../../*.{html,php,js}", "./node_modules/flowbite/**/*.js" ], That said, it does work for the hard-coded tw classes anyway, that's why I thought that might be the issue.
  7. I want the users to be able to subscribe to different lists depending on the page the subscribe form appears on. Is that doable? My guess is it should be, since it would be similar to the functionality of "following" a topic here in the ProcessWire forum – doesn't the forum use ProMailer for email updates? I read through the documentation and neither "custom fields" nor "users/pages list type" would accomplish what I want. Not the former as it would just save the page info (let's say that's I have a custom field for that) along with email address and whatnot in the user entry of the subscriber's list, and not the latter as it would just allow for a closed list of pre-defined users that no-one can subscribe to if they so wish. Thanks for help! I know ProMailer is a pro module but I cannot find (or access?) the ProMailer forum anymore.
  8. Thanks @ryan I didn't see that checkbox but I did see an input field Number of Seconds to Cache Exchange Rate Data It was set to 86400, so I set it to 0 and saved. Then I was able to see the table with all codes, names, symbols and rates. Now I also see the checkbox. Weird, I am still on version 3. Anyways, yes, HKD is listed. (Actually not one currency was working before). Now it seems to work again. I wonder, if I need to do this regularly i.e. lower the number of seconds when the cache is cleared?
  9. I'm having troubles using the methods ->getName() and ->getNames() $cc = wire('modules')->get('ServiceCurrencyConversion'); $currencyArray = $cc->getNames(); // array (0) $currency = 'HKD'; $cc->getName($currency); // null warnings: PHP Warning: Undefined array key "HKD" in .../ServiceCurrencyConversion/ServiceCurrencyConversion.module:341 PHP Warning: Trying to access array offset on value of type null in .../ServiceCurrencyConversion/ServiceCurrencyConversion.module:341 I logged into my openexchangerates.org account and there seems to be no outage. Any ideas what this could be?
  10. Any news on that front? I have an images field on a page with a CKEditor field. When I add to that text content a gif from the images field, the gif gets resized and is not animated. I understand this is a bug that is yet to be fixed but is there a workaround in the meantime? Since I'm not displaying the images programmatically I cannot use the API e.g. Pageimage::getOriginal()
  11. I thought extending the user class was not possible since it's a special case and I should use the module approach instead. Has that change in the meantime?
  12. Though this is very helpful, I am still not sure how this works. I can do stuff like this: i.e. access the custom public methods of the user object from outside the class. I have also of course no problem accessing private classes within the here discussed user extension class. However, how does the code change when I define and use a public method from inside and from outside the class. Do I need to pass it the $event?
  13. Hello dear processwirers, I hope you are doing well. I'm a bit stuck implementing this module. Since the "Edit Profile"-form renders when the GET-params are "profile=1" But that form also submits to the same page with the same GET-params "profile=1" I don't see how I can redirect the page upon form submission without ruling out the case that the user is just on the edit profile page. That also means that when the form was submitted and I refresh the page, the browser asks me if I want to resubmit. In more technical terms: how can I edit the form action URL? Thanks for help!
  14. I meant only return /de/ or /en/, is there no native method to do that?
  15. what's the best way to return the user's current language specific URL segment? I mean for example /en/ or /de/ depending on the user's active language?
  16. I want to create a web app where users can login/register via Google I've seen a handful of modules that promise similar things including Oauth2Login, SocialLogin and GoogleClientAPI What I need is the user to be able to login/register via their Google-account and upon that to be logged-in both in their PW-CMS account as well as in their respective Gmail-account in the browser and me to have access to specific data via Google API. My guess is I would need to combine two modules? Maybe GoogleClientAPI with LoginRegister? Or GoogleClientAPI with LoginRegisterPro? Or can GoogleClientAPI do both? Thanks for suggestions!
  17. I'm trying to create a hook that would populate my SEO-Markup fields automatically with some field values of the page upon saving. For some reason I cannot access the MediaManager image field's ->media property and its properties, it returns null. I do see this in the tracy console though… //ready.php $wire->addHookBefore('Pages::saveReady', function($event) use($sanitizer) { $page = $event->arguments[0]; if (!$page->id) return; if ($page->isChanged('seo_title') || $page->isChanged('seo_image') || $page->isChanged('seo_description')) return; // SEO image :D if ($page->seo_image == '') { $filled = false; bd($page->mema_images); // see screenshot bd($page->mema_images->count); // 3 if ($page->mema_images->count > 0) { $imageURL = $page->mema_images->first->media->url; bd($imageURL); // null :( $filled = true; } if ($filled == true) { $imageURL = strval($imageURL); $page->seo_image = $imageURL; $page->message('SEO image was filled because it was empty :D'); $filled = false; } } // SEO description :D - this works fine if ($page->seo_description == '') { $filled = false; $description = ''; if ($page->preview != '') { $filled = true; $description = $page->preview; } if ($filled == true) { $description = SEOcleanUp($description, $sanitizer); $page->seo_description = $description; $page->message('SEO description was filled because it was empty :D'); $filled = false; } } $event->arguments(0, $page); });
  18. The module still needs quite some improvement. One issue that needs attendance is the following. I build a selector and select a page array from the database. $selector = $this->createSelector($this->q, $category); bd($selector); $unfilteredMatches = $this->pages("$selector, start=0, limit=99999"); As discussed in this thread it's (so far) impossible to select pages based on language specific field values. So the query looks through the field values in all languages for the search term. Since this is not what I want, instead I want the query to only match the fields values of the current user language, I do another loop and within that loop, with the method buildSnippets() I create the snippets for the markup. If this returns null (this is now language specific) I sort out the page entirely. $strippedFieldValue = strip_tags($fieldValue); // Find the position of the search term in the field value $position = stripos($strippedFieldValue, $searchTerm); // If the search term is not found, return an empty string if ($position === false) { return false; } So basically I'm selecting once via selector and then narrow it down with a loop. That works for a one-term search query or an exact phrase, but it makes sense that It won't and doesn't work when the search operand is on the fancier side as listed here: https://processwire.com/docs/selectors/operators/#contains What would you suggest? Is my approach so far sensible? Should I hard-code a different loop condition for each of the fancy search operands? I want to give the module-user (not enduser but admin user) the option to adjust the search operand in the module's settings. Thanks for help!
  19. OK I found the culprit. I was initiating the module on a custom page class just to make use of one method., not a good idea.. Now that I found a work-around it works fine and I can uninstall with no issues.
  20. I actually found this in the modules.txt log file: 2023-12-21 11:36:09 admin https://mysite.ddev.site/admin/module/edit?name=SimpleSearch&collapse_info=1 Uninstalled module 'SimpleSearch' 2023-12-21 11:36:10 admin https://mysite.ddev.site/favicon.ico Installed module 'SimpleSearch' Super strange! I removed the favicon.ico links in the head tag, removed the favicon icons, cleared cache, refreshed modules, cleared compiled files, issue remains Will try this now: EDIT: I just tried this and Tracy doesn't bd-log anything from inside the install() method nor the uninstall() method, I mean not even this gets logged: bd('install'); So strange!
  21. OK then I think the right question to ask would be: why am I seeing this?
  22. I don't know if this is related but I'm seeing a lot modules under the "Missing" tab which are actually not missing. I did of course refresh and check for new modules and also clear compiled files. The modules do appear under "Missing" and under the regular modules tab as if they were just fine. At least one of them, "System Notifications" is even a core-module and I think TineMCE as well, see screenshot.
  • Create New...