Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/02/2018 in all areas

  1. Boolean logic says that, if you want to negate a compound term, you need to negate each individual term AND change the operator. This is commonly referred to as De Morgan's law. !(a and b) = !a or !b Thus, you only need to change the and to or in your if clause: <?php if($item->size->value != 'half' || $item->prev()->size->value != 'half'): ?>
    5 points
  2. If I recall right, I read a discussion or issue about mystyles.js always pointing to the core file in the backend some time ago. The solution there I think was to replace the word mystyles with something different, e.g. renaming site/modules/InputfieldCKEditor/mystyles.js to customstyles.js and using a different name as prefix in the inputfield settings: customstyles:/site/modules/InputfieldCKEditor/customstyles.js Of course, the name change also needs to be done inside customstyles.js: CKEDITOR.stylesSet.add( 'customstyles', [ // style definitions ] );
    3 points
  3. You don't necessarily have to change that approach with ProcessWire ? I've done a few projects with a similar setup, and the easiest method (in my opinion) is to use either sessions (if you're happy to involve PHP in this) or cookies (for a JavaScript only solution) to keep track of the products that were added to cart: When "Add to cart" (or whatever you call it) button is clicked, use JavaScript to add product info to cookie or submit an AJAX request to a PHP based processor in which you sanitise and store product details in PHP session. Note: if you use a PHP processor, you might want to consider making that button a form submit with product ID / details as a hidden text field. This way even if the user doesn't have JavaScript available/enabled, you'll still be able to process the request. When the user reaches the order form, autofill a hidden field (textarea) with contents of the cart. I've handled this part with FormBuilder forms, but obviously you can use a custom form as well. As long as you're essentially just sending a list of selected product names, sanitising data is a simple task, and even if someone does figure out the "hidden form field" trick and goes on to modify the data manually, there's no real harm in that. Or you can just leave that field visible , if it's fine that the client adds more details before sending the enquiry – or perhaps even replace it with a neater UI. Hope this helps a bit.
    3 points
  4. VSCode in my home.php template file (note the marked php start and end tag because I had my cursor there which is not visible in the pic): That's ok because the green parts are just strings for your IDE! Same with VSCode: I think you should have a look at https://processwire.com/api/ref/files/render/g/ Take this example: And in your invoicetemplates.php file you could have clean code just like this: Why not give VSCode a try? ?
    2 points
  5. Of course! ?. Shows you how precious little I know! The best I've been doing until recently is bd($foo, 'bar');! This week I started using the console, like seriously use it, yay! I've been blown away! Even a multi-line cursor! And bd() in the console! I was gonna ask @bernhard to recommend what else I should play with. I've been missing a lot! So no custom permissions then? Looks better, thanks.
    2 points
  6. Another idea for you: Would it be possible on the Dumps and Dumps Recorder panels to auto expand the dump if there is only 1 dump? That way someone doesn't have to click the plus sign or arrow to open the dump every-time the page is refreshed? Currently by default it is always collapsed. No worries if you can't, just a suggestion. Appreciate all you do.
    2 points
  7. No. Its a file field not a folder field.
    2 points
  8. Thanks for the update @adrian For a task like this (wanting to check the a client's access RE a specific page), I'm thinking it would be more useful to actually see the permissions of that client in respect of the said page, rather than scrolling through a potentially long list of all roles (e.g. a large site). The difficulty I see is, obviously, the said client is not logged in when the admin is checking out the status ;-), so this may be wishful thinking. Just wondering... Could the colours please, somewhere, match the current colour scheme of the other panels? I'm 50/50 on this. If I was able to view a page, put a clients name or id in an input and Tracy returns the permission panel, I wouldn't mind it being separate. Just my 2p.
    2 points
  9. Anyone have any thoughts for this new panel before I publish it? Pretty self-explanatory - it shows the status of the various permissions for the current page for all user roles. This should make it much easier to quickly check things if a client complains they don't have access to do a certain action on a specific page. I'll probably commit tomorrow, but just wondering if you guys have any other ideas for this first. Actually, I am now wondering if perhaps this should just be a new section in the RequestInfo panel, rather than a dedicated panel. Any thoughts on this? Thanks!
    2 points
  10. NOTE: This thread originally started in the Pub section of the forum. Since we moved it into the Plugin/Modules section I edited this post to meet the guidelines but also left the original content so that the replies can make sense. ProcessGraphQL ProcessGraphQL seamlessly integrates to your ProcessWire web app and allows you to serve the GraphQL api of your existing content. You don't need to apply changes to your content or it's structure. Just choose what you want to serve via GraphQL and your API is ready. Warning: The module supports PHP version >= 5.5 and ProcessWire version >= 3. Links: Zip Download Github Repo ScreenCast PW modules Page Please refer to the Readme to learn more about how to use the module. Original post starts here... Hi Everyone! I became very interested in this GraphQL thing lately and decided to learn a bit about it. And what is the better way of learning a new thing than making a ProcessWire module out of it! For those who are wondering what GraphQL is, in short, it is an alternative to REST. I couldn't find the thread but I remember that Ryan was not very happy with the REST and did not see much value in it. He offered his own AJAX API instead, but it doesn't seem to be supported much by him, and was never published to official modules directory. While ProcessWire's API is already amazing and allows you to quickly serve your content in any format with less than ten lines of code, I think it might be convenient to install a module and have JSON access to all of your content instantly. Especially this could be useful for developers that use ProcessWire as a framework instead of CMS. GraphQL is much more flexible than REST. In fact you can build queries in GraphQL with the same patterns you do with ProcessWire API. Ok, Ok. Enough talk. Here is what the module does after just installing it into skyscrapers profile. It supports filtering via ProcessWire selectors and complex fields like FieldtypeImage or FieldtypePage. See more demo here The module is ready to be used, but there are lots of things could be added to it. Like supporting any type of fields via third party modules, authentication, permissions on field level, optimization and so on. I would love to continue to develop it further if I would only know that there is an interest in it. It would be great to hear some feedback from you. I did not open a thread in modules section of the forum because I wanted to be sure there is interest in it first. You can install and learn about it more from it's repository. It should work with PHP >=5.5 and ProcessWire 3.x.x. The support for 2.x.x version is not planned yet. Please open an issue if you find bugs or you want some features added in issue tracker. Or you can share your experience with the module here in this thread.
    1 point
  11. Last night my cat bit my hand for no apparent reason while he was sitting in my lap. He's a very friendly cat, but also very old and I think may be getting a little senile. It was a deep bite, though didn't seem like all that big of a deal. But this morning my hand was hurting pretty bad, then it swelled up, and then a swelling red line appeared on my skin that went from my hand to my shoulder. I went to the doctor and he said it was a bad one, and if I hadn't come in today I would have been in the hospital tomorrow. Apparently cats have some mean bacteria in their teeth and these kinds of cat bites can get pretty bad, quickly. They shot me with a bunch of antibiotics and now I've got to go see another doctor and get an x-ray because they think that there's a possibility the cat's tooth broke off and may be stuck inside my hand (I hope not!). If the antibiotics do their thing, all should be fine in a few days. I'd planned on writing a blog post today about ProcessWire 3.0.115, but it looks like that's not going to happen (and one of my hands doesn't work so well), so I'll write about it next week in combination with 3.0.116 updates. But if you want to see what's new in 3.0.115 before that, be sure to check out the dev branch commit log. Thanks for reading and have a great weekend!
    1 point
  12. Ok, I have added this functionality to the RequestInfo panel like I suggested. This keeps things simple and always available. I got rid of all the background coloring - it's really not needed and I prefer the striped rows for clarity of info for each row. Current user is on the first row (and bolded to stand out) so if you're using the User Switcher panel you can quickly get all the details for that current user. I have a few other things in the works, but will commit this shortly.
    1 point
  13. I recently tend to do this, don't know about any best practises, though: That's the only thing where I'm not 100% happy so far. The available plugins that I tried are all somewhat clumsy/bloated/complicated. When I need to edit files directly I browse my server with WinSCP and then I can just double-click the file and it opens in VSCode. I can then edit and save this file from inside VScode and it gets uploaded automatically. For all other edits I switched to a git-setup, so I don't need direct edit via FTP any more. Meanwhile we also have Tracy+File Editor Panel for quick on-demand server edits.
    1 point
  14. I think it's good to have some color. What about the colors of the console - active = white, inactive = light blue: Understand. Thx ?
    1 point
  15. Better imho! I think it could even be grey instead of orange. I'll play around with it one day, but atm I'm busy with other stuff and don't need to care about permissions a lot ? Maybe @tpr comes up with a good suggestion... This isn't about permissions in the sense you are talking about. It's just for these page permissions: https://github.com/processwire/processwire/blob/341342dc5b1c58012ae7cb26cffe2c57cd915552/wire/core/Page.php#L88-L107 Maybe it needs to be reimagined, but that was my initial goal for this. What does everyone think? Oh. I also thought it would list all available permissions. Didn't know about that one. You are absolutely right. Anyhow, it was just an idea. Personally I don't have a need at all for such a panel, but I'm quite sure it can be very handy to have one day...
    1 point
  16. 1 point
  17. Of course, again! Sorry, am half asleep! Custom permissions are mainly used with custom modules ?
    1 point
  18. Nice ? Typically in the Console, you are better off using d() which dumps to the results panel below. This isn't about permissions in the sense you are talking about. It's just for these page permissions: https://github.com/processwire/processwire/blob/341342dc5b1c58012ae7cb26cffe2c57cd915552/wire/core/Page.php#L88-L107 Maybe it needs to be reimagined, but that was my initial goal for this. What does everyone think?
    1 point
  19. Hi everyone, Thanks for all the good thoughts and ideas! There is of course the User Switcher panel which I use the all the time to check issues a client is having - that's the best way to see the site the way they are seeing it. I have just added a new row at the top of the table that shows the permissions for the current user (in this case "ajones"), so this is either you, or if you are using the UserSwitcher panel then it will obviously be for that user. Does that help with what you are looking for? It is using the same colors as the other panels. The colors are all now defined as constants. in the main TracyDebugger class. I know it's a bit loud here, but the idea is for form over function in identifying which roles don't have a certain permission. That said, I'd also be ok with this if you guys prefer: The key thing I think is that I know how many permissions there are and they easily fit on the width of the screen. I don't know how many roles there will be. Does anyone else have any thoughts on this? Not sure if I can because the script that handles the dump doesn't actually know how many dumps are coming, but maybe it can be done with JS after the fact - I'll take a look. I'll need to think about this some more - I feel like we are starting to get into the territory of this module: http://modules.processwire.com/modules/process-access-overview/ which is not really the goal here, or at least it wasn't. I'll let you guys chime back in on what you think would actually be most useful. Thanks again for all the feedback - greatly appreciated!
    1 point
  20. Maybe you want to paste code snippets and a screenshot to help us understand your problem better? I'm using VSCode and it looks like this: Another example with a multiline concatenated string: And another one appending some infos to a rendered field value:
    1 point
  21. Are you talking about a link to the docs or about shortcut links to the settings page of the template where the admin can adjust those permissions? The latter would be great! Maybe there could also be a section where it shows which template setting is responsible, eg: path | template | active -----------------|--------------|-------------------------------- / | home | yes /foo | basic-page | yes /foo/bar | whatsoever | no (inherited from basic-page) The template strings could be linked to the access tab of the template settings. Not sure how complicated that would be to implement, but I think it could be helpful ? +1 for some more thoughts on the colors! I think the red is too loud. It's not a warning imho - it's just telling there is no permission. I think the red could be removed completely. I'm fine with the green - although I think it could also be more quiet...
    1 point
  22. I no longer use PHPStorm but it is also able to properly highlight concatenated strings of source code. So it depends on the capabilities of the IDE/code editor. I simply use the alternative PHP syntax: http://www.brian2000.com/php/understanding-alternative-syntax-for-control-structures-in-php/ in which case highlighting is supported by all editors.
    1 point
  23. Hi, I think that you don't need to do that because $page->comments->count return number of comments for page. Some options to sort pages by comments: // example: page template "blog-item" // $pages->find($selector)... // from top by number of comments $selector = 'template=blog-item, sort=-comments.count' // by recent comment $selector = 'template=blog-item, sort=-comments.created' // by upvotes $selector = 'template=blog-item, sort=-comments.upvotes' Or options by downvotes or stars. Also, there are and additions, eg. "AND comments.count > 10" etc... Regards. EDIT: read again your question, and if you have page array (results), than you can try to filter results with this: $my_results->sort("-comments.count");
    1 point
  24. Good idea adrian! You might want to flip the table rows/columns? roles listed horizontally, permissions listed vertically. I was thinking that there will probably always be more permissions than roles. I would rather scroll vertically than horizontally. That is how Drupal's permission page works. This shows it enhanced with the https://www.drupal.org/project/instantfilter module for instant permission filtering like the AdminOnSteriods module does in Processwire.
    1 point
  25. https://github.com/processwire/processwire-issues/issues/224
    1 point
  26. Preselect option, currently, only in case when you have option value as null "0", as example your "gridsize" field: Label: "Grid size" -- option value: 0, option text: Default -- option value: 1, option text: Grid size 1 -- option value: 2, option text: Grid size 2 In that case, preselected value in admin backend would be "Default". Later in your code: if ($item->grid_settings->gridsize){ // not default (not preselected value) ... } else { // default ... } But there is and "mix" variant, example, some select field with name background: label: "Background color" -- option value: 0, text: Default -- option value: black, text: Black -- option value: orange, text: Orange * preselected text : "Default" Later in code: <?php // configuration form field "settings" with select subfield "background" $background = $page->settings->background ? '-' . $page->settings->background : ''; ?> <div class="bgn<?php echo $background;?>"> * div can have css class values: bgn, bgn-black, bgn-orange Regards.
    1 point
  27. I just posted a new version of Tracy that may also help a little with this sort of thing: https://processwire.com/talk/topic/12208-tracy-debugger/?do=findComment&amp;comment=173674 by highlighting invisible characters (as well as the non-printable ones in the above screenshot).
    1 point
  28. Just reporting back that for my case this turned out to be very easy using just WireHttp alone and no Oauth client library needed. $http = new WireHttp(); $consumer_key = 'my_key'; $consumer_secret = 'my_secret'; $auth_token = 'my_auth_token'; $auth_token_secret = 'my_auth_token_secret'; $time = time(); $nonce = md5(uniqid(microtime())); // OAuth authorization header $http->setHeader('Authorization', "OAuth oauth_consumer_key=$consumer_key, oauth_token=$auth_token, oauth_version=1.0, oauth_timestamp=$time, oauth_nonce=$nonce, oauth_signature_method=PLAINTEXT, oauth_signature={$consumer_secret}%26{$auth_token_secret}"); // Parameters $params = [ 'member_listing' => '123456', 'rows' => '20', 'photo_size' => 'FullSize', 'return_metadata' => 'false', ]; $params_str = http_build_query($params); // Get JSON response from Trade Me $json = $http->getJSON("https://api.tmsandbox.co.nz/v1/Search/Property/Rental.json?$params_str"); Because of the circumstances of my case I can hardcode $auth_token and $auth_token_secret. But more often with OAuth you would need to get these values in a separate query and store them.
    1 point
  29. I sometimes end up with orphaned files as a result of doing mass imports during development. My code won't be quite right the first time around and I'll end up with extra and/or duplicated files. At least that was the case this last week. It was on a pretty large scale, so not something I wanted to clean up manually. Here's how I cleaned them out. Place this in a file in your site root called clean-files.php and then load it in your browser. /clean-files.php <pre><?php ini_set('max_execution_time', 60*5); // 5 minutes, increase as needed include("./index.php"); $dir = new DirectoryIterator(wire('config')->paths->files); foreach($dir as $file) { if($file->isDot() || !$file->isDir()) continue; $id = $file->getFilename(); if(!ctype_digit("$id")) continue; $page = wire('pages')->get((int) $id); if(!$page->id) { echo "Orphaned directory: " . wire('config')->urls->files . "$id/" . $file->getBasename() . "\n"; continue; } // determine which files are valid for the page $valid = array(); foreach($page->template->fieldgroup as $field) { if($field->type instanceof FieldtypeFile) { foreach($page->get($field->name) as $file) { $valid[] = $file->basename; if($field->type instanceof FieldtypeImage) { foreach($file->getVariations() as $f) { $valid[] = $f->basename; } } } } } // now find all the files present on the page // identify those that are not part of our $valid array $d = new DirectoryIterator($page->filesManager->path); foreach($d as $f) { if($f->isDot() || !$f->isFile()) continue; if(!in_array($f->getFilename(), $valid)) { echo "Orphaned file: " . wire('config')->urls->files . "$id/" . $f->getBasename() . "\n"; // unlink($f->getPathname()); } } wire('pages')->uncache($page); // just in case we need the memory } When you can confirm that it has found the right files (and no false positives) uncomment the "unlink" line above to have it remove the files on the next run.
    1 point
×
×
  • Create New...