Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/24/2022 in all areas

  1. Merry Christmas, Happy Hanukkah, and Happy Holidays! The plan is to release a newyear main/master core version. I'm not currently aware of any showstopper issues specific to the current dev branch, but if you are aware of any, please report them in the GitHub issues repo (or reply to an existing issue report), as the dev branch will soon become the master branch. There's not yet a hard deadline, so whether it's end of December or the 1st week of January, we'll have a new release out shortly. The dev branch is very stable right now (likely more stable than the master branch) so it's a good time to get a new version out. I've also been holding off on several larger updates to the dev branch in anticipation of this merge to master and new release, so I've likewise been holding back on any commits that would add more to test. Once we get a new main/master release out there, the dev branch will then get InputfieldTinyMCE merged into it and there will be some JS library updates, along with other larger updates, and those that would need dev branch testing. Thanks for reading and I hope that you have a great holiday weekend and week ahead
    6 points
  2. Merry Christmas @ryan, and all the Processwire community!
    2 points
  3. @bernhard Yes, so far it sounds like that would work. I might be forgetting something, but I will definitely look into adding that, thanks!
    2 points
  4. 2 points
  5. This isn't the first star rating module for ProcessWire, but I wanted some particular config options and to have the inputfield be usable within FormBuilder. FieldtypeStars The inputfield of FieldtypeStars uses a star rating interface to set a float value. The fieldtype extends FieldtypeFloat. The inputfield has no external dependencies such as jQuery or Font Awesome and can be used in FormBuilder. Config Using InputfieldStars in FormBuilder In order to add a Stars field to a FormBuilder form you must first enable "Stars" in the "Allowed Input Types" field in the FormBuilder module config. https://github.com/Toutouwai/FieldtypeStars https://processwire.com/modules/fieldtype-stars/
    1 point
  6. @Robin S amazing addition. The half stars is much appreciated too. Have a great weekend! Question: Are we able to use this module to read said field too, or is it simply for capturing a star rating?
    1 point
  7. I can confirm that this hook is working on a clean PW3.0.208dev install. So problem is somewhere within my other install.
    1 point
  8. Latest version of https://github.com/metafizzy/infinite-scroll is from 2020. It uses modern web APIs like fetch, throttles scroll events and uses the https://developer.mozilla.org/en-US/docs/Web/API/DOMParser API, so it is quite efficient in what it does. This is true in many cases, but not in all. Just because a plugin offers configuration options it does not necessarily mean that it is bloated. To me all the config options in infinite-scroll plugin do make sense. It focuses on the task that it is trying to solve, and does this in a quite concise way. If you take a look at the source you will see that it is well structured. Lets say your URL to the index page is /newspage and the template is newspage.php. You can handle the AJAX requests in newspage.php inside an if($config->ajax) block if($config->ajax) { // build your posts array or return the posts HTML return $this->halt; // stop execution } Then your AJAX GET request goes to the same page. To make a request to the same page you can use $.get('./', queries, ...) or use the $.ajax object and ommit the url parameter $.ajax({ type: "GET", // url: "index.php", ommit data: queries, }).done(function (data) { //... }); All the logic with $limit and $offset in your posts.php example is there to figure out which posts to return in pure PHP. This is commonly called "pagination". You are here because you are using our all beloved content management framework ProcessWire. And PW has it's own implementation of pagination and it does it in a very well thought out and efficient way. So why not use the tools that your framework provides? Namely https://processwire.com/api/ref/paginated-array/ . You are already building a PaginatedArray with $posts = $pages->find("template=video, limit='12', sort=-date"); // $posts is an instance of PaginatedArray class because of limit in the selector string With PW's excellent API documentation and the well documented methods of the PaginatedArray class you should be able to figure out how to return what you need inside the if($config->ajax) block. Take a look at the setLimit() and setStart() methods of the PaginatedArray class. So right there you have some more homework :-) Of course you could do it with pure PHP but this would go beyond the scope of this forum. We shall be happy to help you doing it the ProcessWire way, though.
    1 point
  9. Thanks @Robin S - very timely - I am making use of this in a custom frontend form today!
    1 point
  10. yes! I can confirm that @matjazp's solution works for me as well! As you might be able to see when comparing my actual code and the example / prove of concept code, I was getting close. As for the load from db or load from in-memory, I've always been confused about this stuff. If you don't mind my asking: is that basic php knowledge or specific to PW? I actually need to load the pages and filter them twice because I have two subsections to be displayed on the page. So I don't know how to do that properly, without loading all at once. And I don't know how I would accomplish all of this in the given scenario, with the custom PaginatedArray and all, but I'm curious to find out and appreciate your input. That said, I can also confirm that works now. I'm almost certain though that I've used this syntax before with the empty single quotes so I'm very sceptical. Or I'm delirious. It's like the first approach one would use before ending up with what I did (building that function sortOutEmpty() etc. so I seriously doubt I didn't try that out before.
    1 point
  11. $items = $pages->find("id>1"); $home = $pages->get("id=1"); $customPaginatedArray = new PaginatedArray; foreach ($items as $item) : if ($item->parent == $home) : $customPaginatedArray->add($item); endif; endforeach; // should return an array of pages that are direct children of the homepage $limit = 10; $start = ($input->pageNum-1)*$limit; $total = $customPaginatedArray->count(); foreach ($customPaginatedArray->filter("limit=$limit, start=$start") as $c) : echo $c->title . '<br>'; endforeach; $customPaginatedArray->setStart($start); $customPaginatedArray->setLimit($limit); $customPaginatedArray->setTotal($total); echo $customPaginatedArray->renderPager();
    1 point
  12. I hope someone could shine some light if something like this is possible (don't know if you tried it?): CustomRepeaterPage extends RepeaterPage { ... } What I do a lot is on site/ready.php $wire->addHookMethod("RepeaterPage:newMethod", function(){ .. })
    1 point
  13. @modifiedcontent here you go with a very simple example using jQuery (but it's different for all javascript frameworks or vanilla javascript... I'm using the default profile for the example: home.php <?php namespace ProcessWire; if($config->ajax) { $content = "content loaded via ajax @ " . date('d.m.Y H:i:s'); } else { $content = $page->body . renderNav($page->children); } $sidebar = '<button id="loadrandom">load random page</button>'; _main.php: add this before your </head> <script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script> <script> $(document).ready(function() { // add an event listener for the click event on #loadrandom button $('#loadrandom').click(function() { // check your console if everything works console.log('button was clicked'); // use the load() method to replace the current content // of div#content by the content of div#content that is // returned from an ajax request to the current url ./ $('#content').load('./ #content'); }); }); </script>
    1 point
×
×
  • Create New...