Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/23/2020 in all areas

  1. Just created my first VSCode Extension - if you like it please give it a star on Github and rate it on VSCode Marketplace ? Installation: Either via https://marketplace.visualstudio.com/items?itemName=baumrock.pwsnippets or directly in VSCode: Contributions welcome! https://github.com/BernhardBaumrock/pwsnippets
    9 points
  2. Hi there, while developing a sideproject which is completly build with ProcessModules i suddenly had the urge to measure the performance of some modules ? as a result, say welcome to the FlowtiAppPerformance module. It comes bundled with a small helper module called FlowtiModuleProfiler. In the first release, even though you could select other modules, it will track the execution of selected Site/ProcessModules. This will give you the ability to gain insights how your Application behaves. The Main Module itself will come with 2 Logging Options, Database or PW Logs. Select Database for Charts and Logs...well If you just want your profiles as a simple log file in PW. You also could choose to dump the request profile into TracyDebugger as shown here: Dont wonder about my avg_sysload, somehow my laptop cant handle multiple VMs that good ? Settings Screen Monitoring FlowtiLogs again, dont look at the sysload ? I will update the Module in the future to give some filter options and aggregation, but for now it satisfies my needs. I hope it is helpfull for some. Module is submited to the directory and hosted at github https://github.com/Luis85/FlowtiAppPerformance Any suggestions, wishes etc. are much appreciated. Cheers, Luis
    3 points
  3. Dai amico mio, for the various conspiracies theories Netflix in enough. Once in a lifetime let's think about generosity and collaboration between people, over and beyond their country statuses :)
    3 points
  4. The title might sound more exciting that it actually is. It's just a little helper module to keep things organized ? Basically it just saves you from finding the correct require_once("where/is/my/nette?") and, for a little extra security, it adds an .htaccess file to block all direct access to Nette source files. Why? Nette is an awesome framework with some awesome features/utilities that ProcessWire lacks. Creating separate modules and including Nette packages multiple times in those modules would not be efficient. RockNette makes it easy to store them in a central place. Usage You'll get all necessary instructions on the module information screen: https://github.com/BernhardBaumrock/RockNette
    2 points
  5. PageArray inherits from PaginatedArray which inherits from WireArray. WireArray checks for duplicates by default. You can change this behaviour through setDuplicateChecking!
    2 points
  6. In a rush, so only a quick response. Usually when adding a page via the API, it's best to leave the "name" empty and let PW handle that if you simply want it converted from the title. When adding pages via the API, you can do your own check to see if a page with that title already exists: if(!$pages->has('parent=xxxx, title=myTitle')) { That uses the brand new 3.0.153 has() method, but you can also do it with find or count. If you want to prevent duplicates being added via the admin, then you probably want to hook into Pages::setupNew or Pages::add - I have used the latter many times, but not the former so without looking in more detail, I am not sure if it will work as I don't know if it has the new page name yet. Hopefully that gets you going, or someone else will come along with a more complete example.
    2 points
  7. function renderCustom(PageArray $items) { foreach($items as $item) { echo $item->title; // ... heavy content loading } } Is this just an example, or is your actual function also just echoing content? If so, that right there could be your problem — echo will output the content right way instead of returning it for assignment. Try something like this instead: function renderCustom(PageArray $items) { $out = ""; foreach($items as $item) { $out .= $item->title; // ... heavy content loading } return $out; }
    2 points
  8. Been using Sizzy for a while and things I really like are: Screenshots, I work remote so it's a time saver to show clients a preview You can actually inspect every one of the screens and debug! Things I don't like: A lot of RAM needed.
    2 points
  9. I guess that tool was not exactly built for mocking up a ProcessWire template/field-setup ? But I think this could be quite helpful - also for asking/explaining questions here on the forum! https://dbdiagram.io/
    1 point
  10. @chrizz If you want to create a page but it already exists, than you cannot create it. So you first simply need to check if there is one or not: $title = "mytitle"; $pagename = $this->sanitizer->pageName($title); $parent = $pages->get("/styleguide/"); if(0 == $pages->get("parent.id={$parent->id}, name={$pagename}")->id) { // the selector also can check for parent and title, instead of parent and name // no page with that name exists here, so create it here $channel = new Page(); $channel->template = "basic-page"; $channel->parent = $parent; $channel->title = $title; $channel->name = $pagename; $channel->save(); } else { // A page with that name is already there, what to do now? Throw an exception? Drink a beer? ... }
    1 point
  11. Thank you @LuisM! I think I'll remove the CKEditor where possible and play with CSS to render the rest of the elements in the same way. I'll definitely keep the reminder for the next projects! ?
    1 point
  12. If you view the page source (right-click + view page source, i.e. not the "formatted" version you see in dev tools), is that actually what you see there as well? Since a_01_text is a CKEditor field it'll return markup, and in this case that markup probably consists of a paragraph (<p>Some text</p>). Since you can't have a paragraph inside a paragraph, your browser might be "correcting" it to this. How 'bout converting that wrapping <p> element into a <div> instead? <div class="wow fadeInUp animated" data-wow-delay="1.3s"><?=$page->a_01_text?></div>
    1 point
  13. That new unique flag shouldn't impact this - PW still shouldn't allow duplicate names under the same parent. If for some reason it is, it sounds like a bug. Are you creating pages via the Admin or API?
    1 point
  14. Thx ? Does PhpStorm offer a similar feature? Maybe we can port it easily...
    1 point
  15. I'm a PhpStorm user but I starred it anyway ?
    1 point
  16. It looks like you have a textformatter enabled for file descriptions. Try to de-activate that HTML purifier textformatter.
    1 point
  17. @bernhard Im well aware of profiler-pro ? I am a ProcessWire fanboy since 2014 but unfortunatly lost my forums account ? maybe some old veterans remember me. Anyways, why do I replicate the pro module you may ask, good question. I have a lot of small PW Instances running for various reasons and dont see the need to purchase a module for my profiling needs. Usually my instances are running solely on the ProcessWire Admin because the time I did websites are long gone. This in mind there are times I want to see how a specific module I my application runs. How do I achieve this? The core class ProcessController exposes the hookable Method ::execute. If your site is in Debug=true you already get timers before and after the method call which is totally fine, but once in production I want to avoid setting the site into debug mode just to get these timings. So we add 2 Hooks to ::execute $this->addHookBefore("ProcessController::execute", $this, 'startProfiler'); $this->addHookAfter("ProcessController::execute", $this, 'startProfiler'); This gives us also the ability to enrich our profiling with some more data like the requests memory_peak_usage or the avg_sys_load for the last minute. These are the 2 values I am the most interested in because they will provide me enough data to see bottlenecks not only on a custom Process Module but also on a specific method. For example this dataset will give me the opportunity to track down a single method in one Class to inspect the code if there is something fishy.
    1 point
  18. My bad... everything is fine. A table name was not correctly written ...?
    1 point
  19. Exactly what I thought! I also find it counter intuitive that it does not return a boolean value! Your linked example looks good as-is, but it somehow does not feel right to have a ->has() return something else than yes/no. $pages->getID() is great to have and absolutely clear imho ? Ok, I've done some research and I see that we have several HAS... methods returning integers, for example: $page->hasChildren() $page->hasLinks $page->hasReferences Still not sure if it wouldn't be better to have those additionally for clearness: $page->numChildrenVisible() $page->numLinks $page->numReferences Of course that's nothing extremely important, but PW is known for it's awesome API, so it might be good to keep it as clean as possible. What do others think about those wordings?
    1 point
  20. That's somthing you'll understand once you understand how the PW admin works. What is an Inputfield? What is a Fieldtype? What is a module, what a ProcessModule etc. ? PW has everything abstracted so that it is simple for the general user, but it is on the other hand still very powerful for advanced use. My tutorial about backend pages might be a good read ?
    1 point
  21. You really only discovered this today? We're using it since years (with Gulp, Babel, Webpack etc.). Welcome to the 21st century ?
    1 point
  22. I think @LAPS wants some place that does NOT load on every request. But all of your mentioned options do load on every request ? How large is that list of E-Mails? ? If that is really too much for every request you can put it In some file that you only include() when you need it In a non-autoload module, that you request when needed (eg $modules->get('myemails')->getAll()) In a WireCache object that is stored in the Database In a dedicated page + field (eg $pages->get(1234)->emailslist)
    1 point
  23. The naming of "has" sounds a bit unintuitive to me as well, since it involves getting a true/false, so it can lead to confusion when reading the code where the returned id is used. Maybe something like this? (somewhat similarly to the C# TryGetValue()) $pages->tryGetId(selector);
    1 point
  24. Hi @jonatan and welcome to the forum ? EDIT: Just saw that you are using the Mystique field. So you could have done just that (untested): $insta = ...; // your logic return [ ... 'fields' => [ 'insta' => [ 'label' => 'Instagram User', 'type' => 'markup', 'value' => $insta, ], ...
    1 point
  25. @ryan, great timing on the $pages->has() method - I requested essentially this just the other day: https://github.com/processwire/processwire-requests/issues/358 But the method name has() seems not so intuitive - if you didn't know better you would think this returns a true/false value. I think $pages->getID() would be more intuitive - maybe that could be added as an alias?
    1 point
  26. Everybody please take this pandemic really seriously!! Panic does not help for sure, but ignorance or underestimating this situation will cost the life of thousands of people all over the world! As the following chart shows, the mortality highly depends on the amount of people that are in need of medical care at one time! Taken from link 2, see below. I have underestimated it myself just like almost anybody in europe has, as nobody of us here has ever experienced a situation like this before (in contrast to asia). Here are two links that I encourage everybody to read, even if you live in an area that has not (yet) been affected: 1) https://www.washingtonpost.com/graphics/2020/world/corona-simulator/?fbclid=IwAR0ABgvQGxm005seLywxDkZScKImi53Du9lzAlMwrDH6qsaaefW-Oux-Gao They have great simulations of how such an exponential growth can/will happen and what every single person can do against it! 2) https://medium.com/@holger.heinze_81247/coronacodex-my-commitment-during-the-covid-19-pandemic-76613656dac0 I hope that was not offending the forum rules that don't want political discussion... I work 100% remote now and I encourage everybody to do the same if at all possible. Not because I'm afraid (luckily I'm not at high risk as I'm young and healthy), but to take responsibility for all the people around me and keep the number of people needing medical care as low as possible so that the staff in the hospitals does not have to decide which patient (with severe symptoms) is treated and which is not (and will likely die).
    1 point
  27. I've been working with FieldtypeOptions recently and in the absence of documentation thought I would share some example code: $field = $fields->get('test_options'); /* @var FieldtypeOptions $fieldtype */ $fieldtype = $field->type; // Get existing options // $options is a SelectableOptionsArray (WireArray) // If there are no options yet this will return an empty SelectableOptionsArray $options = $fieldtype->getOptions($field); // Create an option $yellow = new SelectableOption(); $yellow->title = 'Yellow'; $yellow->value = 'yel'; // if you want a different value from the title // Don't set an ID for new options - this is added automatically // Will deal with 'sort' property later // Create another option $orange = new SelectableOption(); $orange->title = 'Orange'; // Add option after the existing options $options->add($yellow); // Get an option by title $green = $options->get('title=Green'); // Insert option at a certain position $options->insertAfter($orange, $green); // Remove an option $options->remove($green); // Reset sort properties (so order of options is the same as the SelectableOptionsArray order) $sort = 0; foreach($options as $option) { $option->sort = $sort; $sort++; } // Set options back to field $fieldtype->setOptions($field, $options);
    1 point
×
×
  • Create New...