Jump to content

bernhard

Members
  • Posts

    5,677
  • Joined

  • Last visited

  • Days Won

    264

Everything posted by bernhard

  1. hi donald, the module is not intended to be used on the frontend. though it is not that hard to do it... example home.php <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title><?php echo $page->title; ?></title> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/handsontable/0.34.5/handsontable.full.min.css" /> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/handsontable/0.34.5/handsontable.full.min.js" /> </head> <body> <h1><?php echo $page->title; ?></h1> <?php if($page->editable()) echo "<p><a href='$page->editURL'>Edit</a></p>"; ?> <?php bd($page->cars); ?> <div id="example"></div> <script type="text/javascript"> var container = document.getElementById('example'); var hot = new Handsontable(container, { data: <?= json_encode($page->cars->data) ?>, rowHeaders: false, colHeaders: <?= json_encode($page->cars->colHeaders) ?>, }); </script> </body> </html> the field config for the backend: $(document).on('afterInit.rht', '.handsontable', function(e, hot) { var colheaders = ['Volvo', 'Audi', 'BMW']; hot.updateSettings({ colHeaders: colheaders, minCols: colheaders.length, maxCols: colheaders.length, maxRows: 1, minRows: 1, rowHeaders: false, }); }); i don't know any technical details of the other module. i built this module to have a quick and easy way to INPUT some table data and be able to copy&paste from excel. for me the benefits of this module compared to the matrix field is the look&feel. it's more compact and more excel-like, so it's easier to grasp for my clients. but the field has some major limitations you have to keep in mind. for example changing inputfield config after some data already has been stored would lead in data destruction. its also not possible to use this data in selectors. and multilang values are not supported. thats no problem as long as you have only have numbers as data because you can translate column headers (see above example).
  2. Wishlist --> Posted Saturday at 03:12 AM New Module --> Posted Saturday at 06:08 AM crazy
  3. never used it but you could save another line with conditional hooks https://processwire.com/blog/posts/new-ajax-driven-inputs-conditional-hooks-template-family-settings-and-more/#new-conditional-hooks $wire->addHookAfter('Page(template=admin)::render', function($event) { ... });
  4. Sure, just hook page render and modify event->return like I showed above. I'm on mobile but this info is easy to find in the forum, it's nothing special
  5. You can also inject scripts and styles by hooking the page render and doing a str_replace("</head>", $yourscripts . "</head>", $event->return)
  6. hi avd and also welcome from my side, nice to hear that you get a pw site. maybe you can share your experience of pw after your first steps with us? would be interesting to hear! in processwire you can make almost everything editable. you CAN. but it's all up to the developer. and in my opinion thats a good thing. so the question is always WHY do you want to make this or that editable. if you have a valid reason one can just create a field for that and build that functionality into your site. but for other things that will not (or should not) change often it's better to change the code directly (and fonts seem to be a good example for that). hope you enjoy pw and your agency does a good job
  7. 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, }); });
  8. @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
  9. i haven't used markup regions on larger projects. ryan said its a little more overhead. but for smaller projects imho it is the cleanest and easiest solution. i think its much easier to understand for newcomers than the regular delayed output. it was also great to work together with my designer
  10. 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.
  11. 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
  12. 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.
  13. maybe this? https://processwire.com/blog/posts/inline-ajax-page-editing-comes-to-listerpro-processwire-2.6.6/
  14. 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!
  15. 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
  16. 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
  17. 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
  18. are you talking about any kind of automated testing? or manual testing for hand picked use cases?
  19. 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/ )
  20. 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...
  21. 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?
  22. 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
  23. 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).
  24. 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...
×
×
  • Create New...