Jump to content

3fingers

Members
  • Posts

    437
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by 3fingers

  1. Ok, we got it! Final code: $pages->addHookAfter('saved', function($event){ $pages = $event->object; $page = $event->arguments(0); if($page->template != 'single-comment') return; $total = array_sum($pages->find("template=single-comment, indice_01!=''")->explode('indice_01')); $pages->get('/comments/')->setAndSave('totale_indice_01', $total); }); Basically I had to insert "$event" as parameter of the function and correct an "_" to "-" in the template declaration Super-many-giga thanks to LostKobraKai, you are my new hero for today
  2. Thanks LostKobrakai, even though I had to add $event as a parameter to your function, your code still doesnt work, and it's very strange because it looks like it should. I'm going to post some screenshot in a minute. Edit:
  3. I've changed my code into this: $pages->addHookAfter('saveReady', function($event) { $pages = $event->object; $page = $event->arguments(0); $tot_indice01 = $pages->get('/comments/')->totale_indice_01; if($page->template == 'single-comment') { $total = 0; $total += $page->indice_01; $tot_indice01 = $total; } }); But still no luck. Field "totale_indice_01" is still blank...
  4. My typo, right. But how would I get all instances each time? Kinda stuck
  5. Hi guys, here I am again with another question. I have a template (name="comments") who has inside an integer field (name="totale_indice_01"). I have another template (name="single-comment") who has inside - among other fields - an integer field (name="indice_01"). This template is associated to several pages. I would like, on every save page, to sum up the value of the field "indice_01" and save that value to the field "totale_indice_01". I'm trying to insert this code: $pages->addHook('saveReady', function($event) { $pages = $event->object; $page = $event->arguments(0); $tot_indice01 = $pages->get('/comments/')->totale_indice_01; if($page->template == 'single-comment') { $total = 0; $total += $page->$indice_01; $tot_indice01 = $total; } }); inside site/admin.php with no luck Could anyone point me in the right direction? Thanks!
  6. Or maybe something like: $first = $page->children("template!=cta-block|puffs-block|table-block"); $second = $first->not("template=company, website=''"); // That is the verbose version of what you have done before, and a slightly change on parenthesis. Written in a hurry
  7. Same is happening here, I've just tried with one of my installation. Cannot find a solution right now, but that's interesting.
  8. Dont' know why this is happening, but may I ask you why you need the <strong> tag inside the "format" dropdown? Isn't enough to have the "B" button for that? ...and in case you need to apply <strong> instead of <b> you could check this link. Am I missing something?
  9. This module (still a WIP but looks like it's working) could be a good starting point...
  10. You could try to use the new ajax-driven inputs (more on that here). Basically you can tell Processwire to delay loading of some specific inputs (or groups of inputs) until they are opened/selected. Worth a try in your case. Let me know
  11. I don't know if there is a better way to achieve the same result,I had (for a previous project) to insert : CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: config.protectedSource.push(/<i[^>]*><\/i>/g); config.enterMode = CKEDITOR.ENTER_BR; // I added this because I didn't want a new <p> tag on every new line, <br /> instead. }; CKEDITOR.dtd.$removeEmpty['i'] = false inside site\modules\InputfieldCKEditor\config-body.js (you shoud already have that file there). To be honest I don't know why this is necessary and doesn't work by default, but as far as I know it's not related to processwire, rather by Ckeditor itself.
  12. You can also add your personal styles in site->modules->InputfieldCKEditor->mystyle.js Example: CKEDITOR.stylesSet.add( 'mystyles', [ { name: 'Credit Card Icon', element: 'i', attributes: {'class': 'uk-icon-credit-card-alt'} }, { name: 'Panel Title', element: 'h4', attributes: {'class': 'uk-panel-title'} }, ]); You could now select on-demand which <i> and <h4> you want to apply those styles.
  13. Thanks @DaveP, it worked flawlessly. Next time I'll take a closer look at the cheatsheet
  14. Hey guys, I'm running into a problem: <?php // my images field is named "filter_image": $pagesWithImages = $pages->find("filter_image.count>0"); $filtered = array(); foreach($pagesWithImages as $p) { foreach($p->filter_image as $image) $filtered[] = $image; }; $out= ""; foreach($filtered as $filter){ $out .="<div class='filter-box' style='background-image: url({$filter->url});'>"; $out .= "<div class='uk-overlay uk-overlay-hover uk-position-cover'>"; $out .= "<div class='uk-overlay-panel uk-position-cover uk-overlay-background uk-overlay-fade uk-flex uk-flex-center uk-flex-middle'>"; $out .= "<a class='hover-btn' href='{$p->url}'>{$filter->description}</a>"; // How can I get the url of the page the image belongs? $out .="</div></div></div>"; } echo $out; ?> This code works fine, but how can I get the url of the page the image belongs? I'm tired and I cannot find the right answer.... Any advice? Thanks!
  15. Ok got it. That Object (indeed an array) and its methods are defined here. Very useful advice and link you gave me @kongondo (and thanks @soma too). (Y)
  16. Hello all, today I was looking (just for curiosity and for learning sake) at PageFrontEdit core module, specifically at PageFrontEdit.js file. I cannot uderstand this line of code (among others ) where loadCSS function is calling Processwire.config object's method. (I know what is trying to do....load a css file defined by that object and its methods). That Object is not initialized anywhere in the file and could not find a reference whatsoever. I'm sure it's my fault (honestly I'm not so experienced in Javascript) but if anyone could point me in the right direction would be very appreciated! Thanks!
  17. I'm a bit in a hurry, sorry if my comment is quick and direct. There's a problem with the animations of various content block which immediately appears even though no scroll animation is triggered, infact if I inspect the console: (index):281 Uncaught ReferenceError: $timeline_block is not defined every time a scroll event is triggered. Site design is nice but despite the problem I noticed above I think there are too many "unjustified" animations occouring, I would probably go to a subtle approach, a bit muted here and there. My two cents, of course
  18. 3fingers

    5 of a kind

    Nice works Macrura, as always A quick note on the Roger Shapiro Fund site: on every page load I notice a "Please enable Javascript" (on the top left of the screen) for half a second or so, then the view fade in correctly. Other than that, everything runs fine and smooth.
  19. Hi solido ( ciao, anche io italiano ), I suggest you to go to this thread, I had the same exact problem as yours while ago and in the end I decided, for lack of time, to swap my fields from one language to the other and then revert the default language. You can, anyway, check the proposed module by @bcartier and see if it works for you.
  20. Thanks to both of you guys, I "solved" swapping the content of my fields from one language to the other and renaming the default language from /en to /it and viceversa. Hope someday it will be easier to switch the default language
  21. I have the same exact problem and it's driving me totally crazy...I've installed both the module ESRCH suggested and AutoDetect Language module. It seems to work if I reach the homepage for the first time (redirecting correctly to /it rather than /en (default)), but if I open a new tab in my browser and retry to go to the homepage the /en appears again. Kinda desperate at this point
  22. Got it, as you may know there is no "good or bad" habit when it comes to organise contents (as long as a pre-production plan is present). MVC, well...I'm still the "old school" guy too, mainly because I never had to face projects where there was such restriction (or property) to learn.
  23. Hi, bit in a hurry but you can check repeaters docs here (bottom of the page you can check how to fill them via API): https://processwire.com/api/fieldtypes/repeaters/. Take a look here too: https://processwire.com/api/fieldtypes/repeaters/ A little hint on TrackChanges: https://processwire.com/talk/topic/4880-questions-about-the-usage-of-trackchanges/ Btw, why (in the code above) are you creating a page with the username as title and then, as a child of if, a page with user infos? You could just create one page per user, with title and infos in there, in just one place.
  24. From the docs echo $page->cropImages->eq(0)->getThumb('thumbnail'); In your case then echo $page->cropImages->eq(0)->getThumb('square'); // 400*400 thumbnail echo $page->cropImages->eq(0)->getThumb('landscape'); // 400*300 thumbnail echo $page->cropImages->eq(0)->getThumb('portrait'); // 340*453 thumbnail
×
×
  • Create New...