Jump to content

fliwire

Members
  • Posts

    66
  • Joined

  • Last visited

Everything posted by fliwire

  1. Those who need it can use this for now. create .prettierrc file { "overrides": [ { "files": ["*.latte"], "options": { "parser": "html", "tabWidth": 4 } } ] }
  2. How format .latte files in vs code ? Currently there is no formatter for "latte".
  3. 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.
  4. 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'); } } }
  5. <?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, ]); }); ?>
  6. 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>
  7. you can set password and other settings in config.php WireMailSmtp/WireMailSmtpConfig.php at master · horst-n/WireMailSmtp · GitHub $config->wiremailsmtp = [ "smtp_password" => "test", ];
  8. hotwire, unpoly doesnt require any backend language. mostly use with pw: Unpoly: Unobtrusive JavaScript framework
  9. 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; } });
  10. https://developers.google.com/search/docs/advanced/robots/create-robots-txt
  11. 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.
  12. SameSite cookies explained (web.dev) u need https and set SameSite = "None"; $config->sessionCookieSameSite = "None";
  13. u can use unpoly. Layers - Unpoly <a href="/post-page" up-layer="new" up-target='.content'>Open Content</a>
  14. 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
  15. 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); });
  16. 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");
  17. 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); } });
  18. 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" ]; });
  19. $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; });
  20. hi : if u still support this module. can u fix this : item markup not set properly. (<div class='uk-width-1-4@m uk-margin-top'>{out}</div>) ProcessWire 3.0.165 $iHelper->markup = array( "list" => "<div class='uk-grid'>{out}</div>", "item" => "<div class='uk-width-1-4@m uk-margin-top'>{out}</div>", "InputfieldSubmit" => array( "item" => "<div class='uk-width-1-4 uk-text-right@m uk-margin-top'>{out}</div>", ) );
  21. Using unpoly for last project needs to validate checkboxes. Normaly unpoly replace input parent .Inputfield div. When user checks fast input seems unresponsive because unpoly replace .Inputfield's content. So i need to inputfield's specific div to replace. Added custom div but unpoly still ignore selector for radios and checkboxes. I tried to solve the problem but the problem was unpoly <input type="text" name="email" up-validate=".email-errors"> <span class="email-errors"></span> $wire->addHookAfter('InputfieldForm::render', function (HookEvent $event) { // Get the object the event occurred on, if needed $InputfieldForm = $event->object; // An 'after' hook can retrieve and/or modify the return value $return = $event->return; $doc = new \DOMDocument(); $doc->loadHTML(mb_convert_encoding($return, 'HTML-ENTITIES', 'UTF-8'), LIBXML_HTML_NODEFDTD); $xpath = new \DOMXPath($doc); $nodeList = $xpath->query("//div[@class='uk-form-controls-meta']"); foreach ($nodeList as $key => $node) { $parentID = $node->parentNode->getAttribute('id'); $parentID = str_replace("wrap_Inputfield_", "", $parentID); $parentID = $parentID . "_error"; $node->setAttribute("class", $parentID); } $return = $doc->saveHTML(); $return = renderNotices() . $return; $event->return = $return; });
  22. Hi, i want to replace {meta_id} with $Inputfield->name. But not works as expected. {meta_id} replaced with parent "Fieldset" or "Form" name. $wire->addHookBefore('InputfieldWrapper::render', function ($event) { $wrapper = $event->object; $wrapper->setMarkup(array( 'item_content' => "<div class='InputfieldContent uk-form-controls {class}'>{out}</div><div id="{meta_id}" class='uk-form-controls-meta'>{error}{description}{notes}</div>", )); }); $wire->addHookAfter('Inputfield::render', function (HookEvent $event) { $Inputfield = $event->object; $return = $event->return; $return = str_replace("{meta_id}", $Inputfield->name, $return); // Populate back return value, if you have modified it $event->return = $return; });
  23. via hook: $wire->addHookBefore('Inputfield::render', function (HookEvent $event) { $inputfield = $event->object; $page = wire("page"); if ($page->template == 'admin') return; if ($inputfield->required) $inputfield->requiredAttr = 1; });
×
×
  • Create New...