-
Posts
396 -
Joined
-
Last visited
-
Days Won
3
Pixrael last won the day on April 29 2020
Pixrael had the most liked content!
Profile Information
-
Gender
Male
-
Location
Florida, USA
Recent Profile Visitors
7,483 profile views
Pixrael's Achievements
Sr. Member (5/6)
444
Reputation
-
tursodatabase/turso-client-php: Turso - libSQL client libraries and utilities for PHP (github.com)
-
How to track all called $page->* properties (fields) ?
Pixrael replied to ukyo's topic in General Support
Read this, it might give you an idea using JSON files: -
The method proposed by @ryan here isn't bad, but it doesn't allow nested fragments. In the case of complex views (web apps, calculators, etc.) with different user actions where several calls are needed for different sections of the page, and we (almost always) need fragments that are inside larger fragments. I'm currently working on my first Processwire module, which can help to use these fragment-based systems. I've been implementing several methods, and only one of them prevents the entire content of the template file from being rendered. It works but requires some conditions, ex. in the case of a single template file with markup regions, you should organize your code to put the creation of all content variables at the beginning of the file and completely separate from the output HTML markup. The idea is that during rendering it collects the requested fragments from the template file and saves them to a temporary PHP file, then includes it in the template file at the point before full HTML output occurs, and then stop the rendering the template file. It's basically like a dynamic partial. The advantage is that you don't need to split the template files into several parts (nested fragments will be a nightmare) and avoid to put a lot of conditionals in the code. It also helps that if you have a new type of request, you only need to declare in the request which parts of the page to fetch. @elabx if you're interested, I have a Hook version of this that I used during testing. Note: It would be great if the Render method, in addition to the current template file, would also accept an HTML string. This avoid the use of temporal files.
-
GREAT!!!!! ?
-
Check: https://processwire.com/docs/modules/guides/comments/
-
in fact I have a method in the custom page class for that: if (HTMX Blah Blah) $page->renderFragment("todo", [array], "200 OK"); function renderFragment($filename, $bag, $code) { header("HTTP/1.1 $code"); wire("files")->include("services/partials/{$filename}.php", array('view' => $bag)); exit(); } .. but I love to use Markup regions in my projects, and I hate using tens of partial files, that's the reason for the proposal. Get the "partials" from the same template file that I render in the page request. It's a simple helper in tune with Processwire Markup Regions
-
I get it, in PW it can be done too with $files->render() ..now do the example without partials ? I mean when a page has many moving parts, you have to dissection too much the "view" in files, and it becomes complex (not impossible) to handle... I want to make clear my first post says that it can be done now, in fact I have done it... but it would be much more productive and simple something like what I propose .. but it's only an idea based on my opinion
-
All that you describe is very good for simple examples like the ones you put here, but when it's a much more complex page, or a web application, with several different elements that you want to update, it starts to become complex. You need to start dissecting the template file into small partial files (or even worse build the markup with PHP variables) to be able to render different types of requests to the same template, and it's a mess! ex. complex forms with dependencies between the fields, updating graphs or tables, panels with details of the selected element, couple of counters in different location in the page, etc. The idea is to be able to use the same original template file that initially rendered the page, and that can be used with Markup Regions if you wish. Response with a whole page as @bernhard proposes (although it's already cached, you need to update it with the new query) and send the complete page each time you need to update something, ex. only one <select> element, small text or a counter, these kind of pages regularly weigh MBs ..It's very unreasonable ..is better to reload the page. The ideal is to send the exact piece of html that you need to update on your initial page render. @bernhard Latte already support this kind of rendering. Using the 3rd parameter to only render 1 block from the template $Latte_Engine->render('path/to/template.latte', [ 'foo' => 'bar' ], 'content');
-
I have been using HTMX recently and it really is a very good option. Of course all of its functionality can be achieved using the Processwire API, and including partial files in the template file. But it would be wonderful to have some kind of facilities in our framework. Maybe with a new method in the PageRender class, that allows to select specific elements of the template file markup. The following is a simple idea based on the Markup Regions syntax: <pw-region id="content"> <h1><?= $page->title ?> <?= $page->summary ?> <h2>Contact Details</h2> <div id="contact_info" pw-fragment> <p><strong>$page->contact_name</strong></p> <p>$page->contact_address</p> </div> <h2>Social Channels</h2> <div id="total_likes" hx-swap-oob="true" pw-fragment> <a href="https://www.facebook.com/">$page->likes</a> </div> <p>Please, Call Us!</p> </pw-region> Since I'm not a programmer and I don't really understand very well how PW works inside, perhaps one of the following options can work to execute the rendering of the fragments (It can use the Find method that Markup Regions has for HTML tags) $output = $page->render("#contact_info#total_likes"); $output = $page->render("basic-page.php#contact_info,total_likes"); $output = $page->render("fragment=contact_info|total_likes"); $output = $page->fragment("contact_info|total_likes")->render(); $output = $page->render()->fragment("contact_info|total_likes"); $output = $page->renderFragment(["contact_info","total_likes"]); wireFragment() Of course this method does not use the append file of the "_main.php", perhaps doing a: $this->halt(); Laravel Blade has this already implemented for precisely the same purpose. Check this video: https://youtu.be/3dPUsXsDZsA https://htmx.org/essays/template-fragments/ @ryan what do you think about this? Everyone, would this be a good idea? ..or something similar?
-
@ryan maybe this could help: https://www.phpclasses.org/package/12821-PHP-Detect-and-block-spam-bots-from-accessing-sites.html
-
https://learn.microsoft.com/en-us/answers/questions/414790/check-if-lat-long-point-is-inside-polygons