Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 03/28/2018 in all areas

  1. 9 points
    Hey guys. Fresh off the oven. We're still polishing a bit, but went live anyway: https://inovtex.com/ Sorry this one is in Portuguese only, so you'll probably need the old google translate for it.
  2. 4 points
    Add the following to the top of /site/templates/admin.php if($user->hasRole('some_role')) { // Replace 'some_role' with the role you want to customise the page list for $wire->addHookAfter('FieldtypePageTitle::wakeupValue', function(HookEvent $event) { $page = $event->arguments(0); // Should be able to match 'Pages' page by ID if($page->id === 3) { // Change 'Pages' to 'Streams' $event->return = 'Streams'; } }); $wire->addHookBefore('ProcessPageList::execute', function(HookEvent $event) { $ppl = $event->object; // Start ProcessPageList from a particular parent page $ppl->id = 1234; // The ID of the 'Streams' page }); } If you are already logged in as this role, log out and then log in again to clear the cached top-level menu.
  3. 4 points
    You can create a separate template for the ajax page (a single page URL, that is called for all ajax requests) and check both to be disabled, prepend and append files in the template settings. Under templates / files: deactivate auto prepend of _main.php
  4. 3 points
    Having built a number of complex projects with tens or hundreds of thousands of pages with ProcessWire, I can say for sure that ProcessWire works very well for all sizes of projects. That being said, it seems to me that your current use case does indeed differ quite a bit from how ProcessWire works right out of the box, and in that case it shouldn't be such a huge surprise that in order to get exactly the result you want, you'll need to modify the system in one way or the other. My point is that it's simply not feasible to add settings for every single use case one might face – and since we're talking about a system such as ProcessWire that already provides a ton of hooks that allow you to modify its behaviour programmatically, there's really no need to do that either. Im not trying to deny that what you've suggested here makes sense, at least in your context, but that's still just one of the million use cases for ProcessWire. Some things to consider: As others have explained above, in ProcessWire "admin pages" are Process modules. Creating a new Process module is surprisingly simple, so rather than customizing the Page tree I'd really suggest that you give them a try and then consider hiding the Page list for roles that don't need to see it. Like LostKobrakai pointed out above, depending on your permission related needs you might be able to get by with one of the third party modules already available – in your case I'd suggest checking out Dynamic Roles and UserGroups. You've mentioned that Page list should be paginated, and it already is. By default pagination is set to display 50 child pages (I think) before paginating the rest. This setting can be tweaked via ProcessPageList module settings. If you have any specific questions, please let us know – we're always happy to help. That being said, if you're going to expect for the system to cater for every possible use case right out of the box, you're definitely going to be disappointed. Just like you'd be with any other CMS, for that matter
  5. 3 points
    You're mixing up routing and $pages->get($path), which are totally unrelated. The Pages class is using the PageFinder to retrieve pages from the database. In no way is that operation concerned with url segments or any routing operations. Url segments are resolved as part of the ProcessPageView module, which is doing the initial matching of request url to an actual page in the database.
  6. 3 points
    Just released an update on GitHub: -Added support for repeaters using the new InputfieldPage::renderReadyHook method (Will fall back to hooking into render if using on an older version of PW) -Specifying processes is no longer required (I'm not sure why I limited the modules use to just specific admin pages before, but there may have been a reason. Let me know if you see any problems with this) I looked into the possibility of making the modal optional, but it's not such a simple task with the way the JS is currently structured. I would like to do some refactoring, but not sure if/when I'll have the time.
  7. 3 points
    Perhaps the following could have helped? Google -> site:processwire.com/blog/ "Link abstraction" Admin > Setup > Fields > Edit Field: body Details (tab) -> Markup/HTML (Content Type) -> HTML Options -> Link abstraction: Update href attributes automatically when internal links change
  8. 3 points
    @Peter Knight this issue is known and fixed in the next version. The cause is that the ProcessModule try to load the log file but the file does not exist (the file is created on the first backup).
  9. 3 points
    Php version issue. Google for the first 5 words of your post and you will see.
  10. 3 points
    I'm afraid I'm not able to understand your scenario any better than the last time you raised it, but I think you might be asking about how to send data from PHP to Javascript. If your Javascript will run in the back-end then you can use the ProcessWire.config object via $config->js(). In your PHP... $config->js('my_data', [ 'noun' => 'dog', 'verb' => 'barking', ]); In your Javascript... alert('The ' + ProcessWire.config.my_data.noun + ' is ' + ProcessWire.config.my_data.verb); If your Javascript will run in the front-end then you can do this in your template file... <?php $my_data = [ 'noun' => 'dog', 'verb' => 'barking', ]; ?> <script> // Create Javascript object var my_data = <?= json_encode($my_data) ?>; </script> ...and later in your Javascript... alert('The ' + my_data.noun + ' is ' + my_data.verb);
  11. 3 points
    Let me know if you need help .
  12. 2 points
    You shouldn't need to create that file - it is part of every core site profile and should already exist. If it doesn't then you must have deleted it at some point, which is likely the cause of the issues you mention. You could try creating a new admin.php based on the file here. The hooks I mentioned have nothing to do with AJAX, and I can't reproduce any problem here. Incidentally, PW does not include any AJAX notifications by default. Maybe you installed the System Notifications module - if so, I don't use that module and I don't know anything about it apart from that it gave me a bunch of problems years ago when I tried it. Off topic, but frankly I think that a module that is clearly beta and labelled "currently in development"... ...has no business being in the PW stable core. It should be in dev branch only, or better yet a module outside the core. That is a method of the base Fieldtype class that all fieldtypes extend.
  13. 2 points
    you can also just return $this->halt() at the end of your ajax template... (similar to exit as @kongondo posted but possibly a tad more elegant ( https://processwire.com/blog/posts/processwire-2.6.8-brings-new-version-of-reno-admin-theme-and-more/#new-this-gt-halt-method-for-use-in-template-files )
  14. 2 points
    You're dismissing the page-tree, which really is the primary tool for getting to visible/editable content in processwire from the start, but then wonder why it's so difficult to add functionality for editing content elsewhere because you just removed most of what was already there. That's a strange conclusion to draw. Setting up custom pages for sections of your page can be done with process modules as you've already gathered. People have been using custom page-trees or custom listers (lister pro if you don't want to get your hands dirty). The best example here is the core itself, where the listing of users is a custom process module, which handles all the additional needs for managing users and it's still just using the basic core lister module beneath. To automate the process of creating any of these as actual pages in the admin tree I'd use something like this: There is no such thing as "permissions for a page" in processwire. Permissions are granted to templates, which is why editing permissions makes most sense in the template edit section.
  15. 2 points
    Maybe you want to clarify a few things here: You're talking about an iframe. What's the page holding the iframe and what the page within the iframe? What's the javascript you're trying to execute and where in the iframe story does it belong?
  16. 2 points
    Maybe deleting everything inside site/assets/cache/ would also do no harm
  17. 2 points
    @ethanbeyer As I mentioned above, I have a custom dashboard process module with links to the areas that members are allowed to view/edit. One is the edit page for their profile at /access/users/edit/?id=xxxx. I then redirect them to the dashboard upon login through a hook so they never see the page tree. $this->addHookBefore('ProcessHome::execute', $this, 'rootPage'); /** * Redirect users with custom role to another page after login */ public function rootPage(HookEvent $event) { if($this->config->ajax) return; // this is needed so that ajax background tasks still work $user = $this->user; if($user->isSuperuser() || !$user->hasRole('member')) return; if($user->hasRole('member')) { $url = $user->statusPageUrl; // custom property added via hook that returns the dashboard URL } $this->session->redirect($url); } I also have a hook that prevents them from viewing the page tree (and other pages, if required). $this->addHookAfter('Page::viewable', $this, 'viewable'); /** * Give only superusers access to certain pages */ public function viewable(HookEvent $event) { if($this->config->ajax) return; // this is needed so that ajax background tasks still work $page = $event->object; if($this->user->isSuperuser() || $page->template != 'admin') return; $denyPages = array(3); // 3=page list if (in_array($page->id, $denyPages)) { $this->session->redirect($this->user->statusPageUrl); } } I then deactivated Breadcrumbs for the member users so they don't see what else would be available. The whole logic sits on top of a custom admin theme which is based on Reno theme. But I think this is not necessary at all. It just made it easier to remove the main navigation and other stuff that I didn't need. With all that in place the members can now only see what they need to. And I can use the dashboard to render some summary information about their profile etc. This was quite some work to setup but in the end it seemed more feasible to go that route rather than trying to change the core profile edit page functionalities. But I still can't see the security benefits that come through the current restrictions in the profile edit page. If that page allows users to change their password why not allow them to change other information? EDIT: Setting up a custom dashboard process module actually isn't that hard and can be fun @bernhard wrote a great tutorial about it.
  18. 2 points
    HI @Jim Bailie. Welcome to ProcessWire and the forums. I don't quite understand the question. ProcessWire does not output anything in the frontend unless you tell it to. Maybe if you could expound a little bit on your question? Otherwise, it's as simple as: if('your condition here') { // do this } else { // do that } As for Ajax..just to elaborate on @elabx's answer if($config->ajax) { // ajax request sent; output ajaxy response stuff and exit; $data = array('foo', 'bar'); header('Content-Type: application/json'); echo json_encode($data); exit;// or use PW halt() if it suits your needs } // echo normal non-ajax stuff
  19. 2 points
    I would adapt the local server to be as much equal as the production server, if possible.
  20. 2 points
    I figured it out, hopefully this might be useful to others as well: // Remove current thumbnail first. $currentThumb = $page->image_thumb->first(); $page->image_thumb->delete($currentThumb); // Get the image we want to copy. $original = $page->image_front; $file = $original->getFile($original); // Clone that image and append it to the image_thumb field. $new = $original->clone($file, array('action' => 'append', 'pagefiles' => $page->image_thumb)); $page->save(); I noticed that this does not work if the filename of the file you are trying to clone ends with -0 (e.g. myfile-0.jpg). I think that is a bug which I'll post to GitHub.
  21. 1 point
    So I decided to wade into module development and created a wrapper module around ImageOptim, a service that compresses and optimizes images in the cloud. ImageOptim currently handles JPG, PNG and GIF files and, depending on the settings you use, shaves off between 15% and 60% in filesize. Great for bandwidth and great for users, especially on mobile. This module handles the part of uploading images to ImageOptim via their official API, downloading the optimized version and storing it alongside the original image. Download & Info GitHub / Module directory / Readme / Usage Why ImageOptim? There are other image optimization services out there, some of them free, that have outstanding ProcessWire modules. A few things make ImageOptim the best tool for most of my customers: It's not free, i.e. it will probably be around for a while and offers support. However, it's cheaper than some of the bigger competitors like Cloudinary. And it does PNG compression better than any of the free services out there, especially those with alpha channels. Installation Install the module like any other ProcessWire module, by either copying the folder into your modules folder or installing it via the admin. See above for downloads links on GitHub and in the module directory. Requirements To be able to upload images to the service, allow_url_fopen must be set on the server. The module will abort installation if that's not the case. I have only tested the module on ProcessWire 3.x installations. I don't see why it shouldn't work in 2.x, if anyone wants to try it out and report back. ImageOptim account To compress images, you first need to sign up for an ImageOptim account. They offer free trials to try the service. Usage (manual optimization) Images can be optimized by calling the optimize() method on any image. You can pass an options array to set ImageOptim API parameters. $image->size(800,600)->optimize()->url $image->optimize(['quality' => 'low', 'dpr' => 2]) // Set quality to low and enable hi-dpi mode Automatic optimization The module also has an automatic mode that optimizes all image variations after resizing. This is the recommended way to use this module since it leaves the original image uncompressed, but optimizes all derivative images. $image->size(800,600)->url // nothing to do here; image is optimized automatically To change compression setting for single images, you can pass an options array along with the standard ImageResizer options. Passing false disables optimization. $image->size(800, 600, ['optimize' => 'medium']) $image->size(800, 600, ['optimize' => ['quality' => 'low', 'dpr' => 2]]) $image->size(800, 600, ['optimize' => false]) For detailed usage instructions and all API parameters, see the usage instructions on GitHub. Filenames Optimized images will be suffixed, e.g. image.jpg becomes image.optim.jpg. You can configure the suffix in the module settings. Roadmap Asynchronous processing. Not really high on the list. Image variations need to be created anyway, so waiting a few seconds longer on first load is preferable to adding complexity to achieve async optimization. Optimize image variations created by other modules. CroppableImage comes to mind. I don't use any of these, so if somebody wants to help out and submit a pull request — all for it! Add a dedicated page in the setup menu with a dashboard and detailed statistics. ImageOptim's API is very barebones for now, so not sure if that's feasible or even necessary. Stability I've been using this module on production sites for some time now, without hiccups. If you do notice oddities, feel free to comment here or investigate and submit PRs.
  22. 1 point
    Hey! We use Processwire in for Blue World Content Section and did some fancy SVG Primitive lazyloading for our images. How do you like it: https://www.blue-tomato.com/blue-world/ We also wrote an article about how we did it: https://dev.to/btdev/hey-user-you-already-see-me11---svg-based-image-lazyloading-as-a-matter-of-enjoyable-ux-1de9
  23. 1 point
    It's true that UI preferences played a part in my not liking the System Notifications module, but I'm sure I struck some problems also. Some forum topics indicate that others have too. Overall it seems like a module that was released partly finished with the intention of being completed (or at least further developed) but that went off the boil and it somehow ended up in the stable core despite its "under development" status.
  24. 1 point
    Aha, that makes sense. For now I'll make a note the field should be entered in uppercase, then I'll use strtoupper() when building my selector. Thanks!
  25. 1 point
    The selectors documentation is focused on PageFinder operations that query the database - $pages->find(), $page->children(), etc. When you use find() on a Repeater field value you are searching a PageArray in memory and the database is not involved, so that is probably the reason for the difference. You could use a different operator like ~= or %= for a case-insensitive search. It would be good if the selectors documentation had more information about the differences between selectors used in PageFinder::find() vs WireArray::find().
  26. 1 point
    Try this in /site/ready.php... $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'your_page_reference_field_name') { $page = $event->arguments('page'); if($page instanceof RepeaterPage) $page = $page->getForPage(); $event->return = $page->variants; } });
  27. 1 point
    I think you're looking for something along these lines: $data = file_get_contents('php://input'); See https://stackoverflow.com/questions/8945879/how-to-get-body-of-a-post-in-php for more details. And no, to my best understanding this is not something that $input API var handles
  28. 1 point
    yep, and if you are doing any custom routing, you can write your own function to get the real page, my theme engine module includes a getVirtualPage() method that can find real pages based on conditions of the segment(s), which templates exist at each segment level, using name matching combined with template; this doesnt help if you are rendering real virtual pages like tag, category or archive filters, or feeds etc. /** * Given an array of expected templates used at each segment index, return the page we are on * @param array $segmentTpls [plain array of template names used for segments] * @return [Page] */ public function getVirtualPage(array $segmentTpls) { $pages = wire('pages'); $sanitizer = wire('sanitizer'); $input = wire('input'); $maxSegs = count($segmentTpls); $segsCount = count($input->urlSegments); if($segsCount > $maxSegs) return false; if($segsCount) { $lastSeg = $input->urlSegments[$segsCount]; $segPlate = $segmentTpls[$segsCount - 1]; $pageName = $sanitizer->pageName($lastSeg); $vPage = $pages->get("template=$segPlate, name=$pageName"); return $vPage; } }
  29. 1 point
    Perhaps you can find some inspiration / ideas from https://github.com/tutsplus/how-to-create-an-ajax-driven-theme-for-processwire
  30. 1 point
    What about serving the data in an endpoint? Like, not actually write it to a file but have a json response in an endpoint and asynchronously request for that and have your scripts just respond to that.
  31. 1 point
    Thanks. I hadn't spotted that module before, or maybe hadn't quite realised what it did. It's exactly what I was looking for.
  32. 1 point
    I'd support @Robin S solution. Generating JS is something I would avoid at all cost if there's a way to have a fixed js just comsume changes from a plain datastructure.
  33. 1 point
    I'm getting the error below The mention of filesize is odd because this site is a 1 page holding page with 4 medium images. Other than that it's the usual 3.0.96 files. This is on a server which I don't have complete control over. Otherwise I'd get you better server info.
  34. 1 point
    I guess I just solved this myself. I needed to use get instead of find in the: $removeParticipant = $eventPage->eventParticipant->find("eventParticipant_deletekey=".$removeKey); Or possibly use the include=hidden. Oh well. It works.
  35. 1 point
    Maybe it's a permission issue in the repeater matrix template used by the repeater matrix field?? Though makes me wonder why it works on Text type because that one uses the same template as the other types.
  36. 1 point
    This message just to let people knowing that Google Invisible ReCaptcha is implemented and can be used in your form by checking the right feature in the module's options without modifying any code line. Now your beautiful formular design won't "break"
  37. 1 point
    hi @flydev I didn't follow the whole thread. Maybe you want to have a look at https://doc.nette.org/en/2.4/finder and https://doc.nette.org/en/2.4/filesystem; Maybe this makes things easier You could also have a look at Soma's online installer: https://raw.githubusercontent.com/somatonic/PWOnlineInstaller/master/grabpw.php (this is in use for a long time and should be tested on all systems).
  38. 1 point
    Hi @Robin S, Thanks for the quick help. I love processwire and did a few sites with it. Need an advanced profile to look on code and learn!
  39. 1 point
    Welcome to the forums @redpanda Community member @dadish kindly released a PW3-compatible version of the Skyscrapers profile here: https://github.com/dadish/pw-skyscrapers-profile
  40. 1 point
    JavaScript, CSS and $this->wire('files')->render('your-file') in Runtime Markup code setting . 'your'file' has the PHP. See video demo below. Works on the fly, no need to save first + shows what's already saved. I do . See video demo. Another option is RM as suggested by @Sergio. See this quick demo. I can post the code later in RM's forum. Picture Options is a Select Options field. Options Illustration is a RuntimeMarkup Field.
  41. 1 point
    @Kiwi Chris Did you try this? https://processwire.com/talk/topic/9857-module-page-field-edit-links/
  42. 1 point
    If that's the exact code, you have an error. It should read "$p->parent->lastcreated", not "$parent->lastcreated". Perhaps that's the whole cause. I'd put the code in a "saved" (or even better "added", since the created property isn't changed after the first save) hook though, so that updating the parent only happens after successfully saving the book page. <?php $pages->addHookAfter('added', function($event) { $p = $event->arguments(0); if($p->template->name == 'book') { $parent = $p->parent; $lastcreated = $parent->lastcreated; if($p->created > $lastcreated) { $parent->lastcreated = $p->created; } // Save just the lastcreated field and leave modified user and time alone $parent->save("lastcreated", ["quiet" => true]); } });
  43. 1 point
    Dear @horst, thanks for the valuable feedback. Indeed you mentioned a very good point. I suspect I had a slightly different than usual understanding of how to remove image variations created by modules. The current implementation uses a glob (/{page folder}/{original file basename}.*) to delete variations. I'll update the module to use the standard naming scheme — this will have its benefits especially in edge cases, e.g. images will then still get removed if the module is uninstalled or deactivated. Also good idea about having a public method removeOptimizedVariations(). That will be very easy to implement with the previous issue.
  44. 1 point
    I've got a dashboard app that uses Hubspot API to pull client info for a given domain name. I can share this with you. Our usage is very vertical but it will give you some sort of a start.
  45. 1 point
    Thanks, I appreciate that. While I can understand being displeased that we are no longer powered by Processwire, I don't think it's reasonable to request that I update this community every time I make a change. It is my job to try out various systems repeatedly and our site has been powered by more than one CMS (pw and wp aside). Do take this nicely but the entire reason for CMS Critic is that we are not accountable to any one CMS and that is how we maintain our integrity. It's been amazing using PW for the period for which we have but we WILL switch it up and we ARE open to change. To name a few, I've run the site on WP, PW, Serendipity and Agility CMS. Also, realize that we have been sure to promote PW heavily and continue to think it's an excellent CMS, regardless of whether we run it on our site. I think realistically, we have and continue to give back in spades. Feel free to ask questions if you wish, I'm always willing to answer.
  46. 1 point
    Just cross-referencing: I've ported the export functionality into a module and class for exporting ProcessWire 2.x sites in a format compatible with importing into ProcessWire 3.x using PagesExport/Import.
  47. 1 point
    I don't share the opinion that the installer ist the best thing possible. There could be more improvements, for example the locale setting that you mentioned. Or displaying the installer in another language. But as ProcessWire is Open Source everyone can submit ideas or fixes. If you don't speak English so well, use an online translator such as https://www.deepl.com/translator, which is the best one I know and submit your ideas to this forum or on https://github.com/processwire/processwire-requests
  48. 1 point
    Concerning this warning about the missing locale: Indeed one should just exactly do, what the warning says - open the given links to the Core Translation Files, look for the "C" and then enter "en_US.UTF-8" for the locale, which should be used for PHP. When you want to change this again later, you will find that under Setup -> Languages -> Language and then the "edit" link in the section "Core Translation Files". If you need German (or any other) as language - you have to add it first in Setup -> Languages using "Add New". Hope I got it all right - because so far I have exactly no experience with ProcessWire at all. This is just what I found out by looking at it (really).
  49. 1 point
    I wanted to store multidimensional data in the config settings of my new AdminActions module and I ended up taking the approach of hooking before saveModuleConfigData so that I could change the content of $event->arguments(1), which is the data array, before it is saved. https://github.com/adrianbj/ProcessAdminActions/blob/b3a82c308377f03c86ae4a2b8fc78e4cdc73b94e/ProcessAdminActions.module#L383-L390 I am not sure if that helps you or not, but thought I'd post just in case. PS - I feel like PW could benefit from a more standard way of storing multidimensional config data.
  50. 1 point
    A couple of ways I have dealt with static file versioning in PW: 1. Use AIOM+ for your CSS and JS files. AIOM+ is sensitive to what is contained in your files though - I got an error when my CSS contained a background image path to a PHP script (for generating translucent PNGs for older browsers that don't support rgba colours). 2. A function that renames static files according to the last modified time (adapted from this article). Include somewhere before your template head is generated... function autoVer($url){ $name = explode('.', $url); $lastext = array_pop($name); array_push($name, filemtime($_SERVER['DOCUMENT_ROOT'].$url), $lastext); $fullname = implode('.', $name); echo $fullname; } Use as follows for your CSS and JS... <link rel="stylesheet" href="<?php autoVer('/site/templates/css/mystyles.css'); ?>"> <script src="<?php autoVer('/site/templates/js/myscript.js'); ?>"></script> Add to your .htaccess, after "RewriteEngine on"... # Versioned static files RewriteCond %{REQUEST_FILENAME} !-s RewriteRule ^(.*)\.[\d]+\.(css|js)$ $1.$2 [L]
×
×
  • Create New...