Leaderboard
Popular Content
Showing content with the highest reputation on 03/29/2018 in all areas
-
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.4 points
-
Or you can steal one or two methods @ryan's code, stuff them into your little module, tweak a few lines and add even more fun to PW Attached is a quick & dirty little module (actually, two of them) that adds: $log->mailLog($your, $fields, $ending, $with, ..., $messagebody) [pass as many arguments as you like; the last one will always have white-space set to wrap] a special log viewer at Setup -> Mail Log that displays as many columns as you sent to mailLog() It uses some unlikely to naturally occur text patterns for newlines and field separators and fools ProcessLogger::executeView into thinking it is pointed to the mail log, and that way lets it do the heavy lifting. ProcessMailLogger.zip3 points
-
You won't be able to use $log->save() for the reason @alxndre mentioned, and you won't be able to use the admin log viewer because a) it uses new lines to identify each log entry so therefore one entry cannot contain more than one line, and b) it entity encodes HTML for security reasons. But you can use PHP functions like error_log() or file_put_contents() to create your own log file (create the "custom-logs" folder first). $text = date("Y-m-d H:i:s") . "\nHello, how \nare you?\n\n"; // your text, include newlines if needed error_log($text, 3, $config->paths->assets . "custom-logs/mail.txt")3 points
-
I don't think this is possible because WireLog replaces the escape characters with spaces: // somewhere in WireLog::save() $text = str_replace(array("\r", "\n", "\t"), ' ', $text); and it also sanitizes the tags when outputting.3 points
-
I've done a simple version of this by hashing the file's modified time: $js_version = md5(filemtime($config->paths->assets . 'js/script.js')); echo sprintf('<script src="%sjs/script.js?v=%s"></script>', $config->urls->assets, $js_version);3 points
-
2 points
-
What is submissions? e.g. submissions=$post_name. What sort of field is that? if($submitted->id) means you found an existing page, so you should redirect, and not create a new page in that condition block. Here's some pseudo-ish code based on @elabx's code since I don't know what submissions is. It assumes there is a parent with the path /submissions/ . That parent page has children which have an email field. In this code, we are looking for a child page whose name matches a submitted name and whose email matches a submitted email. I am assuming name here is ProcessWire's in-built name field and not some custom field. I have also used $input rather than $_POST. I have left your stripslashes in there since I don't know why exactly you are using them. if($post->submit){ $name = trim(stripslashes($post->firstname)) . trim(stripslashes($post->lastname)); $upper_name = trim(stripslashes($post->firstname)) . " " . trim(stripslashes($post->lastname)); $post_name = $sanitizer->pageName(strtolower($name));// I am assuming ProcessWire 'name' which is used to build the page URL $email = $sanitizer->email($post->email); $todaysdate = date("F j, Y H:i a"); // rather only get the first page // this is an OR:group selector $submitted = $pages->get("parent=/submissions/entries/, (name={$post_name}),(email={$email})"); // page with email and/or $post_name already exists, redirect if($submitted->id){ $session->redirect("?alert=existing-submission"); } // good to go, create new page else { $u = new Page(); $u->template = "submissions-entry"; $u->parent = '/submissions/entries/'; // some of these already sanitized above $u->name = $post_name; $u->title = $sanitizer->text($upper_name); $u->submissions->_date = $todaysdate; $u->submissions->full_name = $sanitizer->text($upper_name); $u->submissions->email = $email; $u->save(); //$u->setOutputFormatting(false);// @question: why do you need this? $session->redirect("?alert=form-success"); } } // show new form else { //$session->redirect("?alert=form-failure"); }2 points
-
@theoretic there is such a field type for color https://modules.processwire.com/modules/fieldtype-color/ and also a module for color picker https://modules.processwire.com/modules/fieldtype-color-picker/ if they don't solve your request, you can inspect their code and see how to do it hope this helps2 points
-
It's ProcessPageView::getPage(), but it's a protected function and therefore not for public consumption as per right now.2 points
-
Here the url should be add-new-recordal, so it gets read by the process module: $wire->addHookAfter("ProcessPageLister::execute", function($event) { if(wire('page')->id === 1413) { // the particular Lister instance page id $out = $event->return; $out .= ''; $btn = wire('modules')->get("InputfieldButton"); $btn->attr('data-href', "./add-new-recordal/"); $btn->addClass("pw-modal"); if(!$this->config->ajax) $out .= $btn->render(); $event->return = $out; } } I have done this in init.php but my wild guess is it should work on ready.php too: $wire->addHook("ProcessPageLister::executeAddNewRecordal", function($event) { // // Create new page and redirect to its edit section $p = new Page(); $p->template = '02_template'; $p->parent_id = 1040; $p->name = 'recordal_' . $pageRecordalsMicrotime; $p->title = 'Recordal_' . $pageRecordalsMicrotime; $p->created_users_id = $this->user->id; $p->of(false); $p->save(); $this->session->redirect(wire('config')->urls->admin."page/edit/?id={$p->id}&modal=1"); } From what I can see, the creation of the page and redirect is already performed in an iframe modal, so it will all happen in the iframe opened with the button you are rendering. Or maybe I'm missing a point here2 points
-
if(isset( $_POST['submit'])){ $submitted = $pages->find("parent=/entries/, (submitter_name={$input->post->name}),(mail={$input->post->mail})"); if($submitted){ $u = new Page(); $u->template = "entries"; $u->parent = $pages->get("/entries/"); $u->name = $sanitizer->text($post_name); $u->title = $sanitizer->text($upper_name); $u->save(); $u->setOutputFormatting(false); $session->redirect("?alert=form-success"); }else { $session->redirect("?alert=existing-submission"); } }else { $session->redirect("?alert=form-failure"); } This check is first_name OR mail exists already (and checks for exact value! maybe for name you want: name%=$input->post->name).2 points
-
https://github.com/processwire/processwire-issues/issues/5142 points
-
pseudocode: // tracy console foreach($users as $user) { if(user admin theme == ..) $user->setAndSave('admin theme', 'uikit'); } you'd need to find out the correct properties and values, but that should not be too hard.2 points
-
That's ProcessWire! A series of ways to reach your goal. Pick your favourite: Do you like uphill climbing, go there. Do you like to stroll, go here. Another way would be to put a snippet like this into the top of your _main.php: <?php namespace ProcessWire; if('ajax' == $page->template || $config->ajax) { echo region('main'); return; }2 points
-
just found the tut+ tutorials, I wish I had found these earlier lol. PW is becoming much clearer, like finding a Rosetta stone. thanks everyone for your patience2 points
-
Hi @szabesz - sorry I only have a minute at the moment, but I see that you are using an after hook, but in CustomUploadNames I use a before hook: https://github.com/adrianbj/CustomUploadNames/blob/master/ProcessCustomUploadNames.module#L98 Does that help?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 )2 points
-
Perhaps you can find some inspiration / ideas from https://github.com/tutsplus/how-to-create-an-ajax-driven-theme-for-processwire2 points
-
1 point
-
@BitPoet @Robin S thank you! it will take some time to get used to how things work in the backend, thanks your help1 point
-
Just click on the "Change" button and hover over the currently selected page in the tree. The "unselect" button will pop out next to it. It's a bit hard to find, especially using the UIKit admin theme.1 point
-
Those two things contradict each other somewhat. If you are creating a new custom fieldtype then there won't be any existing field data until you create your fieldtype module and start using it in pages. There is the Events fieldtype and inputfield which was created specifically as a proof-of-concept for developers to learn from. But it extends FieldtypeMulti (each field instance saves/shows multiple repeated items) so that might not suit what you are wanting to do. I don't think Ryan made a similar proof-of-concept for a straight Fieldtype. But in a way all the Fieldtype modules in the core and in the modules directory are a proof-of-concept - find a fieldtype that is broadly similar to what you want to do and check out (borrow from ) the code. Also, the documentation for the Fieldtype class will be useful. Perhaps if you describe exactly what you want the fieldtype/inputfield to do people can give you more suggestions.1 point
-
Thanks @elabx! I had no idea that I could set it up like that. Some things are so easy, and I just try to over complicate them in my head.1 point
-
You can simply do this : Form submit => POST request => verify($input->name, $input->email); Then in the verify function, you parse the name and check if it already exist in your system. If it exist, your return an error, else you create an new entry. Which difficulty are you encountering ?1 point
-
1 point
-
And https://github.com/processwire/processwire-issues/issues/523 Yes. That explains...1 point
-
// tracy console foreach($users as $user) { if($user->admin_theme == 'AdminThemeDefault' || $user->admin_theme == '') $user->setAndSave('admin_theme', 'AdminThemeUikit'); echo $user->name . ": " .$user->admin_theme . "<br>"; } Well. This did it. It not exactly what I would have prefered but it works. Now every user has the uikit theme marked in his profile. What was confusing: New Users have the default admin theme marked in the interface by default, but have no entry in the db ($user->admin_theme == ""). But explicitly saving the users profile will entry the AdminThemeDefault.1 point
-
1 point
-
@Robin S, bravo! Cannot test it now (moved to a simper solution) but for sure Your proposal should work. The only thing i needed was to get the page holding both repeaters, and You did it using $page = $page->getForPage();1 point
-
Right - I forgot that your Page Reference field is inside a repeater, so that means in the hook $page is the repeater page and we need to get its container page. I edited my post above and it should work now.1 point
-
Glad to hear that helped. What I meant regarding saved/added: the saveReady and saved hooks are executed every time you save a book page, even if it is just to amend some information. The created timestamp won't change anymore after the first save when it was added. The "added" hook will only execute once for each book page at the time it is created, so you can avoid running your code each time. On saved/added vs. saveReady: there might be an (unlikely, but not impossible) error where something prevents saving your book page. If that happens and you use saveReady, your parent page's lastcreated field will have been updated nonetheless, which will lead to an inconsistency until the next book page is added and correctly saved so it overwrites its lastcreated field again.1 point
-
Oh yes, it does help a lot! Thanks for fixing it for me! I was just too much concentrating on anything else but creating those image variation which can be performed in the after hook only. And you are right, renaming them is a different matter which can be done in the before hook.1 point
-
you can just pass the path of the page that handles the segments; if you are on the page, then $page is what you want. how can the system know which part of the URL is the segment? The whole point of URL segments is that they are not real pages, so there is no way to "look them up".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.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().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; } });1 point
-
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 matter1 point
-
@horst That's it! Thank you. @dragan Great tip. Will install an instance and see what's going on. Thanks all1 point
-
This question does not really matter, as there just are no page level permission in processwire and propably never will be. ProcessWire is build around template level permissions reaching deep into quite a bit of core functionality and page-level permissions are not really a requirement for a simple cms anyways (we're not talking enterprice grade). Though there are actually quite a few 3rd party modules to make access management more granular in various ways.1 point
-
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.1 point
-
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.1 point
-
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 stuff1 point
-
You can check for AJAX calls with: $config->ajax Sets to true if request is async.1 point
-
I am using it for different cases. For modules (everything from a config file) : I am not defining default values as you see here : https://github.com/trk/WirePHPMailer/blob/master/WirePHPMailer.module#L33 Getting module configs : https://github.com/trk/WirePHPMailer/blob/master/WirePHPMailer.module#L77 Settings default values : https://github.com/trk/WirePHPMailer/blob/master/WirePHPMailer.module#L78 Merging module values with defaults, building inputfields : https://github.com/trk/WirePHPMailer/blob/master/WirePHPMailer.module#L119 - Its easy to build configurable module for me, no need to set all things on different places. For creating form you can see simple example usage on README.md I am using it for creating dynamic fields for page templates on runtime by hooking ProcessPageEdit::buildForm. In screenshots Settings and General tabs added dynamically and fields inside these tabs added by a config file. Use case change up to you.1 point
-
Lol, now I'd hate that to be on my conscience. I'll create a custom option then. This is linked to my other post: Trying to juggle between the two here.1 point
-
It is hirarchically ordered, highest first: $element->size() options are the highest, overrides all other individual ImageEngine-Settings, override all below them, if you have installed two or more engines, only the setting of the finally invoked engine is used site/config.php => $config->imageSizerOptions wire/config.php => $config->imageSizerOptions and last, but more theoretically, if all above would be missing, the hardcoded defaults of the module-file (php-class) would be used The higher override all lower1 point
-
Currently the Map Marker inputfield does not support AJAX-loading. I have opened a GitHub issue for this. Until an update is released you can fix the problem by adding the following to InputfieldMapMarker.js: $(document).on('reloaded', '.InputfieldMapMarker', function() { $(this).find('.InputfieldMapMarkerMap').each(function() { var $t = $(this); InputfieldMapMarker.init($t.attr('id'), $t.attr('data-lat'), $t.attr('data-lng'), $t.attr('data-zoom'), $t.attr('data-type')); }); });1 point
-
Help yourself... ;-) 1 - apache user id inside my container docker exec processwire /bin/sh -c "id www-data" # uid=33(www-data) gid=33(www-data) groups=33(www-data) 2 - I create my directory site (pw/site) mkdir site chown -R 33:33 site mkdir modules mkdir assets chown -R 33:33 modules chown -R 33:33 assets cp site-default/config.php site/config.php chown -R 33:33 site/config.php cd site-default/ ls assets finished.php install ready.php config.php init.php modules templates cd .. cp site-default/finished.php site/ cp site-default/ready.php site/ cp site-default/init.php site/ cp -r site-default/install site/ cp -r site-default/templates site/ After that, everythink is ok with http://192.168.2.2:82/install.php1 point
-
For those people who cannot get this to work in PW3, the instructions say to put this in your head: <script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?sensor=false'></script> This actually needs to be: <script src="https://maps.googleapis.com/maps/api/js?key=<?= $modules->get('FieldtypeMapMarker')->get('googleApiKey') ?>"></script> Or however you like to include your JS files. The sensor=false is no longer needed, but the API key is. Seemed to work for me, I havent had time to investigate the inner workings of the module to see if this should be done or not but is just a bug. Happy mapping.1 point
-
Just add something like this to the top of your events index page. You could compartmentalize this into a LazyCron call, but for such a simple thing it's really not necessary. $events = $pages->find('parent=/events/, date<"-3 months"'); foreach($events as $event) { $event->of(false); $event->addStatus(Page::statusUnpublished); $event->save(); } Btw, when testing something out like this, always comment out the $event->save(); the first time and take a look at what pages get affected by echoing them rather than saving them, the first time around. i.e. // $event->save(); echo "<p>Unpublishing: $event->url</p>"; Once confirmed that it is behaving the way you want, then remove the echo and uncomment your save();1 point