-
Posts
6,671 -
Joined
-
Last visited
-
Days Won
366
Everything posted by bernhard
-
sorry no memory issue any more is there some caching that i can reset? i had to decrease it to 16MB to get the error... thanks, works!
-
-
for me it is only one click on the heart (also have to get used to that ^^)
-
Preview/Discussion: RockDataTables
bernhard replied to bernhard's topic in Module/Plugin Development
PM -
hi @Martin Muzatko i would recommend you read the docs about hooks carefully: https://processwire.com/api/hooks (especially here: https://processwire.com/api/hooks/#add_new_method ) to your problem: try this: public function getMessagesBySender($event) { $user = $event->object; $sender = $event->arguments[0]; $event->return = $user->getMessages()->find('sender='.$sender); } you could also modify your getMessages method to take an argument as selector and then use it like this: $user->getMessages("sender=$user"); // additional tip: double quotes makes it easier to read sometimes ;) regarding the "event system": $event in the hooks is the hookevent object. you could call it whatever you want, but as it's called $event everywhere in PW it's good to stay with this naming. the object is needed by PW and it's hook system so you cannot just "return" from inside the method. or to be more clear: you can just return but then it will not change anything. thats the way how you can do early exits: $wire->addHookAfter('Pages::added', function($myHookEvent) { $page = $myHookEvent->arguments(0); if($page->template != 'mytemplate') return; // example of early exit [...] } here i named $event differently just as a showcase. the $event->return property holds the "value" of the hooked method. this can be different things, for example a PageArray if you hook a page find operation or a simple string if you hook a field's value. This value is only one thing that is needed by processwire to fully execute the request. For example there is also the $event->replace property that would tell PW to completely replace the hooked method if it was set to TRUE - so pw would not call the original method after the hook was executed (this only works on before-hooks, of course). https://processwire.com/api/hooks/#replace_method hope this makes sense for you. i would also recommend using tracy debugger - it's a lot more powerful and easier to read than var_dump
-
nice and besides that it is easy to add i think it would be nice to have it in the core. maybe you can add a PR @Martin Muzatko ?
-
hi @Pete sorry for being a little off-topic but you didn't read my PM from july... is there a reason why ma attachment limit seems to be always decreasing? i have only 2MB limit left and it seems it's getting lower and lower... thx
-
what about this? <?php $allTitles = $yourPageArray->each('title'); // or if it was more complex $allTitles = $yourPageArray->each(function($page) { return "{$page->forename} {$page->surname}"; } you can also add your own methods via hooks: $wire->addHookMethod('WireArray::test', function($event) { $arr = $event->object; $out = []; foreach($arr as $item) $out[] = 'testing page ' . $item->id; $event->return = $out; });
-
@abdus i like the idea of using only one field and adding options via hooks, but i don't think it's the most userfriendly to throw an exception after pagesave in case someone uploads more than 1 image. i guess it should be possible to set the max-file setting and show the upload on the client side before upload?
-
sorry my solution only works if you have zip-codes like 1... 2... 3... 10... and 19... would be listed under 1... you could replace the for(...) with this $zipcodes = [11, 15, 80, 99]; foreach($zipcodes as $zip) { ... } always depends what your initial data looks like (if you know the zip-code-categories or if they are dynamic). 1 question, so many answers
-
hi and welcome deceleration quite easy: <?php // overview for($i=1; $i<??; $i++) { echo "<a href='./$i'>"; // create a link with that url segment echo "ZIP $i... [" . $pages->count("template=yourtemplate, zipcode^=$i") . "]"; echo "</a><br>"; } // details $zip = $sanitizer->int($input->urlSegment1); if($zip) { $items = $pages->find("template=yourtemplate, zipcode^=$zip"); foreach($items as $item) { echo "<a href='{$item->url}'>{$item->title}</a><br>"; } }
-
Never said that I would recommend reading my second link carefully and trying out markup regions (... And building your site with a template for your child pages instead of URL segments)
-
Preview/Discussion: RockDataTables
bernhard replied to bernhard's topic in Module/Plugin Development
datatable connected to the pagefield updating the pageautocomplete field seemed a little tricky in the beginning but the final approach was quite easy: // handle buttonclicks $('#addcompetences').click(function(e) { e.preventDefault(); var table = $table.DataTable(); // datatable instance var $field = $('#wrap_Inputfield_competences'); // asm select field var $template = $field.find('li.itemTemplate'); // selected page template var $ol = $template.closest('ol'); // get selected competences from table var selectedtable = $.map( table.rows({selected:true}).data(), function(val, i) { return [[ val.id.sort, val.title + ' (' + val.cluster.filter + ')' ]]; } ); // update ASM // clone template and populate values $.each(selectedtable, function(i,val) { // check double if($ol.find('.itemValue:contains("' + val[0] + '")').length) return; // add clone var $new = $template.clone().appendTo($template.parent()); $new.find('.itemValue').text(val[0]); $new.find('.itemLabel').text(val[1]); $new.removeClass('itemTemplate'); }); // add state changed class $field.addClass('InputfieldStateChanged'); // update original input InputfieldPageAutocomplete.rebuildInput($ol); return false; }); -
abdus code would work great, but still i don't understand what is bad about having a template file for each of your children. url segments in those cases have some drawbacks that you may not think of before and always need some extra work (for example creating a sitemap, multilanguage or the like...). hearing that this scenario makes problems for you i guess maybe your setup is not optimal. using https://processwire.com/docs/tutorials/how-to-structure-your-template-files/page4 this would be very easy. and using https://processwire.com/blog/posts/processwire-3.0.62-and-more-on-markup-regions/ it would be even easier.
-
i know that this would change but i thought you maybe request only some content via ajax or the like and populate areas in your parent page's template. i don't really get what you are trying to achieve and what the problem would be with a template for your child pages... but it's late here
-
then i didn't understand your question, because my solution would have nothing to do with seo
-
maybe you can use the page id as url segment? then you do not have the name conflict (or at least you would only have it if a page with the name of another page's id exists, what should be at least very unlikely or if you take care of this would be impossible). ps: or you take an url segment like #getcontent#123 and then you strip off the #getcontent# part and request the page's content by the id
-
hi adrian, me again just wanted to try captain hook and got a memory error with the default 128M php setting: setting it to 256M helped but I'm not sure why this happend or if tracy should also work with 128M of memory and this is a bug?
-
hi adrian, just updated tracy from the version before the console ready.php include and now i got an error Call to a member function addHookAfter() on null because i add my hooks like this: // set all languages active automatically $wire->addHookAfter('Pages::added', function($event) { $page = $event->arguments(0); foreach ($this->wire->languages as $lang) $page->set("status$lang", 1); $page->save(); }); as quickfix i added this on top of the file: $wire = $this->wire; i think it would be nice to have the wire variable available by default. what do you think?
-
Very nice indeed! i had no problems at all here on my 7Mbps internet and very old PC. I cannot even remember when i bought it ^^ One feedback: I liked the customer story but imho the end was a bit sudden. It only redirects to the services page and there is no real call to action or no hint where the customer could continue. What do you think of some help like "contact us or see our portfolio" on that page?
-
Since I read about the new fieldsets I'm thinking if it would make sense to have some kind of fieldset library. Maybe export jsons in github gists? Or maybe collect them just in a forum thread here... This could make it more easy and more efficient to share common fieldsets, like SEO, person details or the like. What do you guys think?
-
hi @rafaoski maybe https://laragon.org/ is interesting for you as a replacement for xampp. i use it on win10 for about a year and it's great
-
Wishlist: Group field for grouping fields
bernhard replied to steveooo's topic in Wishlist & Roadmap
finally: https://processwire.com/blog/posts/processwire-3.0.73-and-new-fieldset-types/ -
very nice and welcome update!!
-
hi Jacek, if I understand you correctly it seems like this module could help you: