Flashmaster82
Members-
Posts
166 -
Joined
-
Last visited
Everything posted by Flashmaster82
-
[SOLVED] How to copy title in multi language?
Flashmaster82 replied to Flashmaster82's topic in General Support
Thank you so much!! -
I have 2 language, default and en. When i create a new page template "tag" i want the other language title to be copied on save. How do i hook this?
-
I have a field "page reference" name: tags. I have a template that it reference to. In the field i have checked "Allow new pages to be created from field" But when i create a new page from that field only the default language "i have two", is indexed. When i switch to my other language site.com/en/ the new page "tag" will not show up? If i manually add a new page with the template "tag" it will show up on both languages on the page?
-
Twitter seems not to be working at sharing? i use this ?url={url}&text={ingress}
-
Is it possible to add Avif format?
-
The path is correct, the problem is the syntax errors. The path to the file is site/templates/css/style.css and site/templates/scss/style.scss
-
Same error still? Is there something else i should be adding in another file or something? <?php namespace ProcessWire; if(!defined("PROCESSWIRE")) die(); $scss = $modules->get('Scss'); $watchFiles = $files->find( $config->paths->templates . "scss", ['extensions' => 'scss'] ); $scss->compileIfChanged( input: $config->paths->templates . "scss/style.scss", watch: $watchFiles, output: 'css/style.css', style: 'compressed', ); Exception: allowPath: pathname not allowed: css/style.css (in E:\Wamp\www\Ganthor\wire\core\WireFileTools.php line 1947)
-
I have PHP 8.1.12
-
I can´t this module to work. ready.php $scss = $modules->get('Scss'); $watchFiles = $files->find( $config->paths->templates . "scss", ['extensions' => 'scss'] ); $scss->compileIfChanged( input: $config->paths->templates . "scss/style.scss", watch: $watchFiles, output: 'css/style.css' style: 'compressed' ); I get error "syntax error, unexpected ':', expecting ',' or')' ? Error: Exception: allowPath: pathname not allowed: css/style.css Please help!
-
That is awesome!!! Thank you
-
Any solutions? I thought it was possible because the Mime types is in the config image/webp:webp
-
If i add a webp image url i get error "Pageimage: johnrogershousemay2020.0x260.webp - not a supported image type"... ? Any idea whats wrong?
-
I get [FAILURE] Number of fields does not match. with the latest version of Processewire (3.0.213) or (3.0.210). If i´m using 3.0.200 then it works? Please help!!
-
Need some help with long polling configuration
Flashmaster82 replied to Flashmaster82's topic in General Support
I think the Htmx polling is "Short polling" that polls all the time. I want to use long polling that is polling only if there is new content. -
Need some help with long polling configuration
Flashmaster82 replied to Flashmaster82's topic in General Support
I will check it out \thanks -
Need some help with long polling configuration
Flashmaster82 replied to Flashmaster82's topic in General Support
Anyone? -
Ok i´m working on a auction site and i need to update some variables for the clients in real time without refreshing the page. So i looked around and found a script for this (long polling) and now i´m trying to implement this. My page looks like this. And my struction in the tree. This is my current script to update a table in the database. I have created an test table in the database just for testing purposes. server.php, Location: root folder <?php ini_set('display_errors', 1); error_reporting(E_ALL); class CustomerDetails { // (A) CONSTRUCTOR - CONNECT TO DATABASE protected $pdo = null; protected $stmt = null; function __construct () { try { $this->pdo = new PDO( "mysql:host=".DB_HOST.";dbname=".DB_NAME.";charset=".DB_CHARSET, DB_USER, DB_PASSWORD, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ]); } catch (Exception $ex) { exit($ex->getMessage()); }} // (B) DESTRUCTOR - CLOSE CONNECTION function __destruct () { if ($this->stmt !== null) { $this->stmt = null; } if ($this->pdo !== null) { $this->pdo = null; } } // (C) GET LATEST DETAILS function getCusDetails() { $this->stmt = $this->pdo->prepare( "SELECT *, UNIX_TIMESTAMP(data) AS 'unix' FROM testtable ORDER BY 'data' DESC LIMIT 1" ); $this->stmt->execute(); return $this->stmt->fetch(); } } // (D) DATABASE SETTINGS - CHANGE THESE TO YOUR OWN! define("DB_HOST", "xxx"); define("DB_NAME", "xxx"); define("DB_CHARSET", "utf8"); define("DB_USER", "xxx"); define("DB_PASSWORD", "xxx"); // (E) CHECK FOR UPDATES // ******** THIS IF STATEMENT IS NOT WORKING - WHEN REMOVED WE CAN PRINT_R THE CUSTOMER DETAILS AS ARRAY. WHEN USED THE IF STATEMENT RETURNS NO DATA. ********* if (isset($_POST["last"])) { // (E1) SET TIME LIMIT set_time_limit(30); // set an appropriate time limit ignore_user_abort(false); // stop when long polling breaks // (E2) LOOP UNTIL THERE ARE UPDATES OR TIMEOUT $_DETAILS = new CustomerDetails(); //print_r($_DETAILS->getCusDetails()); while (true) { $details = $_DETAILS->getCusDetails(); if (isset($details["unix"]) && $details["unix"] > $_POST["last"]) { echo json_encode($details); break; } sleep(1); // short pause to not break server } } ?> Auction page <?php ini_set('display_errors', 1); error_reporting(E_ALL); ?> <script> // (B) LAST UPDATED TIMESTAMP var last = 0; // (C) AJAX LONG POLL function poll () { // (C1) FORM DATA let data = new FormData(); data.append("last", last); console.log("Fetch run", last); // (C2) FETCH UPDATE ON SERVER RESPONSE fetch("<?php echo $config->urls->httpRoot;?>server.php", { method:"POST", body:data }) .then(res => res.json()) .then(data => { //console.log(data); // (C2-1) UPDATE HTML DISPLAY document.getElementById("time").innerHTML = data.data; document.getElementById("id").innerHTML = data.pages_id; last = data.unix; poll(); }) // (C3) CATCH ERROR - LOOP ON TIMEOUT .catch(err => poll()); } // (D) GO! window.onload = poll; </script> <div id="time">Time</div> <div id="id">Id</div> But i don´t how to get the fields from the auction_page and auction_bid as in the first image to be updated. To get values from the database to this page/pages. Sorry for being such a beginner. But i´m in need for some guidance. Or has somebody made a similair better code for this with ajax long polling into Processwire? Any help is highly appreciated.
-
htmx: Auto-refresh Frontend Content on Backend Page Save
Flashmaster82 replied to kongondo's topic in General Support
This look awesome.. Is there any possibility to post the full code for this? -
Need some help to specify path to website root.
Flashmaster82 replied to Flashmaster82's topic in General Support
I am a total noob at javascript so it´s pretty difficult for me this 🙂 How would you @Jan Romero do if i wanted to poll another field or multiple inside a template? Lets say that i wanted to do poll field: auction_bid that is on my auction_bid template, that is a child of auction_page. Right now its polling from a test table auctionbidx that is in the root of the database. -
Need some help to specify path to website root.
Flashmaster82 replied to Flashmaster82's topic in General Support
@Jan Romero My bad 😞 I think it finding the file now, but endless loop still och fetch etc... Console Network -
Need some help to specify path to website root.
Flashmaster82 replied to Flashmaster82's topic in General Support
thanks all for the replies. How to solve this in the code? Sorry for being such a beginner.. 😞 -
Need some help to specify path to website root.
Flashmaster82 replied to Flashmaster82's topic in General Support
thanks for the reply once again @Jan Romero if i do ../../auction_longpolling.php i get this fetch run loop running in the console if i do <?php echo config()->urls->httpRoot;?>auction_longpolling.php i get Error Call to undefined function config() 86: fetch("<?php echo config()->urls->httpRoot;?>auction_longpolling.php", { method:"POST", body:data }) -
Need some help to specify path to website root.
Flashmaster82 replied to Flashmaster82's topic in General Support
Thanks for the reply @Jan Romero templates/assets/auction-page/javascripts.php <script> // (B) LAST UPDATED TIMESTAMP var last = 0; // (C) AJAX LONG POLL function poll () { // (C1) FORM DATA let data = new FormData(); data.append("last", last); console.log("Fetch run", last); // (C2) FETCH UPDATE ON SERVER RESPONSE fetch("<?=config()->urls->httpRoot?>auction-longpolling.php", { method:"POST", body:data }) .then(res => res.json()) .then(data => { // (C2-1) UPDATE HTML DISPLAY document.getElementById("bid").innerHTML = data.bid; // (C2-2) NEXT ROUND last = data.unix; poll(); }) // (C3) CATCH ERROR - LOOP ON TIMEOUT .catch(err => poll()); } // (D) GO! window.onload = poll; </script> auction-longpolling.php <?php class auctionbids { // (A) CONSTRUCTOR - CONNECT TO DATABASE protected $pdo = null; protected $stmt = null; function __construct () { try { $this->pdo = new PDO( "mysql:host=".DB_HOST.";dbname=".DB_NAME.";charset=".DB_CHARSET, DB_USER, DB_PASSWORD, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC ]); } catch (Exception $ex) { exit($ex->getMessage()); }} // (B) DESTRUCTOR - CLOSE CONNECTION function __destruct () { if ($this->stmt !== null) { $this->stmt = null; } if ($this->pdo !== null) { $this->pdo = null; } } // (C) GET LATEST function getauctionbids () { $this->stmt = $this->pdo->prepare( "SELECT *, UNIX_TIMESTAMP(`time`) AS `unix` FROM `auctionbidx` ORDER BY `time` DESC LIMIT 1" ); $this->stmt->execute(); return $this->stmt->fetch(); } } // (D) DATABASE SETTINGS - CHANGE THESE TO YOUR OWN! define("DB_HOST", "xxx"); define("DB_NAME", "xxx"); define("DB_USER", "xxx"); define("DB_PASSWORD", "xxx"); define("DB_CHARSET", "utf8"); // (E) CHECK FOR auctionbids UPDATES if (isset($_POST["last"])) { // (E1) SET TIME LIMIT set_time_limit(30); // set an appropriate time limit ignore_user_abort(false); // stop when long polling breaks // (E2) LOOP UNTIL THERE ARE UPDATES OR TIMEOUT $_auctionbids = new auctionbids(); while (true) { $auctionbids = $_auctionbids->getauctionbids(); if (isset($auctionbids["unix"]) && $auctionbids["unix"] > $_POST["last"]) { echo json_encode($auctionbids); break; } sleep(1); // short pause to not break server } } ?> You can try this out and see if you can make the path work...