Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/27/2016 in all areas

  1. @louisstephens: so you followed these instructions: http://processwire-recipes.com/recipes/create-custom-admin-settings-page-link-in-admin-menu/ right? In _init.php (delayed output method) I just do this: $settings = $pages->get("/settings/"); and later on, access settings like this: <h1><?= $settings->site_title ?></h1> Sure, we can use the ID of the page too, but it is easier to remember a string, which can be the same in different projects, while IDs might differ.
    4 points
  2. Alan, have you had a look at sendy?
    3 points
  3. I'm doing it almost like szabesz explained, but using $config->opt = $pages->get(xyz); so i have it also available in included template files via wireRenderFile(xyz) then you can do $config->opt->yourfield everywhere
    3 points
  4. @eutervogel: $pages->get() always returns the first page, if any or multiple are found. But, unlike the $pages->find() method, it assumes that you, when using ->get(), you definetly want get this page and it has disabled access checking and uses include=all. To understand what include=all and no access checking means, please try the following code to compare: $page_exsists = $pages->find("title=$searchtitle")->first(); This will give you only pages that are not hidden and not locked and that are also be accessible, (no admin (sub)pages like repeater items). But both, ->get() and find()->first(), will give you back a page object that has an ID! (find gives back a PageArray, = multiple page objects). And in cases where no matching page can be found, it contains a NullPage. NullPages ever have an ID of 0 (zero). So, if you want store a boolean, you can do it like this $page_exsists = $pages->find("title=$searchtitle")->first()->id > 0; But you also can check for NullPage, or if count() of the pageArray is greater than 0, or if it matches exactly 1, or if it contains multiple pages. Hope this helps a bit.
    2 points
  5. Can't believe it's almost 2 years. Unfortunately in between 'life' happened .
    2 points
  6. Just tried and works as advertised, thanks!
    2 points
  7. Hey @tpr - sorry about that - please try the latest version.
    2 points
  8. Hi ottogal, Sorry for my late response. I currently don't have time to update Batcher, at least not for the next month. The module needs a rewrite because a lot changed since this was released, for example: Native support of ProcessWire's modal Make use of InputfieldSelector to build the selector strings ... I hope to update the module at the end of may, but since I don't know the release date of Pw 3 I can't promise... unless someone else takes over. Cheers
    2 points
  9. It's not really designed to be used in a template through the API, the use case was to make re-using images and documents in CKEditor less complicated. Behind the scene, MediaLibraries are nothing but pages with a MediaImages and MediaFiles field, the magic is the concise overview over dedicated media pages (and their creation without navigating through the page tree) and, most importantly, the quick selection in the CKEditor dialogs. You can get the available libraries for a page through the API though: /* Retrieve all available MediaLibraries for the current page */ // get possible parents first $mparents = $page->parents->and($page); // get PageArray with all possible libraries $libs = $pages->find("template=MediaLibrary, parent=$mparents"); // do something with libraries foreach($libs as $lib) { echo $lib->title . PHP_EOL; // Every library is just a page with the fields MediaImages and MediaFiles foreach($lib->MediaImages as $img) { echo "<img src='$img->url'/><br/>" . PHP_EOL; } } Of course, you can fetch a specific library through regular selector syntax too, e.g.: $lib = $pages->get("template=MediaLibrary, name=global-media"); foreach($lib->MediaFiles as $file) { // ... }
    2 points
  10. This does work: $tmpls = $templates->find("tags=myTag"); $result = $pages->find(template=$tmpls");
    2 points
  11. Is there a workaround to making it compatible with PW 3.0.15?
    2 points
  12. In fact the page is already created in the 'middle of the process' and it has to be created to pull the page name from other page fields. If you don't like this. Create a cronjob like bernhard mentioned. Example: $wire->addHook('LazyCron::everyDay', function() { // trash untitled pages $delay = time()-60; $untitleds = wire('pages')->find("created<$delay,name^=untitled,include=all"); foreach ($untitleds as $untitled) $untitled->trash(); // to delete permanently use $untitled->delete() instead }); In this case you don't need this module. Use built in 'Name Format Children' in parent template settings and create the name frome date. It is also possible in my module to create the name from any autogenerated page property like 'created' or 'id'. Read the note in 'Name Format Children' field if module is installed. This message is needed. How could the page editor know from where the values are pulled to generate the pagename? I don't want to change this.
    2 points
  13. Well I decided that it could be an issue is several scenarios, so I have added some new options. You can now return false from the custom php code option which will result in the user having no access to any pages in the tree. There is also a new config settings option for determining whether non-matching users see the entire page tree (current scenario and the new default) or they have no access. This setting works with all three matching options. Check it out and let me know what you think. I have also included the temp hack fix for the page doubling issue in PW 3.0.8+ (https://github.com/ryancramerdesign/ProcessWire/issues/1774). Hopefully this is something that Ryan will fix in the core shortly and I can remove the hack. The side-effect is that the new smarter page tree (that remembers what was open) doesn't work, but if you are using the functionality of this module, then likely the page tree that the user is seeing is quite simple anyway - I think a decent compromise for the moment.
    2 points
  14. Not sure if this helps, but for custom buttons i have recently made large usage of Kongondo's Runtime Markup field to create custom buttons and many other custom things (special information, tables of other pages, etc) to use on the page edit screen.
    2 points
  15. Here you can see the basics to implement additional buttons: https://processwire.com/talk/topic/12174-module-to-add-2-additional-save-buttons-and-unpublish-button-to-page-edit/
    2 points
  16. To complete Adrians answer, the ProcessForgotPassword.module tries to determine the 'from' Email address in 3 steps (fallback) from the Modules settings, like Adrian described from config.php $config->adminEmail = info@example.org; construction of an Email address based on $config->httpHost like: $from = 'processwire@' . $config->httpHost; This happend in your example.
    2 points
  17. Just wanted to share what I recently used to create forms in modules and in frontend using the API and Inputfield modules PW provides and uses on its own. I think many newcomers or also advanced user aren't aware what is already possible in templates with some simple and flexible code. Learning this can greatly help in any aspect when you develop with PW. It's not as easy and powerful as FormBuilder but a great example of what can be archieved within PW. Really? Tell me more The output markup generated with something like echo $form->render(); will be a like the one you get with FormBuilder or admin forms in backend. It's what PW is made of. Now since 2.2.5~ somewhere, the "required" option is possible for all fields (previous not) and that makes it easier a lot for validation and also it renders inline errors already nicely (due to Ryan FormBuilder yah!). For example the Password inputfield already provides two field to confirm the password and will validate it. De- and encryption method also exists. Or you can also use columns width setting for a field, which was added not so long ago. Some fields like Asm MultiSelect would require to also include their css and js to work but haven't tried. Also file uploads isn't there, but maybe at some point there will be more options. It would be still possible to code your own uploader when the form is submitted. Validation? If you understand a little more how PW works with forms and inputfields you can simply add you own validation, do hooks and lots of magic with very easy code to read and maintain. You can also use the processInput($input->post) method of a form that PW uses itself to validate a form. So getting to see if there was any errors is simply checking for $form->getErrors();. Also the $form->processInput($input->post) will prevent CSRF attacks and the form will append a hidden field automaticly. It's also worth noting that processInput() will work also with an array (key=>value) of data it doesn't have to be the one from $input->post. Styling? It works well if you take your own CSS or just pick the inputfields.css from the templates-admin folder as a start. Also the CSS file from the wire/modules/InputfieldRadios module can be helpful to add. And that's it. It's not very hard to get it display nicely. Here an code example of a simple form. <?php $out = ''; // create a new form field (also field wrapper) $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'subscribe-form'); // create a text input $field = $modules->get("InputfieldText"); $field->label = "Name"; $field->attr('id+name','name'); $field->required = 1; $form->append($field); // append the field to the form // create email field $field = $modules->get("InputfieldEmail"); $field->label = "E-Mail"; $field->attr('id+name','email'); $field->required = 1; $form->append($field); // append the field // you get the idea $field = $modules->get("InputfieldPassword"); $field->label = "Passwort"; $field->attr("id+name","pass"); $field->required = 1; $form->append($field); // oh a submit button! $submit = $modules->get("InputfieldSubmit"); $submit->attr("value","Subscribe"); $submit->attr("id+name","submit"); $form->append($submit); // form was submitted so we process the form if($input->post->submit) { // user submitted the form, process it and check for errors $form->processInput($input->post); // here is a good point for extra/custom validation and manipulate fields $email = $form->get("email"); if($email && (strpos($email->value,'@hotmail') !== FALSE)){ // attach an error to the field // and it will get displayed along the field $email->error("Sorry we don't accept hotmail addresses for now."); } if($form->getErrors()) { // the form is processed and populated // but contains errors $out .= $form->render(); } else { // do with the form what you like, create and save it as page // or send emails. to get the values you can use // $email = $form->get("email")->value; // $name = $form->get("name")->value; // $pass = $form->get("pass")->value; // // to sanitize input // $name = $sanitizer->text($input->post->name); // $email = $sanitizer->email($form->get("email")->value); $out .= "<p>Thanks! Your submission was successful."; } } else { // render out form without processing $out .= $form->render(); } include("./head.inc"); echo $out; include("./foot.inc"); Here the code snippet as gist github: https://gist.github.com/4027908 Maybe there's something I'm not aware of yet, so if there something to still care about just let me know. Maybe some example of hooks could be appended here too. Thanks Edit March 2017: This code still works in PW2.8 and PW3.
    1 point
  18. Hi, I would be interested in this work of yours, too...
    1 point
  19. Hi @pmichaelis, Glad you like the module. Have a look at the current_class_level. That in conjunction with current_class should probably do the trick (the 'active' bit).
    1 point
  20. I had the same issue just now on PW 2.7.2 - resolved after taking away a field from the erroring template. (field was dependent on a page that no longer existed)
    1 point
  21. Hi, the get selector give me troubles before too. The best way to use it is with an ID as selector value: $pages->get(1234); Reading the doc's I found this: Note that $pages->get("..."); is not subject to this behavior (or access control) and "include=all" is assumed. Repeater's are actually pages that exists under the Admin menu. So a get filtered by title will return this pages too. If you need only one page use a findOne or a find with more filter's parameter's. Hope that this help's you.
    1 point
  22. New Page View Options (Modal, Panel) in 3.0.15 makes edit button obsolete http://processwire.com/blog/posts/pw-3.0.15/
    1 point
  23. Thanks, I will try a combination of fields then & try lazycron. Sometimes the editors shouldn't care about the page name, for example when pages are created to hold content for content blocks. For example awards pages that won't have its own page at all.
    1 point
  24. @Günter, Why not use one of the other examples of recursive menu methods in the forums?
    1 point
  25. Hi Günter, Whether PHP, ProcessWire or English: just keep add it and you'll improve, no doubt.
    1 point
  26. I wrote to them (even though I knew it would make no difference) in order to note that for my use-case [send very few emails per month] the new price model was completely inappropriate; I used about 2% of the potential emails I had to pay for per month; 98% of my fee being effectively unused. The next month wash and repeat. I went from being a fan to a lost (low spend) client. VERY happy with http://postmarkapp.com/.
    1 point
  27. Ryan solved this in pagetable as that pages created but not published are deleted automatically each day by a kind of lazycron. On mobile and no details for that... Just throwing in an idea
    1 point
  28. Great module but there's one thing that prevents me form using it, maybe this could be added in the future: When adding a page and in the middle of the process you decide not to add a new page (skipping the Publish button and navigate away), then an empty page will be created. I think this coul be solved by adding a "Cancel" button next to the existing buttons ("Publish", "Save and....", "Cancel"). But perhaps there is an easier fix. Don't get me wrong - I can delete the pages of course but I would use this module to make it easier for clients to add new pages, especially where the page name is actually irrelevant. As a bonus feature request I would love to see message like these appear only for superusers - these may be too much for a regular client: "SetupPageName expects value in field 'title' to autogenerate Pagename"
    1 point
  29. Lister Pro is purchased!
    1 point
  30. Building menus for any usage has been discussed a lot over the years. Here's one post: https://processwire.com/talk/topic/2787-custom-menu-not-related-to-page-tree/#entry27275 In the end, i have found that having a branch on the page tree for the menu is the most flexible and easiest to: - code custom navs from (mega menus, boostrap etc) - publish/unpublish menu items - use permissions for menu items (e.g. show some menu items to logged in users) - insert stuff like forms, videos etc into a menu and it works very well with MSN (markup simple navigation) because it allows you to set the parent...
    1 point
  31. I don't think this would be easy unless using the menu builder module. I also don't think that it is a good idea to build your site structure like this. Have you thought of deviding your tree in one branch "menu" and one branch "helpers" or "options" or "data"? Maybe this would make things easier. You can than rewrite the URLs from example.com/menu/page1 to example.com/page1 I'm on mobile... Use Google and you will find how to do that
    1 point
  32. You could maybe hook into PageRender::renderPage ? Take a look at the ForcePasswordChange module: https://github.com/adrianbj/PasswordForceChange/blob/master/PasswordForceChange.module#L57 and the method that is called: https://github.com/adrianbj/PasswordForceChange/blob/master/PasswordForceChange.module#L87 Taking that approach you can prevent them from viewing the restricted pages even if they are logged in.
    1 point
  33. There is a setting for the Forgot Password module that lets you set the from email address.
    1 point
  34. From a noob on the outside looking in, I feel a need to state the obvious. I have been spending a fair amount of my time lately installing and working with a few of the 'popular' CMS offerings. I haven't honestly decided what product I'm going to go with yet. For the type of sites I hope to be doing, PW might be overkill. But that's off topic here. Just speaking from my own observations so far.... The Processwire forums and community easily outshines the others ... overwhelmingly. I am not going to name names and I'm just guessing that the accompanying argument from the competition would be something like 'Well , there's only so many hours in a day, and we're a small group of developers with other jobs, family , etc , so whatever time we can spare, we put it into development , patching, etc.'. And that argument is a completely valid one. The point is though, that it appears a number of people involved with PW, with I'm sure the same obligations, ARE taking the time to make the community here what it is - very knowledgeable , very friendly and VERY valuable to those who otherwise might be Googling for hours on end looking for a solution, and we all know how much fun that can be. Well maybe not all of us, but I know I have been there on more than one occasion because the so called documentation was outdated, couldn't find an answer in the 'forum' and I wasn't in the mood to walk through the code with XDebug that day. Anyway, I have rambled enough. Thanks again to ALL. You ALL have a GREAT community here.
    1 point
  35. Thanks LK, I'll give it a go when I get a mo. The support on this site is unbelievable. You really should charge people for this.
    1 point
  36. I've just commited a few smaller updates (most on Jonathan's requests) Migration descriptions are now escaped, so that characters like double quotes or backslashes won't break any newly created migrations. Also the backend UI does now feature a textarea instead of a text input to allow for multiline description entry. In the cli one would have to add "\n" linebreaks manually. The module does now try to add the /site/migrations/ path automatically, when it's called for the first time (e.g. by accessing the admin UI page) I've added a basic onboarding page for the admin UI, when there are no migrations, which does now feature a "Create New" button to get started. Jonathan did also request the addition of importer migrations for modules like FormBuilder or HannaCode. I'm not really keen on adding those and especially maintaining them. I'd rather suggest creating a GitHub repo, where the community can add migration snippets via pull-request. For example using the FormBuilder importer is just a single line of code, whereas the HannaCode importer would need to be copied nearly completely, because it's so tightly coupled with it's backend form. This repo option would be an easy way to just share the bits of boilerplate which is sometimes needed to do things via the api. Additionally I'm going to add some example above on how to add own helper methods to the Migration class with hooks, so everybody can add his own helper functions. Edit: I've added the mentioned docs about helper functions.
    1 point
  37. Thanks for the link to Anttis writeup. ------------------ Following is a description for what the SQLite handler was used in the past before I built WireQueue around it. One use case was for an award winning Cinemaportal where they send up to 2x 13k emails in different newsletters every week. I should embed the WireMailSMTP module there and I suggested that we should use SQLite files for it. This is running a half year in production now without any problems. At the beginning we have had a testing for 2 weeks where we slightly modified and tweeked some little parts. On that server where the website is hosted were running many many different programs and services, so, that for unknown reasons, sometimes the SQLite DB stopped working unexpected. But SQLite has a sort of transaction feature (Sqlite-Journal files), so that no recipient got lost. On every run we retrieve 500 pending recipients. The only thing what could happen there was, that, when immediately after successful sending a mail and the SQLite crashed before it could update the record in the dbfile AND in the journal file, this single recipient will be picked up again with the next batch, what results in sending him the newsletter twice. So, this (only) happened a few times per week, (3-10) on 10k mails, = 0,1 percent. And as this may be a bit specific to that explicit server, as I haven't encountered it with other use cases, it seems to be much more secure to use SQLite with its transaction / rollback functionality as MySQL with MyISAM! Don't know about the differences when using MySQL and InnoDB. But we / you can build storage handlers for every DB we / you like. So, what I have done with building WireQueue, is implementing it for easy usage and monitoring in PWs backend. The previous used fieldsdefinition of the SQLite table has changed from userid, email, sent, tries to data, state, worker, but everything else of the SQLite part is identical in WireQueue. Hope this helps a bit.
    1 point
  38. New update to support random images within RTE textarea fields. You can specify whether to include images, and the positions that they might be placed in. You can reload the page several times and the images will change positions/alignment randomly. I would very much like to hear suggestions from anyone using this if they have any ideas for improvements - do you want more configuration options - eg size of the embedded images, captions, etc?
    1 point
  39. Thanks, I have added this as an issue in the queue. https://github.com/ryancramerdesign/ProcessWire/issues/132
    1 point
×
×
  • Create New...