Leaderboard
Popular Content
Showing content with the highest reputation on 06/08/2016 in all areas
-
Ok, slightly out of context, because it's Javascript, but these 3 videos from funfunfunction could really help you to understand those 3 functions: It's a series, watch them in sequence4 points
-
I'm mainly thinking about the way ProcessWire makes it possible for third party modules to alter the source of a page, inject their own scripts or styles, etc. While this does require a lot of trust in installed modules, it's also something we wouldn't want to disallow. Inputfields are another thing consider: many third party inputfields rely on existing libraries, in which case the implementation details are more or less out of our hands. Unless I'm missing something obvious, CSP would mostly be useful if users were able to inject their own scripts or styles for other users to see. In order to do that, you'd either have to be a superuser and use some rather specific features to achieve this, or exploit a third party module that allows this. Latter option is absolutely something to consider, but the first one not that much: generally speaking we consider users with access to the admin interface "trusted"... and superusers even more so. While we could introduce a method of "registering" embedded content with the system, I'm not entirely sure if that's worth it. It could make the lives of perfectly legitimate developers more difficult, while the benefits are — in my opinion — somewhat questionable. It's also good to keep in mind that this isn't something that would protect you from malicious / hacked third party modules: a module could simply hook into an earlier (or later) point in program execution and override any CSP rules you've got in place. That being said, I'm not against the idea of implementing this as a configurable option. It would no doubt be possible for ProcessWire to generate nonces for any inline content it requires, and as long as this would be a configurable setting, it shouldn't come as much of a surprise if some third party features stopped working afterwards. I don't see this as such a big thing and I'd imagine the potential use cases to be limited, I for one would be OK with this as long as it doesn't needlessly complicate things ?3 points
-
Inline scripts are used widely in the admin interface, so this sounds like a case where you wouldn't want to enable CSP. It's fine to enable it on your front-end if it's something you want, or you could use the unsafe-inline keyword to get past this issue, though. CSP is well-intentioned, but some of it's rules don't make that much sense in certain use cases, and our admin interface is in my opinion one of those cases. On the other hand ProcessWire doesn't dictate any of the markup you see on the front-end of your site Note: this topic has been moved to the security forum.3 points
-
I am a bit lost here and am probably way off. To test things, I have installed my Blog module but did not do any manual save after that. My default settings are saved without doing any manual save...this is because I have this line in ProcessBlog...___install() $this->wire('modules')->saveModuleConfigData($this, self::configDefaults()); ...unless of course that is what you guys mean by manual save? I can immediately access the settings...e.g. did this in basic-page $settings = $modules->getModuleConfigData('ProcessBlog'); Edit: forgot to add...I still use the old way of setting module config + PW 2.7.33 points
-
v016 was uploaded today to GitHub: enable setting template latte file with/without extension ($view->viewFile = 'basic-page' and $view->viewFile = 'basic-page.latte') $view->json_encode returns JSON encoded string/markup. Possible values are true and PHP's json_encode options (eg. JSON_PRETTY_PRINT). if "viewFile" begins with "//", $config->paths->templates and viewDir is not prepended to the view path These updates make it easier to get Ajax results, and allow placing latte files outside templates/views directory. The latter was also possible earlier using relative paths ("../"), but now it's more flexible. Getting json output was only possible using wireRenderFile() and applying json_encode() manually, which was less convenient.2 points
-
Hi Peter - I am using it here on PW3 and it's working just fine. Are you having any specific problems with it?2 points
-
I hope Ryan plans to add such features to the panels you requested. I guess some features could be implemented easily, like auto width, position next to content, etc. I'll see.2 points
-
I can really recommend http://adamwathan.me/refactoring-to-collections/ if you're curious (has a free sample as well). Brought a lot of light into all those functions and their usefulness.2 points
-
$byColor = array_reduce($children->getArray(), function($carry, $child){ $carry[$child->color][] = $child; return $carry; }, array()); $toTextBlocks = array_map(function($color, $children){ $childrenPA = (new PageArray)->import($children); return "$color (" . $childrenPA->implode(", ", "title") . ")"; }, array_keys($byColor), $byColor); $line = implode(", ", $toTextBlocks);2 points
-
Hi! Just finished my first module This module adds a new "Google-Analytics" Page in your Admin-Panel and displays various Statistics from a Google Analytics Account. It uses the JQuery plugin "jqplot" to display the charts. Github: https://github.com/w...GoogleAnalytics Modules directory: http://modules.proce...ogle-analytics/ Features Visits by Date (Chart) General Statistics about Visits (Total visits, Visit duration, New visitors, Returning visitors etc.) Demographics: Countries, Cities, Languages System: Browsers, Operating Systems, Screen Resolutions Mobile: Operating Systems, Screen Resolutions Pageviews by Date (Chart) Top Content Traffic Sources: Keywords, Referral Traffic by Domain and URI Choose a default date range displaying statistics: last 24 hours, 2 days, 1 week, 1 month etc. Custom date range by setting a "start date" and "end date" Requirements Google Account and Analytics Account A Project in the Google APIs Console cURL Installation 1) Create a Project in the Google APIs Console: Create a new Project in the APIs Console: code.google.com/apis/console/ Under Services, enable the Analytics API Under API Access: create an Oauth 2.0 Client-ID Give a Product Name, choose "Web-Application", Domain doesn't matter Enter a Redirect URI to the GA-Page in your Processwire Installation: http://yourdomain.com/processwire/google-analytics/ Notes: The redirect URI must exactly match with the URL from the new "Google Analytics" page in Processwire. Open the Page and copy the URL from the address-bar (localhost does work too!) The project created in the APIs Console can be reused for every Processwire installation using this module. You just have to enter more redirect URIs 2) Install the module: Place the module's files in /site/modules/ProcessGoogleAnalytics Install the Module via the Admin-Panel Enter Client-ID and Client-Secret keys from the created project in the module config Load the newly created page "Google-Analytics" and click on the button "authenticate" Grant the module access to the Analytics Data Choose a Google Analytics account (Domain) from the dropdown Done: You should see the statistics. Check out the module config options for further customization In order to let other users see the Google Analytics page, you must give their role access to the "ga-view" permission. Ps. Processwire is awesome and so is this community!1 point
-
GitHub: https://github.com/Toutouwai/TemplatesChildPages For any page, allows the restricting of templates that may be used for child pages. Usage Install the TemplatesChildPages module. The module adds an AsmSelect inputfield "Template restrictions for children" on the Children tab of Page Edit. Use the inputfield to select from existing templates and any child pages added subsequently will be limited to those selected templates. Note that any template restrictions added via this module are in addition to any "Family" restrictions set for the child and parent templates. In other words, if template Family restrictions prevent a template being selected for a given page you can't override this simply by including the template in the parent's "Template restrictions for children" field. Why use this module? The module allows you to add child page template restrictions without having to create new or duplicate templates for the parent page. This forum post explains the situation well. Similarly, it makes it possible to use the "Add New" page feature without an unnecessary proliferation of templates. If you specify a single template as restriction for child pages you can add a Page Add Bookmark for that parent page that allows site editors to easily add a new page using the right template for the location.1 point
-
Hola amigos I wrote a little DOMDocument magic (long time ago) which would automatically link images add classes for Magnific Popup set alt tag wrap the whole thing in a figure insert figcaption if image description available and wrap multiple figures in a container think that's it.. So for our articles we only needed to open pwimage popup in cke, choose desired image, set the size and alignment To caption images we use description input from image field It was a nice starting point, and at some point I changed DOMDocument to SmartDOMDocument wrapped the code into TextformatterBlogImages.module.. But I had ideas to simplify the whole process..and due to a problem with the old implementation which broke design (just realised it a week ago, or that it's linked to my Textformatter) I finally took the time and rewrote the whole thing. Problem was that figure is not a valid child of <p> so at least in chrome I ended up with orphaned text and an empty paragraph so the text style differed from the rest.. I'm posting this as a boilerplate/resource/idea, it's really basic..everything is hardcoded and it's not flexible right now.. So there is the Textformatter module and a hook which is placed in my /site/ready.php right now but might be moved somewhere else.. Maybe it can become a proper module..Maybe I find time to do so..but if someone is interested everyone is welcome to grab the code and extend/modify for their own needs Here's a little animated gif screencast (it's shrinked so the quality is not very beautiful..) So what it does right now: TextformatterBlogImages.module: first it replaces double line breaks like <br><br> or <br /><br /> or any other combination with </p><p> (I had such occurences) parses the article for <p> tags using simple_html_dom finds all containing images it extracts the image name stripping image variations gets the corresponding pageimage from images field the image itself will be replaced by markup used with LazySizes JS plugin (https://github.com/aFarkas/lazysizes) Example: <img src="fullImageUrl" srcset="data:image/png;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" data-srcset="smallUrl smallWidth, medium mediumWidth, full fullWidth" data-sizes="auto" width="fullImageWidth"> data-sizes="auto" works for now but I might replace it by normal sizes markup, manually deciding how images should be chosen width="fullWidth" I read that images with width attribute render faster but I'm not sure if this is true even if the image is downsized by css? then the new image will be linked to full size image link with markup for js modal (wrote my own, but not ready yet) if image class contains "align_left" or "align_right" it will wrap it in span moving classes from img to span if pageimage got a description it'll insert the descr below the img within span in another span the old image will just be replaced by the new span image so it will be in the same place it image is not aligned (or align_center) it wraps the image in figure moving img classes to figure and description will be wrapped in figcaption and the figure will be stuffed in an own container before the paragraph (original image within p will be removed) The figure gets a class landscape or portrait according to the aspect ratio Uh, I added another hook property called Pageimage::cdn so the images will be served directly from assets subdomain (using domain sharding option from AIOM but saving the extra redirect) Then there is another "round" reparsing the article for newly created figure containers adding additional class containing the number of children and another class indicating how many of the images are landscape/portrait for later styling like 2lx1p for 2 landscape and 1 portrait We add rows of 1 to 4 images, not more so my stylesheet contains rules for all possible cases like 1 landscape 2 portraits, 3 landscapes 1 portrait and so on to resize the images so alls images in a row will have the same height and the row will be always as wide as the main container as seen in the gif above Because the textformatter is doing everything for us I added a little clickable area to each image in the image field and a little javascript which inserts an image into body cke field on click at caret position Only thing to do is manually break the line after 4 images (or less) (NOTE: This javascript code inserting the clickable area requires at least PW 3.0.17 with new image field, as mentioned by Robin S below) For inline images I have to modify, I guess, the javascript a little, or maybe I can add another script which adds 3 links to inserted images, which add alignment classes to the image Here you'll find the files (and code snippes) https://gist.github.com/CanRau/662a559a07d6d7c492159d1cd497944f Any questions, ideas, improvements, concerns and other comments are highly appreciated PS: I'm not using it in production yet, just finished the version, I think I need to review all articles first to ensure proper migration, and maybe I add the inline handling to the javascript as mentioned before PPS: If you're interested in using this you should at least cache the textformatter output using WireCache, or TemplateCache or you can of course use ProCache, but I wouldn't recommend using it without any caching mechanism as it would re-do all the work every time someone requests the page.. Un Saludo Can1 point
-
Ok, the latest version comes with the new Console panel that I introduced a few posts back. Here are the key points/features on this panel: Has full access to all PW variables: $pages, $page, $user, etc Works really nicely with fl() calls, but you can also make use of d(), l(), or even simply echo() All output is generated via ajax, and so is virtually instant No need for editing a template file and reloading the page in browser - simply type your code in the console panel for an instant result Only available to superusers Caches code in the filesystem so it stored between page reloads, navigation to other pages, and even browser restarts Note that for those of you upgrading you will need to install the new Process Tracy Console module that is now included. For new installs, this will be installed automatically with the main module. Remember that this allows you to run any PHP code, so be careful! Please let me know what you think. Here are some example calls and their results:1 point
-
I found the problem, when i add a <base> tag inside <head> tag, this problem appear.1 point
-
For the simple minded this would be the foreach version that does the same. $colors = array(); $childrenByColor = array(); foreach($children as $child) $colors[$child->color][] = $child; foreach($colors as $color => $items) { $childrenByColor[] = "$color (" . $items->implode(",", "title") . ")"; } $line = implode(", ", $childrenByColor);1 point
-
In addition to the core cropping functionality, there are two third party cropping modules: http://modules.processwire.com/modules/croppable-image/ http://modules.processwire.com/modules/fieldtype-crop-image/ Neither of these work properly in PW3. The one you are using is tagged as compatible up to PW 2.4 only. The other one has a dev branch (https://github.com/horst-n/CroppableImage/tree/PW3) that works for 3.0.17 only. You should have a read of these threads: https://processwire.com/talk/topic/13215-pw-3017-major-upgrades-to-images-field/ https://processwire.com/talk/topic/13279-pw-3018-yet-more-images-field-upgrades/ Not everything is relevant, but there is a lot of discussion about further enhancements to cropping in the core to allow for predefined crop ratios etc. I think if you are wanting PW3, then unfortunately you will need to be satisfied with the core cropping for the time being.1 point
-
+1 working fine on 3.x. I use this on all my websites for a long time.1 point
-
Make sure $child->prod_fiber_type is a string and not an object (page field?).1 point
-
You don't need anything like this. Just make sure that your php files are really stored in utf-8 encoding!! (PHP files you need to check in this reagrd are: the calling template file(s), the WireMailSMTP module files and the base WireMail files) Normally they all should be in utf-8 encoding, but better you check this thouroughly. Then it works with simply using: $subject = 'Ö Ä Ü ö ä ü ß'; I tested this just yet. The source of the received email looks like: Subject: Wiremail-SMTP Test 15:57:23 =?UTF-8?q?=C3=A4=C3=B6=C3=BC_=C3=84=C3=96=C3=9C_=C3=9F?= X-Mailer: ProcessWire/WireMailSmtp Date: Wed, 8 Jun 2016 13:57:25 GMT +00:00 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable It does automated encoding, but you don't have to do anything by yourself.1 point
-
What Adrian said If the question is whether I plan to release a separate 3.x version with namespace declarations in place, I honestly haven't even thought about that yet. On the other hand I do intend to support both 2.x and 3.x for the time being, so if this module isn't playing nicely together with the compilation feature of 3.x, please let me know.1 point
-
Just tested this and it solves the issue completely. I just set it to work on 'Event' templates and use /{$page->id}/ for the id format and it does the trick. Thanks so much Adrian.1 point
-
There is nothing like that in ProcessWire's backend. Almost everything is stored in pages and if you need such a section just create a template and a (hidden) page (e.g. named settings) and use it. Another option is to extend the $config variable (site/config.php) with custom properties. There's also a module, which allows you to change those properties in the backend, but it's not as flexible in terms of UI as a page with custom fields would be.1 point
-
Thanks kongondo, saveModuleConfigData works fine. I guess @horst did a typo writing setModuleConfigData. Maybe he wrote the whole stuff by head?1 point
-
This should be saveModuleConfigData() not setModuleConfigData() - thanks kongondo Yes, that's what we mean. Or clicking "Save" on the module config screen. Most modules that I have looked at don't do saveModuleConfigData() on install. Random example: TextformatterVideoEmbed This doesn't work - getDefaults() is a method of the ModuleConfig class, or MyModuleConfig class which extends ModuleConfig. It's not a method in the module class.1 point
-
I'm afraid I don't really know what you are trying to change - by the ""Page tree" menu item is marked as active/current", do you mean the breadcrumb trail? Perhaps a screenshot may help us understand your goal a bit better.1 point
-
Take a look at: http://modules.processwire.com/modules/process-redirect-ids/ It may work as is for your needs, or you can take a look at the approach used as it also hooks into ProcessPageView::pageNotFound1 point
-
Thanks! Glad to hear you can make use of it. Just tried the ctrl-s combo and I got it working. Here is a snippet I have atm if you can't wait: $(document).ready(function () { var saveButton = $('#submit_save'); CKEDITOR.on('instanceReady', function (evt) { var editor = evt.editor; editor.document.on('keydown', function (e) { if (e.data.getKeystroke() == CKEDITOR.CTRL + 83) { e.data.$.preventDefault(); saveButton.trigger('click'); return false; } }); }); });1 point
-
Filtering for filenames with images will / is be one of the most used functions of all for me. If you have done the images your self and use a naming convention, this is the fasted way to find specific images / images groups out of hundreds. Also, with an own naming convention, (and knowing the images), you don't need to tag the images. Thanks @tpr!1 point
-
v016 is uploaded to GitHub, containing the datalist feature for filterbox + a display bug fix reported by matjazp.1 point
-
seems the init state does not show the lines/words counter - this is a documented issue with the plugin, see https://simplemde.com/ you can force it to update on load by enabling autosave; (adding these to the init call) autosave: { enabled: true, uniqueId: thisID, delay: 1000, }, spellChecker: false the plan is to make each instance individually configurable, but for now this is a very bare-bones implementation. i'm going to add those options to the js init, but maybe leave them commented out, and let users uncomment to disable spellcheck, and enable autosave; BTW - the autosave is interesting and works, not sure how useful it is or even if it makes sense in the context of a CMS. if it were to be enabled, additional configuration would be required to change the way it works so as to have a unique id for the page and the field though.1 point
-
1 point
-
Hey guys! Sorry, I'm not giving great attention to the module lately and I'm tight with time right now. @evan, your pull request seems reasonable, so I will accept it as is. Don't worry about the fix not being the most elegant. The module is naturally hacky in it's own nature already1 point
-
Well, for filtering items E.g if you have many images or documents uploaded and you would like to find a specific one. Or if you go to the Language Translator, there can be many translation files and it can be hard finding the one you need without filtering.1 point
-
1 point
-
$pageArray = $page->your_field; $total = $pageArray->count(); $limit = 20; $pageNum = $input->pageNum - 1; // make it zero based for calculation $start = $pageNum * $limit; $paginatablePageArray = $pageArray->setStart($start)->setLimit($limit)->setTotal($total); This way you'll get a PageArray, which will work like any $pages->find() one in terms of pagination.1 point
-
Here is a little trick how a user the user template to manage things like a /profile/ page to frontend edit a users profile and this could be easy used for a own register logic and let the new user fill in all needed fields....the logic could be implemented via URL segments: //load module $fh = $modules->get('FormHelper'); // Template based form, skip fields 'title' and other adminfields, unstyled $form = $fh->create($templates->get('user'), array( 'notifications', 'admin_theme', 'language', 'roles', 'user_email', //this is where we fill a created token/hash to register the user and verifie via emaillink... 'confirm' //confirm link for an admin to set user created stuff puplic )); and in your template you could use URL segements for very simple or complex logic on registration - in my case i need to register a user but hide his content until an admin activated the user...email from the user itself should have to be validated, too so i've to build my own code here...since i wanna stick to just email + password and let the username created automatical in the background...this is just the basic for such a template nothing fancy here - maybe i wrote a little topic if it is running stable. Pseudocode for a template file register.php and URL's like: http://mysite.com/app/regsiter/URLsegment1/UserID/Hash http://mysite.com/app/register/activate/1235/fb5a44cfc2ecd8b5667a667319b66688 http://mysite.com/app/register/confirm/1235/d41d8cd98f00b204e9800998ecf8427e // we are using 3 URL segment, so send a 404 if there's more than 1 if($input->urlSegment4) throw new Wire404Exception(); switch ($input->urlSegment1){ case '': // segment 1 is empty so display normal content/register form // users could submit the register form and a new user is created two tokens are generated // email to the user and to admin // user is logged in and can add content - but the content will only published if // his two tokens are created on the first step to validate his email and confirm by an admin break; case 'activate': if ($input->urlSegment2){ // check for the user id if ($input->urlSegment3 == user_email) // check for the email token // user has get an email on submit the register form with a token link // and he hit this link so publish/activate the user and show him a message // delete user_email token break; case 'confirm': if ($input->urlSegment2){ // check for the user id if ($input->urlSegment2 == confirm){ // the user is confirmed by an admin and his content is published, delete confirm token break; default: // Anything else? Throw a 404 throw new Wire404Exception(); } This is just a example to how to rebuild the functions of the EmailValidation module in a flexible way with URL segments and some additional fields on the user template....AND the awesome form module from pwFoo... URL segments could setup with an regex in the template settings like this: regex:^[0-9]*$ //regex for user id regex:^[a-f0-9]{32}$ //reges for a hash/token If my project is finished i will provide more and detailed examples with templates and FormHelper! Best regards mr-fan1 point
-
@macrura and @horst, thank you! Although it is not necessary to use both your suggestions, I have. To satiate my curiosity. @Jan Romero, you are correct. When it comes to php I am a bit of a bush mechanic. I am learning in a traditional Australian way. Thank you again to all of you. One of the things I enjoy most about PW is the supportive and encouraging community.1 point
-
Here are some of my findings in case anyone need it: // hook to before page add render and prevent execution if necessary $this->addHookBefore('ProcessPageAdd::execute', $this, 'hookUserAdd'); // hide add button in the backend menu $this->addHookAfter('ProcessUser::executeNavJSON', $this, 'hideUserMenu'); public function hideUserMenu($event) { //we don't want to modify links for super user if ($this->user->isSuperuser()) return; //ajax only if($this->config->ajax){ $options = json_decode($event->return, true); unset($options['add']); foreach ($options['list'] as $key => $value) { //check and unset if necessary } $event->return = json_encode($options); } } public function hookUserAdd($event) { if (!$this->user->isSuperuser()) { $event->replace = true; $this->error('You do not have permission'); return; } } That is because I still want "staff" role to use page-lister permission. Hooking to ProcessPageLister is much harder and require regex to hide the "Add new" buttons. Also, to modify the result returned from the selector, you can add hook to getSelector function (this is undocumented in Captain Hook) $this->addHookAfter('ProcessPageLister::getSelector', $this, 'hookPageListerSelector'); For better security, add hook to Pages::save (similar to ProcessPageAdd) to deny saving new user.1 point
-
1 point
-
1 point
-
Install db session module and you'll have a setup page with users. (not installed in core)1 point