-
Posts
6,155 -
Joined
-
Last visited
-
Days Won
302
Everything posted by bernhard
-
FieldtypeHandsontable: Excel-like Inputfield
bernhard replied to bernhard's topic in Modules/Plugins
you need to use pw's built in translation tools on the server side and send the array to your client (js): // some php file loaded in the backend $config->js('colheadersformyhandsonfield', [ 'col1' => __('First column'), 'col2' => __('Second column'), ]; then you can assign them in the js: $(document).on('afterInit.rht', '.handsontable', function(e, hot) { var colheaders = ProcessWire.config.colheadersformyhandsonfield; hot.updateSettings({ colHeaders: colheaders, minCols: colheaders.length, maxCols: colheaders.length, }); }); -
@SamC what are you trying to do exactly? Like always in PW it's up to you. Just wanted to mention markup regions because I didn't see anybody mentioned them. If others are happier with using includes that's totally fine Ps: if performance is a factor for you the best you can do is to invest some euros and 3 minutes to download and install procache. No matter what technique you are using for generating the output, procache will make it lightning fast even on slow servers
-
wow, did'nt read all the answers, but it seems nobody mentioned markup regions anywhere? soma's post is a must-read of course, but it's also from 2011 and we now have the same functionality a lot easier and cleaner imho: https://processwire.com/blog/posts/processwire-3.0.62-and-more-on-markup-regions/ a simple setup could be: _main.php <html> <head> <!-- scripts&co --> </head> <body> <section id="header">your header, menu or the like...</section> <region id="main"></region> <section id="footer">your footer</section> </body> </html> home.php (really no other markup than this in this file!) <section id="main"> <h1>Welcome to my website!</h1> <p>This is the awesome text of my awesome website</p> </section> blogitem.php (for example) <section id="main"> <h1>Blog Item <?= $page->title ?></h1> <?= $page->body ?> <ul> <?php $page->siblings("id!=$page")->each(function($p) { echo "<li><a href='{$p->url}'>{$p->title}</a></li>"; } ?> </ul> </section> This will render your website with header and footer, inject scripts on all sites and just change the content of the main section on your pages.
-
sure: // save data or print errors if(!count($err)) { $answer = $feedback->answers->findOne("competence=$compid"); $feedback->of(false); // save data // if answer does not exist, create it if(!$answer OR !$answer->id) { // add a new repeater item $answer = $feedback->answers->getNew(); $feedback->answers->add($answer); $feedback->save(); } $answer->of(false); $answer->competence = $comp; $answer->rating = $rating; $answer->noanswer = $noanswer; $answer->textfeedback = $textfeedback; // save the changes $answer->save(); // update numanswers field, quickfix for this: // https://processwire.com/talk/topic/17549-is-this-a-wrong-selector-or-bug/ $feedback->save(); } else { // print errors echo implode("\n", $err); } edit: setAndSave was wrong in this regard - i'm using it only to set the repeater values when somebody provides a new rating
-
thanks robin, i found the problem! by coincidence i had to modify one feedback and manually save it. now i wanted to investigate further and got a count of 1 for the answers.count>0 selector. then i saved another page and got a count of 2. so the repeater.count selector seems to work only after a page was saved. i set all the values via API so the selector didn't work. first i thought it's maybe because of setAndSave() but even after a foreach and page->save() the selector didn't work. it works only after a manual pagesave. my quickfix is an additional field + saveready hook that populates the number of answers. I'll file an issue on github.
-
maybe this? https://processwire.com/blog/posts/inline-ajax-page-editing-comes-to-listerpro-processwire-2.6.6/
-
hm... now this is weird thanks for clarifying - yes, i have more than 3 pages with non-empty answers. see the screenshot - does anybody has an idea what could be going on?! the field's name is "answers" (see line 2 of console). maybe this is related to my multilang setup? shouldn't that be irrelevant? thanks for your help!
-
Sorry for being unclear! I would have expected the second to also return five pages but it only returns 3. Thanks for the link szabez, that's a very similar problem but in my case it should also work with the answers.count>0
-
thanks for the topic kongondo i'm still missing proper code completion / intellisense support so i would be happy to get some tips in this regard! thanks
- 242 replies
-
- 1
-
- visual studio code
- vsc
-
(and 2 more)
Tagged with:
-
hi! very strange... i have several feedback-pages that store feedback values in repeaters. i want to show the last 5 feedbacks to my users and did a selector like this: foreach(pages("has_parent=$project, template=feedback, sort=-modified, limit=5") as $p) { d($p->answers->count()); } this works as expected, but we added some feedback-pages and they show up in this list. so i wanted to exclude them by only showing items that have at least one answer in the answers repeater: foreach(pages("has_parent=$project, template=feedback, answers.count>0, sort=-modified, limit=5") as $p) { d($p->answers->count()); } the results are: // first code example 7 0 4 0 7 // second example 7 4 7 any other ideas how i can only show modified pages and NOT newly created ones? thanks
-
Module Preview: Process Documentation
bernhard replied to Macrura's topic in Module/Plugin Development
are you talking about any kind of automated testing? or manual testing for hand picked use cases? -
i think i would create a single blog-entry template with a repeater holding one ckeditor body-field. 1 repeater entry = single page blogpost more repeater entries = blogpost with multiple pages based on url-segments you could show the corresponding repeater item. without url-segment it would show the first. all other content would always be the same (like a comment section, for example would show up on all pages, like here: http://processwire.com/docs/tutorials/hello-worlds/ )
-
this looks great, thanks for sharing! i hope we can get the drag image support into processwire too. that's one of the few things that always needs some explanation for my clients...
-
Module Preview: Process Documentation
bernhard replied to Macrura's topic in Module/Plugin Development
hi macrura! nice to see the progress. i hope nobody gets me wrong but i still think that going with native pw modules (fields) could have some real benefits. i try to explain what i mean and how i came to that opinion... my first impression when i saw your screenshot was, "very nice". i then asked myself how easy that could be built with a process module and InputfieldMarkup... The dashboard example would be quite easy, consisting of only 3 fields with some markup. but still it would need some coding, of course - and that might be a little more work and a little more time needed than your quick ckeditor solution. but still i'm confessed that working with native pw fields is much cleaner than hacking around with hanna codes and several nested tags inside a ckeditor field. that feels like i get thrown back to my old joomla days where we had only this one huge content field and had to do all the magic with messing around with tags and replacements and so on i hope you get what i'm trying to say. btw: i was thinking if i'm messing up your thread with my post, but as it is a preview thread i think discussion should be welcome now my idea that could combine both worlds: first i thought, "why not using some InputfieldMarkup for the content instead of the whole Process?". you are creating a process page that renders one field of a selected documentation page. i thought, what if we had some fields on that page where we can select the content that gets rendered. then i thought we already have this kind of fields: InputfieldRuntimemarkup. So we would need a quick and easy way to arrange those fields! We already have it: The template editor. I'm using ProcessPageEdit all around my CRM application and it works well for presenting data. It has a clean interface and all you need for arranging your content (fieldsets, tabs, toggles etc - i already mentioned that in my post above). So what if we showed the ProcessPageEdit of the documentations page directly to the user? Admins could modify content quickly and easily and for users we could set the visibility to "locked". this would result in something like that: ckeditor fields would get rendered as HTML, image fields would get rendered as gallery and we could do whatever we want with RuntimeMarkup fields. We would have all the built-in pw magic, we would have a consistant styling (for all admin themes, not only for the one your stylesheets are optimized) and many other benefits. what do you think? -
Module Preview: Process Documentation
bernhard replied to Macrura's topic in Module/Plugin Development
that's exactly what i mean nothing will work better than process modules but i get your point. and for simple documentation and text it's for sure easier to type some text into a textarea than writing it into modules. but as soon as it gets to some more complex content i would strongly recommend going with process modules. it's easier than one might think! but we are getting offtopic. @Macrura thanks for sharing this! its a very welcome and much needed addition -
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