Jump to content

SamC

Members
  • Posts

    733
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by SamC

  1. I'm writing a tutorial on using tracy soon, started it the other day. It's a chance to finally get my feet wet with it myself, and to share whatever I learn along the way. I'd give the dev branch a go.
  2. This may seem like a dumb question, but running this in the Tracy console actually deletes the pages on the site? Here's me, trashing -> going to trash, checking them all, confirming deletion like a sucker!
  3. Yeah totally! I saw that suggested by @adrian in the other MySQL thread. It's gonna be very interesting to see what my $pages->find() are actually doing.
  4. I should have mentioned that he shows this example as a way of showing how the results of this query are undesirable (i.e. only prints first value it finds). Except in my case, it just s***s the bed and complains. He continues to show that GROUP BY would normally be used with MySQL functions, MIN(), MAX(), COUNT(), SUM(), AVG(), NOW(), CONCAT() and UNIX_TIMESTAMP(). Guess what I'll be doing today
  5. SamC

    Share buttons

    Beautifully designed sites! Colour schemes, fonts and white space are gorgeous. I see the social links too, thanks. Great work
  6. Sorry @Juergen I got my wires crossed here, I'm not using ->focus() at all. Just been messing about in the admin, I output just with: <?php // if page has single image field called 'featuredImage' if ($page->featuredImage) { // save some typing... $image = $page->featuredImage; // for demo purposes, don't leave this in! $options = array( "forceNew" => true ); $rec = $image->size(150, 75, $options); } ?> <div class="container py-5"> <div class="row"> <div class="col"> <img src="<?php echo $rec->url; ?>" /> <p> Changed width and height</br> Width: <?php echo $rec->width() . "px"; ?></br> Height: <?php echo $rec->height() . "px"; ?> </p> </div> </div> </div>
  7. It's in my book, he uses GROUP BY on a similar table (with some output though, not an error). I think it's painfully clear I had no idea what GROUP BY does! Lol. However, thanks for the replies. I don't want to disable warnings, rather write decent code. @BitPoets explanation made things a lot clearer!
  8. OMG just tried it out, this feature is KILLER! so much easier now, just set some image defaults (i.e. quality) and leave the rest (cropping to true rather than n, s, se, nw etc.), then just adjust image by image in the admin, amazing. Thanks @ryan Unlike @Juergen above, my image field only allows one image and it works fine.
  9. Not processwire specific, this is to do with what I've been learning in MySQL today. I can't get passed this error and I have no idea what it means. I looked up the docs (and googled the error) but tbh, I don't understand any explanations either. Made a table and tried to use GROUP BY like so, I'm probably missing the point of GROUP BY so any advice would be awesome (there's extra steps in here so I can test out how to insert/alter etc. it's the error that's throwing me): DROP TABLE golfscores; CREATE TABLE golfscores ( id INT AUTO_INCREMENT PRIMARY KEY, member_name CHAR(255), member_score INT ); INSERT INTO golfscores (member_name, member_score) VALUES ("Sam", 30); INSERT INTO golfscores (member_name, member_score) VALUES ("Ben", 28); INSERT INTO golfscores (member_name, member_score) VALUES ("Felicia", 26); INSERT INTO golfscores (member_name, member_score) VALUES ("Sam", 38); ALTER TABLE golfscores ADD member_id INT AFTER member_name; UPDATE golfscores SET member_id = 222 WHERE member_name = "Sam"; UPDATE golfscores SET member_id = 333 WHERE member_name = "Ben"; UPDATE golfscores SET member_id = 444 WHERE member_name = "Felicia"; SELECT * FROM golfscores; id member_name member_id member_score 1 Sam 222 30 2 Ben 333 28 3 Felicia 444 26 4 Sam 222 38 So far, so good! Now when I try and run: SELECT * FROM golfscores GROUP BY member_id; I get the error: Can anyone (attempt to) tell me what this means please (in plain English)? Thanks.
  10. SamC

    Share buttons

    Look very interesting, have you got a link to this in action? Sometimes wish the PW module pages had more screenshots/demos of the modules on offer.
  11. Lol yeah, ended up thinking out loud on that one... This still puzzles me. Doing this (as I learned above) means a bunch of key/value pairs are missed out. I know I've been saying this for ages, but still got to get started using Tracy regularly.
  12. I'm still having some trouble getting my head around the image sizer options. I was going over this old thread (horsts reply in this case): ...which suggests not overriding them in case you miss out any key/value pairs. But then I was reading on the official docs (just after halfway down the page): https://processwire.com/api/fieldtypes/images/ ...but a var_dump of $config->imageSizerOptions shows me this: array(7) { ["upscaling"]=> bool(true) ["cropping"]=> bool(true) ["autoRotation"]=> bool(true) ["sharpening"]=> string(4) "soft" ["quality"]=> int(90) ["hidpiQuality"]=> int(60) ["defaultGamma"]=> float(2) } So does setting default system values in config.php as above not also miss out some key/value pairs? Not sure why I'm having such a hard time with the image options, but I am! Any help is appreciated, thanks. =EDIT= Can I add I just put: $config->imageSizerOptions = array( 'upscaling' => true, 'cropping' => true, 'quality' => 10, ); ...in config.php. Now a var_dump of $config->imageSizerOptions shows me: array(3) { ["upscaling"]=> bool(true) ["cropping"]=> bool(true) ["quality"]=> int(10) } = EDIT = Back again. So did (in config.php): $config->customImageSizerOptions = array( 'upscaling' => true, 'cropping' => 'north', 'quality' => 10, ); $config->imageSizerOptions = array_merge($config->imageSizerOptions, $config->customImageSizerOptions); var_dump of $config->imageSizerOptions shows me: array(7) { ["upscaling"]=> bool(true) ["cropping"]=> string(6) "north" // YAY! ["autoRotation"]=> bool(true) ["sharpening"]=> string(4) "soft" ["quality"]=> int(10) // YAY! ["hidpiQuality"]=> int(60) ["defaultGamma"]=> float(2) }
  13. Can't wait to try out the new focus feature! One question, I haven't tried it, just seen the vid (on the phone now). Does this replace the 'cropping' => 'southeast' from the $options array? What happens if you crop "ne" at 400 x 200 (from an image 1000 x 800) for example then use the focus tool in the page editor? This new feature looks like I can throw all my pre-empting out the window, leave crop at centre, just set the size and use focus. Which would be awesome.
  14. @adrian that's awesome! Need to try this, will be very helpful to see what queries are actually being run. Thanks. @bernhard I was using mysql workbench yesterday, maybe that would be of use to you? You can get visuals etc. I've found it really useful so far. https://dev.mysql.com/doc/workbench/en/wb-performance-explain.html
  15. Sitting here learning MySQL for the first time (along with PHP, i.e. getting some actual core skills...), typing into the monitor stuff like ALTER and ADD. Then reading this thread. Then realising that I got a long road ahead. Gonna put the kettle on.
  16. @Smoo that's what I do on my site. When I create a tutorial post, I can tag it with either existing options, or create a new one: Each one of those is page: This way has the additional bonus of allowing me to show all posts by tag at URLs such as '/tags/ckeditor/'. Works really well
  17. Just tried this morning on a completely fresh install, no prepended files, no extra modules etc. Created a basic structure just with basic page and included "_main-menu.php" which shows the issue of running $pages->children twice: <?php namespace ProcessWire; $root = $pages->get("/"); $topLevelsFirst = $root->children(); $topLevels = $root->children(); $topLevels->prepend($root); ?> <ul> <?php foreach($topLevels as $topLevel):?> <li> <a href="<?= $topLevel->url ?>"><?= $topLevel->title; ?></a> <ul> <?php foreach($topLevel->children as $topLevelChild): ?> <li><a href="<?= $topLevelChild->url ?>"><?= $topLevelChild->title ?></a></li> <?php endforeach; ?> </ul> </li> <?php endforeach; ?> </ul> ..which outputs: ...and <?php namespace ProcessWire; $root = $pages->get("/"); $topLevels = $root->children(); $topLevelsSecond = $root->children(); $topLevels->prepend($root); ?> <ul> <?php foreach($topLevels as $topLevel):?> <li> <a href="<?= $topLevel->url ?>"><?= $topLevel->title; ?></a> <ul> <?php foreach($topLevel->children as $topLevelChild): ?> <li><a href="<?= $topLevelChild->url ?>"><?= $topLevelChild->title ?></a></li> <?php endforeach; ?> </ul> </li> <?php endforeach; ?> </ul> ..which outputs: So I must have $pages->children called earlier on the page somewhere (probably in the main menu above my test one) which would cause the double home link. I think @BitPoet was right earlier about the pointer. This would also be why @kongondo and myself were getting different output.
  18. Yeah that's why it's so weird. I did too! Check my original post, the ids output are: 1|1086|1069|1081|1022 ...for both versions. However, it's the returned WireArrays that are different (check them with print_r ()). One version gives me an added 'Home' link but in order for that to be output in the inner loop, it must have been added to the children of home as the outer loop is correct. If 'Home' was added as an extra parent, then the outer loop would have output : Home|Home|About|Services|Portfolio|Contact It's like there's a wirearray inside a wirearray.
  19. Tried same code, two different sites, one of which is nearly a fresh install with exactly the same issue. If the outer loop, loops through the top level pages (including home) and the inner loop loops through the children of the top level pages, home should never be output inside the inner loop, but it does for some reason. This only happens using: <?php $topLevels = $root->children->prepend($root); ?> <ul> <?php foreach($topLevels as $topLevel):?> <li> <a href="#"><?= $topLevel->title; ?></a> <ul> <?php foreach($topLevel->children as $topLevelChild): ?> <li><a href="<?= $topLevelChild->url ?>"><?= $topLevelChild->title ?></a></li> <?php endforeach; ?> </ul> </li> <?php endforeach; ?> </ul> There's literally no other code affecting this. Nothing in '_init.php' (which I do prepend) and this is just direct output. Check out the resulting WireArrays for these two variables ($topLevels and $topLevels2): <?php $root = $pages->get("/"); $topLevels = $root->children->prepend($root); $topLevels2 = $root->and($root->children); ?> They're not the same. This isn't an important issue, but I'm curious I can't see any errors in the code, or any other code that would affect this throughout the site.
  20. Commenting out (xampp/php/php.ini): [Xdebug] ; zend_extension = C:\xampp\php\ext\php_xdebug-2.6.0beta1-7.1-vc14.dll ; xdebug.remote_enable=1 ; xdebug.remote_autostart=true ...solved the ports issue.
  21. This sounds promising. Will have to check this out. Looking for a one stop solution as I don't want to get distracted from my current activities, learning plain PHP and JS (without any frameworks).
  22. Hi @BitPoet, thanks for the info. Is there an alternative for me re: debugging? I installed xdebug just to use it in visual code but I'm always willing to change tactics. Or maybe change the server. Do the same problems exist with windows WAMP?
  23. My localhost sites suddenly slowed right down and I noticed whenever I clicked a link or refreshed the page, the ports on the XAMPP contol panel for apache keep changing, like flicking through a bunch of ports before settling on '80, 443'. I tried changing the port to 8080, then 8888, but still the same thing. never had this issue before and been using it for years. I use vhosts but I've never experienced this before. I've attached a vid to show what I'm talking about. I'm trying to avoid reinstalling xampp because I have a bunch of local databases in there. https://www.dropbox.com/s/59jayjquuwrntgp/apache-ports.flv?dl=0 Does anyone know what might be causing this? The only thing I've change is adding xdebug to php.ini for visual code, not changed any apache conf settings.
×
×
  • Create New...