-
Posts
6,671 -
Joined
-
Last visited
-
Days Won
366
Everything posted by bernhard
-
Module Preview: Process Documentation
bernhard replied to Macrura's topic in Module/Plugin Development
that's exactly what process modules do there's no need to write a processmodule that renders custom php if a processmodule itself already renders custom php. the key is to use pw's built in inputfields, especially InputfieldMarkup. then you have a consistent UI and all the features that the pw admin offers by default (toggling fields, setting widths, fieldsets, ajax loading etc). -
ah, thanks, you are right ok, so now i get 15seconds. if you really need the count-labels it seems you would need to implement some caching...
-
you have 175 labels showing the tree count: i tried a loop with 200 iterations on my test-install with the SLOW selector from my above example and got all the counts within 500ms: so i think it should be no problem to get the site to returning results plus all the filter count-labels under 500ms. but as i said in my pm: that can only be a wild guess as we don't know any details about your setup.
-
i think you need to do some more debugging! i just played around with a local test-setup and got this results with 10.000 pages: creation of pages: //foreach($pages->find('parent=8181') as $p) $pages->delete($p); $i=0; $tmp = range('A', 'Z'); while($i<10000) { $p = new Page(); $p->template = 'filtertest'; $p->parent = 8181; $p->title = "test$i"; $p->a = $tmp[array_rand($tmp)]; $p->b = $tmp[array_rand($tmp)]; $p->c = $tmp[array_rand($tmp)]; $p->save(); $i++; } dump (results): d($pages->find('template=filtertest, a=a, b=b')->each('title')); array (13) 14.48ms, 0.09 MB d($pages->find('template=filtertest, a|b|c=a|b|c')->each('title')); array (3084) 1110.54ms, 6.54 MB d($pages->find('template=filtertest, a|b|c%=a|b|c')->each('title')); array (3084) 1339.68ms, 6.54 MB your filter function looks totally weird to me. you have ID values as filter but then you use the slow %= selector. why? see my first example using " = " as selector should give you an instant result! also i don't understand why you are using the OR operator ( | ) for searching different fields. is the information spread over multiple fields?? shouldn't every filter-value be stored in a separate field? PS: my template "filtertest" has fields A, B and C holding letters from A-Z PPS: are you sure the selector is slowing the site down? maybe it is the way you count your number of results in the filter sidebar?
-
PW 3.0.79 – Covering issues, tweaks, optimizations
bernhard replied to ryan's topic in News & Announcements
@szabesz i disagree about that suggestion. i think it could open more room for bugs and overcomplicate things than it is useful... things are already a little "buggy" when having multiple non-fullwidth fields with showif-dependencies. @ryan it would have been nice to get some feedback about the problems with the forum that occured over the last days: -
Ideas and best practices to secure a member registration system
bernhard replied to modifiedcontent's topic in Security
One very easy and effective solution is to use honeypots. Ryan also uses this technique for Formbuilder and has (like me) very good results. Just remember to turn off the autofill option for the input to prevent the browser from filling your hidden field and marking it as spam.- 10 replies
-
- 3
-
-
- no subscription detected
- not recognized
-
(and 4 more)
Tagged with:
-
upload txt file to root folder and access it from xxx.com/ex.txt
bernhard replied to Kemal's topic in General Support
if you tell us why you did this we might suggest another solution for example you could create a page with a file field. then you would have an easy to use file uploader with all the other pw features like access control and so on and you could access the file via it's url ( /site/assets/files/1234/your-file.txt ). that might or might not be a better solution depending on your usecase... -
i also switched from sublime and overall like vscode a lot. only thing missing is a proper intellisense/code completion so i would be very interested in seeing how that works for you thanks!
-
thanks @abdus , i think i have to give phpstorm (a second) try. i also needed 2 attempts for processwire, so maybe that's a good sign
-
could you please provide some insights on how you are using it? i'm also using vscode because of a recommendation here in the forum by @fbg13 and like it so far, but i would love to see how others do
-
PW3 - Adding Category Posts Count to Sidebar
bernhard replied to ridgedale's topic in General Support
what is the built in debugging? again my recommendation: use tracy you'll get nice info like this: https://processwire.com/blog/posts/introducing-tracy-debugger/#bardump you could just do a bd(ukBlogPosts($posts)) and see what this function returns and why count(ukBlog...) returns 1. you could also see the docs to this function in the code that says that it returns a string: https://github.com/ryancramerdesign/regular/blob/master/site-regular/templates/_uikit.php#L720 ... so count() correctly returns 1 ---------- but back to your initial question: i think it would be much easier to just use the API and forget about the uikit functions that are shipped with the profile! in your case it would be as easy as this: <ul> <?php foreach($pages->get('/categories')->children as $cat) { echo '<li class...>' . $cat->title . ' (' . $cat->numChilrden(true) . ')</li>'; } ?> </ul> -
robin, you are right. but his wordpress example is also a simplified "sitemap" only showing all pages on the site (if i understand this weird wordpress code correctly ) the equivalent in PW would be something like this: foreach($pages->find('has_parent=1, has_parent!=2') as $p) { echo "<h1>{$p->title}</h1>"; echo $p->body; }; edit: this would mess up the sort, but i think the wordpress example is also not a proper real-life example so it should be a valid comparison...
-
[WIP] ProcessMailer - A module for managing and sending newsletters
bernhard replied to abdus's topic in Modules/Plugins
great to hear that you are working on that, indeed very needed! how do you plan to send the emails? imho it would be nice to be able to easily integrate services like https://www.sparkpost.com or https://sendy.co/ . i'm not sure but i think for large amounts of emails it is better to use some kind of substitution based sending method (https://developers.sparkpost.com/api/substitutions-reference.html ). good luck for this module and have fun -
PW3 - Adding Category Posts Count to Sidebar
bernhard replied to ridgedale's topic in General Support
Those kind of errors can easily be debugged with Tracy. Just install it and then you can do a bd($yourvar) and see what your variable is internally. In your case it would be null, so your get() is wrong somehow. On mobile, so I hope this already helps -
maybe a nice showcase of what can be done with processwire with VERY little code
-
https://www.baumrock.com/portfolio/event-voting-tool-social-impact-award/ Another nice little Showcase of what can quickly be done with Processwire I sponsored this voting tool for the Austrian Social Impact Award ceremony (https://socialimpactaward.net/) helping them to pick the winner of the audience voting. The site is based on the default UIKIT theme (obviously) and i basically just placed the logo + changed the colors. The site structure is also very simple, having only one parent to store all teams, one parent to store all votes and one page to show the results (to the admins): The Projects-Template stores some informations of the project and the vote-count: All the votings are single pages as well having only one checkbox, ensuring that every code can only vote once (every visitor got one code at the entrance): Votes are created via Tracy Console as easy as that: The hook that creates the passwords is also simple: /** * create unique code for voting */ $wire->addHookAfter('Pages::saveReady', function($event) { $page = $event->arguments(0); if($page->template != 'vote') return; if(!$page->title) { $rand = ''; while(!$rand OR pages("title=$rand")->count() > 0) $rand = randomPassword(); $page->title = $page->name = $rand; } }); And finally the check if the vote for this code is already done (inside the vote-template). the whole vote-template is as simple as that (thanks to the awesomeness of markup regions and functionsapi): <?php namespace ProcessWire; // handle votes (url segments) if($id = $sanitizer->int($input->urlSegment1)) { // if voting is locked redirect to thankyou message if($page->votingdone) $session->redirect($page->url); // else set voting $team = pages($id); if($team->id) { // increase voting for this team $team->setAndSave('votes', $team->votes+1); // lock this votings page $page->setAndSave('votingdone', 1); } } ?> <?php // if voting is done show thank you and lock page if($page->votingdone): ?> <region id="main"> <div class="uk-card uk-card-primary uk-card-body uk-width-1-1 uk-margin-small-top uk-text-center uk-border-rounded"> <h3 class="uk-card-title">Danke für Ihre Teilnahme!</h3> </div> </region> <?php return; endif; ?> <region id="main"> <div class="uk-text-center uk-margin-top"><?= $page->parent->body ?></div> <?php foreach(pages('template=team, sort=random') as $team): ?> <div class="uk-card uk-card-default uk-card-body uk-width-1-1 uk-margin-small-top uk-border-rounded"> <h3 class="uk-card-title uk-text-center"><?= $team->title ?></h3> <ul uk-accordion="collapsible: true"> <li> <p class="uk-accordion-title uk-text-center"><span uk-icon="icon: chevron-down"></span> Beschreibung anzeigen</p> <div class="uk-accordion-content"> <?= $team->body ?> </div> </li> </ul> <a href="<?= $team->id ?>" class="uk-button uk-button-large uk-button-primary uk-width-1-1 uk-border-rounded">Für dieses Projekt abstimmen</a> </div> <?php endforeach; ?> </region> I'm still impressed by ProcessWire and how much can be achieved with how little effort
-
- 23
-
-
i think the superuser name is much better than webmaster: https://en.wikipedia.org/wiki/Superuser and i think once you got some experience using permissions everything should be quite clear. i think my learning curve was: create an editor role assign page-edit permission try to edit a page... why does it not work? ah, i have to set the permission on the template level (meaning i can control it on a template level) ah, i can inherit to all child pages done i think that's not too hard for someone wanting to work with user permissions
- 14 replies
-
- 2
-
-
- admin
- permissions
-
(and 2 more)
Tagged with:
-
just add the "pw-panel" class to your link. if you want it to reload on every open add "pw-panel-reload". see here for details: https://github.com/processwire/processwire/blob/master/wire/modules/Jquery/JqueryUI/panel.js
-
you are right! thanks. than that's of course not possible. didn't think of that since i always updated my modules through git pull... so +1 for /site/assets/TracyDebugger/snippets agree
-
not if the folder is empty and excluded from git. or am i wrong here?
-
i prefer to have a dedicated folder for code snippets inside the modules' folder ( /site/modules/mymodule/snippets ). it's simple to implement, it's simple to work with and it's simple to communicate! think of the difference that ready.php made to hooks. any newbe can easily add hooks to the system by some help in the forum "just put this into the /site/ready.php file..." a configurable option is nice to have but needs more config for the dev (applying the correct settings to the module compared to just placing a file in the right folder) and also for communication in the forum ( place the file wherever you like, set the correct path in the module, with or without trailing slash, relative to xy... ). but i had this discussion with @kongondo regarding his runtime markup field and "lost" (using my own render method), so maybe i'm alone with that opinion...
-
the latest weekly.pw had a survey about that topic: i'm on self-managed VPS using plesk as controlpanel. current pricing is 15€ for 2core / 4GB / 150ssd / 10 domains or 30€ for 4core / 8GB / 400ssd / 30 domains i tried several other options over the last months ( digitalocean self managed, cpanel, laravel forge, serverpilot ) but i came back to vps + plesk because it is quite easy to use (for me as a non expert) but also offers a lot of freedom if you need advanced stuff (having full ssh access). all the other solutions where always lacking some parts and would have made another service necessary (like backups, for example). looking forward to hearing other experiences
-
it's just too easy to create them
-
PW3 - Adding Category Posts Count to Sidebar
bernhard replied to ridgedale's topic in General Support
when you put variables in selectors you need to use double quotes! otherwise php will use $var as regular string and not as a variable. // this does not work $pages->find('categories=$cat') // this works $pages->find("categories=$cat") edit: just saw you have some more code... // change this echo "<li><a href='$cat->url'>{$cat->title} {$pages->find('categories=$cat')->count}</a></li>"; // to something like that echo "<li><a href='{$cat->url}'>{$cat->title} " . $pages->find("categories=$cat")->count . "</a></li>"; -
does that tip help?