Jump to content

adrian

PW-Moderators
  • Posts

    10,912
  • Joined

  • Last visited

  • Days Won

    349

Everything posted by adrian

  1. You'd know the line numbers from any error messages that Tracy has reported. You can of course always enter line #1 for some scenarios. Maybe it would be nice if I had a trigger for inserting at the last line as well? But, agreed it is probably a little obscure as a feature - I'll see how much I end up using it and see if others find a use for it.
  2. Thanks for your writeup also @matjazp - great to have this stuff documented! I have committed a fix for the blank line number issue you were having. Please let me know if it works now. New Feature I have just added a new feature - it's a bit experimental, and I am not sure just how useful it is so would appreciate feedback. It provides the ability to insert debugging statements (actually any code you want) at designtaed lines in the compiled template at runtime. I see this as useful if you want to quickly debug something on a live site without having to edit the files on the server. In this example I am inserting two barDump (bd) statements into the home.php template file at lines 61 and 63 and noting which one is before the variable is iterated and which one is after. The code for the home.php file looks like this: And this is the result in the dumps panel: Obviously the scenario and the inserted debug statements could be quite different, but hopefully you get the idea. Note: Any lines of code inserted like this are only executed for superusers, so you could even use this as a way to insert lines of code that affect the output on the page without it affecting other users and guests. Also, be sure to remove any statements when you are done debugging, because the template file is re-compiled every time the page is loaded when this field is populated.
  3. Awesome writeup - thanks @tpr!
  4. @matjazp - thanks for the info on the changes to list() in PHP 7 - I hadn't seen that yet, although from reading about it, I don't think it actually affects that code. No problem at all - I assume the only places where this is affecting you are the links to the template file from the PW Info panel (both in the template info section and the icon at the bottom)? Are there any other locations with links without line numbers that I haven't thought of? Awesome - care to share any tips for setting it up? Did you work with this file: https://github.com/adrianbj/TracyDebugger/blob/master/tracy/tools/open-in-editor/open-editor.js Thanks!
  5. Hi everyone, Thanks to prompting from a good friend who is doing his first site with PW, I have added the ability to completely lock/prevent changing of the page name. This is achieved by a new option: "Automatically rename the name field to match the title" - this is checked by default as this is the whole reason this module was created. But now by unchecking this, you can revert to PW's default behavior. Why not just uninstall once the site is live you ask? Good question The reason is that now you can use the "Prevent Manual Changes" options along with this to make it impossible to change the name of the page. The default PW behavior allows all site editors to change the name - but if you want to prevent this, you can now do it easily. You can also add superusers (and other roles) to the list of roles that are exempt from the "Prevent Manual Changes" option. Anyway, hopefully others will find this useful as well.
  6. Ok, the latest version now correctly modifies the editor path to the file in the errors panel, as well as dump() and barDump(). Thanks again @szabesz for helping so much to figure this out - sorry we got so sidetracked along the way
  7. Great - thanks for confirming that the paths are correct for dump() and barDump() The class not found error will be because of the template being the ProcessWire namespace. If you are doing that, then you'll need prepend a "\" to your calls, eg: \Tracy\Debugger::dump('Test \Tracy\Debugger::dump'); \TD::dump('Test \TD::dump'); and then they'll work fine.
  8. Oh, I see - I have been running in StrictMode, so haven't been noticing that - there is another location that I need to add that hack to change the path. I'll get that fix committed shortly. @tpr - is this the case for you also? Do the links from dump() and barDump() calls get converted properly?
  9. Thanks! I am wondering what links are actually showing the compiled file? Can you show a screenshot of the link you are trying to click on? Here are some examples showing it working as expected: Link from a dump() Link from a barDump() I am starting to think you are talking about other links, but I am not sure what!
  10. Is $loc always 0 ? If so, then that's the problem. I get it 0 sometimes - when the first result of findLocation() is a module file. But when it's a template file, $loc returns 7 At least from this: [0] => .../site/assets/cache/FileCompiler/site/modules/TracyDebugger/ProcesswireInfoPanel.inc I can see that the path in $file is matching something that the next line can remove the "/site/assets/cache/FileCompiler" component to make it the path to the original file. Can you please clarify that $loc is always 0? What if you force it to 7 on line 100? Thanks again for your help with this!
  11. list() populates the $file variable from the result of findLocation(), or NULL if $loc returns false. I am not sure what's going on, but if your edit links are to the compiled file, then it would suggest that $file is being populated. Could you maybe check the value of $loc and self::findLocation() before that list() call please?
  12. Hey guys, I am not sure what is going on. To make this work I have made a small tweak to the Tracy core (hopefully only temporary as I have asked them about a way to publicly modify the filepath) - you can see it here: https://github.com/adrianbj/TracyDebugger/blob/master/tracy/src/Tracy/Dumper.php#L111 Would you mind taking a look at that and debugging why it might not be working - just find out what $file contains before and after that str_replace I can imagine on Windows I probably need to replace all the "/" with DIRECTORY_SEPARATOR but it sounds like @szabesz is on a Mac so what I have should work? Thanks to both of you for helping out with this.
  13. You can now click on the text of any entry in the PW and Tracy log panels to open the file in your code editor to the line number of the clicked entry. Of course for this to work, you need to have properly configured your editor protocol handler. Not really worthy of a screenshot, but still a very handy shortcut that I hope you'll find useful for when you have an log entry that has been truncated because it's too long for the built-in viewer.
  14. #7 of 50: http://dailycodex.com/top-content-management-systems/ http://www.queness.com/post/14579/6-lightweight-flexible-php-cms/page/1 http://preludi.fi/blog/processwire-julkaisujarjestelma-6-syyta-valintaan
  15. Nice one bernhard - I totally missed the line in the OP noting that PW was being bootstrapped
  16. Nice one Jan Romero - I hadn't seen the use of the Selectors class and PageFinder like that. Putting it all together: $selectors = new Selectors("template=basic-page"); $pagefinder = new PageFinder(); $sql = $pagefinder->getQuery($selectors->getArray(), array("returnVerbose" => false))->getQuery(); $result = $database->query("SELECT SUM(data) AS sum_amount FROM field_amount WHERE pages_id IN ($sql)"); $sum = $result->fetch(PDO::FETCH_COLUMN); echo $sum; Note that I had an SQL error regarding "SQL_CALC_FOUND_ROWS" when I included a limit in the selector. If I removed the SQL_CALC_FOUND_ROWS then it complained of not allowing limit in IN. Remove the limit from the selector and things work just fine. Also, note that you need to specify "returnVerbose" => false - otherwise you get a php NOTICE: https://github.com/ryancramerdesign/ProcessWire/issues/1734
  17. Not necessarily the answer you are looking for, but searching on Github is often very enlightening: https://github.com/ryancramerdesign/ProcessWire/search?utf8=%E2%9C%93&q=%22%24field-%3Eattr%22
  18. If you didn't have so many pages I would say go for something like this where you populate the pageids from your selector in the IN clause. SELECT SUM(data) AS sum FROM `field_amount` WHERE pages_id IN ( 1234, 2412, 1234 ) But with 1 million page ids in your "IN", that's not going to work What about this: SELECT SUM(data) AS sum FROM `field_amount` INNER JOIN `pages` ON `field_amount`.`pages_id` = `pages`.`id` WHERE `pages`.`templates_id` = 29 The problem with this is that you need to reproduce your initial pages selector - in my example I am just limiting to a template. Do you think you could make this work? What is your actual selector?
  19. Sounds like output formatting may be off, or you have changed the Formatted Value for the field - what is that set at? Also, try this just before outputting the image and let me know what it returns. echo $page->of();
  20. Looks like the homeboximage field is not set to "1" for the Max Files Allowed setting. Either change that, or do: echo $homebox->homeboximage->first()->url;
  21. Hi everyone, Thanks to a request from @Ralf, this module now also works on the front-end. If you have setup your own login form and profile editing forms you can enable this for the front-end and specify a URL to redirect to for the user to change their password.
  22. This tutorial from soma might also be useful: https://processwire.com/talk/topic/4602-flexible-downloads-using-pages/ Also, if you're working with SVG files, these two modules might be of interest: http://modules.processwire.com/modules/image-rasterizer/ http://modules.processwire.com/modules/file-validator-svg-sanitizer/
  23. I think what you are looking for is whitelist: $input->whitelist($name, $value) Read about it under the getVars section on this page: https://processwire.com/api/modules/markup-pager-nav/
  24. New public method: TD::templateVars() templateVars() tv() Basically what this does is strip any system PW variables and returns just those that you have defined in your template file. It replicates what is output on the "Variables" panel, but lets you dump, barDump, fireLog, or log at whatever points you want throughout the execution of your template file script. Obviously if you are only interested in the changes to one variable there is no point in using this, but if you want to see how they all change, this is a nice shortcut. It is really only designed to work with PHP's get_defined_vars() Here's an example output via barDump: bd() $i=0; $x=10; bd(tv(get_defined_vars()), 'breakpoint one'); $i++; $x--; bd(tv(get_defined_vars()), 'breakpoint two'); This results in: Without tv() in there it would include all PW variables/objects and it would be difficult to see the variables you are interested in. Note that the templateVars() and tv() shortcuts/aliases may need to be turned on in the config settings if you are upgrading.
  25. Small update that enhances links from the PW Info panel Summary section - now you can have shortcuts to either view (page name) or edit (page id) each of the linked pages that are related to the current page. The children item now has: an "open tree" link (opens this page in the page tree expanded to show all children) an "edit" link (opens this page to the Children tab, which is particularly useful if you have Batch Child Editor installed). The template filename in the Template Info section uses the defined editor protocol handler to open the file directly in your code editor. Hopefully you'll all find these nice little time/click savers And page edit and template file edit buttons are also in the footer of this panel for instant access:
×
×
  • Create New...