Jump to content

fliwire

Members
  • Posts

    70
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by fliwire

  1. addSuffix loads class if filename ends with suffix. processwire/wire/core/ProcessWire.php at 3cc76cc886a49313b4bfb9a1a904bd88d11b7cb7 · processwire/processwire (github.com) my setup. changed default "classes" dir with "models".
  2. @TomPich // suffix is Repository not Repo. $classLoader->addSuffix("Repository", __DIR__ . '/classes/Repository');
  3. <?php // site/init.php namespace ProcessWire; if (!defined("PROCESSWIRE")) die(); $classLoader = $wire->classLoader; $classLoader->addSuffix("Service", __DIR__ . '/services'); $classLoader->addSuffix("Form", __DIR__ . '/forms'); $classLoader->addNamespace("ProcessWire", __DIR__ . '/utils');
  4. session issue. add site/config.php $config->sessionCookieSameSite = "None"; and make sure site is https.
  5. Those who need it can use this for now. create .prettierrc file { "overrides": [ { "files": ["*.latte"], "options": { "parser": "html", "tabWidth": 4 } } ] }
  6. How format .latte files in vs code ? Currently there is no formatter for "latte".
  7. Same issue: $collections->sync_queue("product={$product}, limit=1"); // this not work in hook $collections->sync_queue->find("product={$product}, limit=1"); // this works if pagination limit not enabled in settings.
  8. My access to support form expired. sync_queue is a "ProFields: Table field". Version: Table 0.2.3 // ready.php $wire->addHookBefore( "Pages::saveReady(template=collection)", function (HookEvent $event) { $page = $event->arguments(0); if ($page->sync_add) { $collections = pages()->get("template=collections"); $collections->of(false); foreach ($page->children() as $key => $product) { $queue = $collections->sync_queue("product={$product}, limit=1"); // always give 1 count can't check if already added. if (!$queue->count) { $q = $collections->sync_queue->makeBlankItem(); $q->product = $product; $q->date = time(); $collections->sync_queue->add($q); $collections->save('sync_queue'); } } // This works $home = pages("/"); $http = new WireHttp(); $response = $http->post($home->httpUrl, [ "collection" => $page->id, "sync_add" => $page->sync_add, ]); } $page->sync_add = 0; $event->removeHook(null); } ); // home.php $collection = input("post", "collection", "int"); $sync_add = input("post", "sync_add", "int"); $collection = pages()->get("template=collection, id={$collection}"); if ($collection->id && $sync_add) { $products = $collection->children(); $collections = pages()->get("template=collections"); $collections->of(false); foreach ($products as $key => $product) { // Only add product one time $queue = $collections->sync_queue("product={$product}, limit=1"); // this works as expected if (!$queue->count) { $q = $collections->sync_queue->makeBlankItem(); $q->product = $product; $q->date = time(); $collections->sync_queue->add($q); $collections->save('sync_queue'); } } }
  9. <?php $home = pages("/"); echo cache()->get('offcanvas-nav', 10, function() { return ukNav($home->and($home->children), [ 'depth' => 2, 'accordion' => false, 'type' => 'default', 'class' => '', // 'blockParents' => [ 'blog' ], 'repeatParent' => true, 'noNavQty' => 20, 'maxItems' => 16, 'divider' => false, ]); }); ?>
  10. install it via composer and than how init latte? tried breadcrumbs code not working? <ul> <li n:foreach="$page->parents()->add($page) as $item"> <a href="{$item->url}" n:tag-if="$item->id != $page->id"> {$item->title} </a> </li> </ul>
  11. you can set password and other settings in config.php WireMailSmtp/WireMailSmtpConfig.php at master · horst-n/WireMailSmtp · GitHub $config->wiremailsmtp = [ "smtp_password" => "test", ];
  12. hotwire, unpoly doesnt require any backend language. mostly use with pw: Unpoly: Unobtrusive JavaScript framework
  13. delete " - site name" from module settings and add "site name" if not home page. $wire->addHookAfter('SeoMaestro::renderSeoDataValue', function (HookEvent $event) use ($settings) { $group = $event->arguments(0); $name = $event->arguments(1); $value = $event->arguments(2); $page = wire("page"); if ($page->id != 1 && $group === 'meta' && $name === 'title') { $event->return = $value . ' - ' . $settings->site_name; } });
  14. https://developers.google.com/search/docs/advanced/robots/create-robots-txt
  15. make sure u have latest master version 3.0.184. sessionCookieSameSite added 3.0.178 ProcessWire Weekly #366 or add to htaccess <ifmodule mod_headers.c> Header always edit Set-Cookie ^(.*)$ $1;SameSite=None;Secure </ifmodule> u should have no issue.
  16. SameSite cookies explained (web.dev) u need https and set SameSite = "None"; $config->sessionCookieSameSite = "None";
  17. u can use unpoly. Layers - Unpoly <a href="/post-page" up-layer="new" up-target='.content'>Open Content</a>
  18. hi @Sebi found that that was server fault. AUTHORIZATION headers not set. cant find what apache module should enable but .htaccess solve my issue. SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
  19. hi need to add custom variable to every request . Token has an_id value and need to fetch user data from another database. Tried bottom code but $tokenString is empty. Simply need to add $token->an_id value to request $data object. wire()->addHookBefore('Router::handle', function (HookEvent $event) { $auth = Auth::getInstance(); $tokenString = Auth::getInstance()->getBearerToken(); // if ($tokenString === null || !is_string($tokenString) || empty($tokenString)) { // return false; // } // throws exception if token is invalid: // try { // $secret = $auth->application->getTokenSecret(); // if (!$singleJwt) { // $secret = $auth->application->getAccesstokenSecret(); // } // $token = JWT::decode($tokenString, $secret, ['HS256']); // } catch (\Firebase\JWT\ExpiredException $e) { // throw new AccesstokenExpiredException(); // } catch (\Firebase\JWT\BeforeValidException $e) { // throw new AccesstokenNotBeforeException(); // } catch (\Throwable $e) { // throw new AccesstokenInvalidException(); // } $routeInfo = $event->arguments(0); $routeInfo[2]["an_id"] = $token->an_id; $event->arguments(0, $routeInfo); });
  20. module bug or wrong usage ? ptable has 3 row data // this work $page->of(false); foreach ($page->ptable() as $key => $item) { $item->test = "test444"; } $page->save("ptable"); // this not works // any selector cause not save $page->of(false); foreach ($page->ptable("start=0, limit=10") as $key => $item) { $item->test = "test444"; } $page->save("ptable");
  21. how to disable validation with processInput hook? Or maybe better solved this problem? Tried to load custom options and save value. $wire->addHookBefore('InputfieldSelect::render', function (HookEvent $event) { $InputfieldSelect = $event->object; if ($InputfieldSelect->name == "dselect") { $page = wire("page"); $event->replace = true; $options = [ "1" => "test2", "2" => "test3", "3" => "test4", ]; $attrs = $InputfieldSelect->getAttributes(); unset($attrs['value']); foreach ($options as $key => $value) { $selected = $key == $page->dselect ? "selected" : ""; $out .= "<option value='{$key}' $selected>{$value}</option>"; } $out = "<select " . $InputfieldSelect->getAttributesString($attrs) . ">{$out}</select>"; $event->return = $out; } }); // tried for disable validation $wire->addHookBefore('InputfieldSelect::processInput', function (HookEvent $event) { $field = $event->object; if ($field->attr('name') == "dselect") { $page = wire("page"); $event->replace = true; // $field->setAttribute('value', input("post", "dselect")); $event->arguments(0, $field); } });
  22. Want to change Auth::login process with session::login hook but not working. Can i extend auth::login process ? // Routes.php wire()->addHookBefore('Session::login', function (HookEvent $event) { // Get the object the event occurred on, if needed $session = $event->object; // Get values of arguments sent to hook (and optionally modify them) $name = $event->arguments(0); $pass = $event->arguments(1); $force = $event->arguments(2); //HERE another database check for login // changed for testing not working $name = "prouser"; $pass = ''; $force = true; // Populate back arguments (if you have modified them) $event->arguments(0, $name); $event->arguments(1, $pass); $event->arguments(2, $force); }); // extend auth login wire()->addHookBefore('Auth::doLogin', function (HookEvent $event) { $auth = $event->object; $event->replace = true; $event->return = [ 'jwt' => $auth->createSingleJWTToken(), 'username' => "3254235" ]; });
  23. $cached value is null after 1 minute first visit, after first refresh $cached value is ok. Bug or wrong usage ? //_init.php $cached = cache("cached2", 1 * 60, function () { // file_get_contents html and return array $array = []; return $array; });
×
×
  • Create New...