Jump to content

ethanbeyer

Members
  • Posts

    111
  • Joined

  • Last visited

Everything posted by ethanbeyer

  1. @alexmercenary Could you post your code? Chances are the variable you're trying to use the attachment() method on isn't an instance of WireMailSmtp.
  2. @gebeer I've looked at your solution and put it in place - and it s a much better start than I would've thought of. I'm not sure it does everything I need it to right now, but I can keep tinkering and I will report back. This is the first time when something ProcessWire does hasn't made a lick of sense to me.
  3. @gebeer It looks like you got further into the solution than I did. Tabs and repeaters were a problem for the Profile Edit screen for me, too. So I eventually gave up and gave users of that template type a role that gave them page-edit permissions, but I hadn't worked out how to make sure that people were only editing their own profiles - so I think your two hooks are helpful there! I know there's a difference in form and function for Profile Edit and Page Edit, but our scenario (where Users = Content) seems like a time when keeping the two completely separate breaks down. I think your method is clean and I will give implementation a shot. Thank you!! Edit: Just saw you'd posted twice in this thread, and just now read the first: That. Exactly that. In full! If it's on a profile page, and I've given the user the permission to edit their page...they should be able to do whatever is necessary on it.
  4. In my _init.php file, the first thing I include is _login.php: <?php // Handle logouts if(isset($input->get->logout)) { $session->logout(); $session->redirect($page->path); } // If they aren't logged in, then show the login form if(!$user->isLoggedin()) { // check for login before outputting markup if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if($session->login($user, $pass)) { // login successful $session->redirect($page->path); } else { $session->login_error = 'Login Failed. Please try again, or use the forgot password link below.'; } } ?> <!DOCTYPE HTML> <html lang="en"> <head> <title>Login</title> <link rel="stylesheet" href="/build/css/app.css"> </head> <body> <div class="container py-5"> <form action='./' method='post'> <div class="row"> <div class="col-12 col-sm-6 offset-sm-3"> <h1>You must be logged in.</h1> <div class="login"> <? if($input->post->user && $input->post->pass) { echo "<p class='error'>" . $session->login_error . "</p>"; }?> <p><input class="form-control" type='text' id="user" name='user' placeholder='Username'/></p> <p><input class="form-control" type='password' id="pass" name='pass' placeholder="Password" /></p> <p><input type='submit' class="btn btn-primary" name='submit' value='Login' /></p> </div> </div> </div> </form> </div> </body> </html> <? die(); // don't go any further if not logged in } If I go to site.dev/whatever, I am met with a login. After logging in, it takes me straight to the URL I intended to go to before needing to log in. You could change the $page->path to $pages->get('/events/')->httpUrl; - would that work?
  5. It's definitely possible that you haven't set up a valid from-email address. Check out the WireMailSmtp module, it may help!
  6. Hello, I recently posted in this topic, but I decided to start my own thread because while I believe my issue is related to the one in that thread, they are not exactly the same: I have created a custom User Template in the method outlined in the docs. I am creating a directory, so it made sense that every page in the directory was a Directory Member, so they could log in and edit their own information while also keeping the entire directory protected behind a login wall. So the new user type is created: "directory-member". I then created two new roles: "member" and "directory-admin": The "member" only has the ability to View directory-member pages, and "profile-edit", which allows them to manage their own information. The "directory-admin" has the ability to edit any directory-member pages, and administer users. Some Directory Members are both, but all have at least the "member" role. The first hint that something was wrong was when I was testing a "member" user and I could not add a new item to a repeater on that profile. The url for the profile edit (this will be important shortly) is site.dev/admin/profile. The repeater is set up to load new items through AJAX. If this option is turned off, the rest of this issue is no longer completely valid. But as I have found what I believe to be a pretty large issue in the Processwire codebase, I thought it worth bringing up. See, every page (even a user) has a $page->editUrl() method, and it returns a URL like this: site.dev/admin/access/users/edit/?id=2096. That's all good and fine for users that have page-edit permissions, but if they don't, that link will resolve to the admin's equivalent of a 404. So the way that Processwire currently gets around this is by creating a specific editing area for a user to interact with only their profile: /admin/profile. And that works pretty nicely, except for the fact that nowhere is editUrl() ever made aware of the difference. editUrl() is not hookable, and whether or not a page is editable is based on the PagePermissions module. On top of that, there are several core modules that hardcode a search-and-replace (see InputfieldRepeater.module:627) where the editing screen is for Users. This doesn't allow for a huge degree of flexibility that is offered in other places throughout Processwire. If line 627 of InputfieldRepeater is changed from this: $editorUrl = str_replace('/access/users/edit/', '/page/edit/', $editorUrl); to this: $editorUrl = str_replace('/access/users/edit/', '/profile/', $editorUrl); ...the AJAX repeaters work. It's maddening! As is brought up in the thread I attached above, a lot of the features of page editing are missing within /admin/profile/, and it just makes for an altogether strange editing experience. A user who has "page-edit" permissions for templates other than directory-member, but does have "profile-edit" permissions, will see their user in the Page List, but cannot edit their Page unless they hover over the wrench and click the "Profile" link. It just seems - off. I think what this hinges on for me is that the editUrl() of the user should be "/admin/profile/" if that user is logged in (and their page should be editable from the Page List), or the "/admin/access/users/edit/" url; regardless of the URL, both links should resolve to the Page Edit screen, as the Profile Edit screen seems to be a unnecessarily neutered version of Page Edit.
  7. I know this is an old topic, but I am currently running into some majorly-headache-inducing issues concerning the User Profile Page and the Page Edit screen - I can't sort out why they have to be different. I am about to post a new thread about my specific experience in this realm, but if anyone knows anything about this issue, I'd appreciate the help! Here's the thread I just created--
  8. I'm having this problem too, and I think that it is due to the fact that Repeaters are technically Templates and Pages of their own. I don't think the current permission schema handles this very well. I am looking into the problem as we speak, and the only way I have been able to get it to work is by duplicating the User Template, and giving a role page-edit permissions. This results in unwanted side-effects of that user being able to see the entire page tree in the admin templates so I am not sure exactly how to solve this right now.
  9. @Barry after logging in to SendGrid, have you looked here? https://app.sendgrid.com/guide/integrate/langs/smtp I've been using SendGrid, and tested it just now - it is working for me! You will have to create an API key, but they walk you through that in the link above.
  10. @horst Can you tell me how/where in the module this hijacks/extends wireMail()? I'm glad that it does, but I am desperate to understand how this works. new WireMail(); // WireMail new wireMail(); // WireMail wireMail(); // WireMailSmtp $mail->new(); // WireMailSmtp This has highlighted one of the many parts of my PW knowledge that is majorly lacking. Edit: Ok. Finally get it. Here's how it works, for anybody else that wonders... wire/core/boot.php loads JUST WireMailTools. WireMailTools::new() looks for any classes that overlay on WireMail. If WireMailSmtp is installed, it will be the class that is returned. If none are found, it defaults to WireMail. Shooooo-wee. Nice to know!
  11. I have a role with the following permissions: Up until today, I've had no issues with this Role. But now when I log in with a test account with this role, the admin page list never loads. Looking at the Javascript console, I see: TypeError: Q is null I have no idea what's causing this.
  12. Interesting... I've been saying for a while that I'd love to help the docs get better. As they are now, I think they're pretty good - but things could always improve, and if there is one thing in development I am uber-passionate about, it's documentation!!
  13. Today I noticed the Fieldgroups class is missing from the reference, and I wasn't sure why! Does anyone know? Also, I feel like the docs would be easier to parse/navigate if the API Variables were shown alongside the class they were an instance of. Config ($config) Field Fields ($fields) Fieldgroup Fieldgroups ($fieldgroups) Fieldtype HookEvent Inputfield InputfieldWrapper MarkupPagerNav Module Modules ($modules) ... Page ($page) Pages ($pages) ... I'm also aware of the API Gen reference page (https://processwire.com/apigen/index.html), which is more robust, but a little harder to parse.
  14. I know this is old, but I think your error might be because you're trying to attach $content to the current instance of ProcessWire. I think it might work if you did this: return $content->wire('pages')->find("parent=/"); Since $content is a new instance of ProcessWire, you should be able to do things like this: $contentModules = $content->wire('modules'); $contentForms = $contentModules->get('FormBuilder');
  15. Had to report back and say that in a multi-site environment, where all the sites are using the same ProcessWire core, it is possible to "share" modules by the method listed above, with no need for symlinks! $config->paths->siteModules = $config->paths->root . 'shared/modules/'; $config->urls->siteModules = $config->urls->root . 'shared/modules/';
  16. You're right. require_once("creds.php"); // this works require_once("./creds.php"); // this doesn't No idea why.
  17. To me, saving database credentials to a Git repository, even if that repo is private, is a big no-no. So I've been tinkering with different ways to deploy sites to production environments without saving the database credentials to the repo. I know that there is a the config-dev.php option. But that hasn't worked for me, as I will explain later. I added this to my config.php: $config->env = "dev"; if($config->env == "dev") { $config->dbHost = 'localhost'; $config->dbName = 'processwire'; $config->dbUser = 'root'; $config->dbPass = 'root'; $config->dbPort = '3306'; } else { require("./{$config->env}.config.php"); } So if $config->env = "production", production.config.php should be loaded: $config->dbHost = 'localhost'; $config->dbName = 'processwire-production'; $config->dbUser = 'username'; $config->dbPass = 'productionPassWord'; $config->dbPort = '3306'; I can't see anything wrong with the syntax of this at all - but for some reason, if that file is added with require() or require_once(), ProcessWire never loads. If it's loaded with include(), I get an error about the page not being found, and there being no install.php present. So it seems like for some reason, there is no way to include a file in config.php, which confuses me immensely. How my brain works I'll try to explain my thought process behind this a little more. I think it's a good idea for dev environments (especially those that come with a Vagrant box and a defined database already installed) to include dev-level database creds. It should just work. If someone works on this site after me, they shouldn't have to spend a ton of time getting a config file set up. Secondly, having a config.php file and a config-dev.php file frustrates me because for the developer that comes after me, they could really use the config-dev file! But if it's in the repo, it gets deployed. If it gets deployed, it gets called on the staging/production server, and that is no good! Also, config.php and config-dev.php would in most cases pretty much completely mirror one another with the exception of database creds, and maybe debug or a few other things. That is why I want to have all the configs in the repo within config.php except for the tiny bits that are environment-specific. They should be able to be included, right?
  18. I have a question about Multiple Site implementation, and how to possible "share" modules between them. First, required reading: https://processwire.com/api/modules/multi-site-support/ I'm dealing with Option #1. The way this works is that in the root directory of a site, there is an index.config.php file that denotes what domain is mapped to which site-*/ directory. The project I am working on has three site-*/ directories, each with their own site-*/modules/ directory. What has happened is that a lot of the modules from site to site are the same. I was wondering if there was any way to "share" modules between sites in the Multiple Site setup, via symlink or alias, or potentially if there was some roadmapped feature that @ryan has planned to solve this issue. Either way, any help/pointers would be appreciated!
  19. Thanks for the help, @Robin S and @LostKobrakai! You guys rock.
  20. Oh my gosh - have I been reading these docs wrong all this time? http://processwire.com/api/ref/pagefiles/ hahahahaha I thought $page->files was an attribute that got set at some point and was a Pagefiles array of all files added to that page... Well that definitely solves one thing!! Thank you, @Robin S! I'm still very confused why some of the fields don't show up as a part of the $page->data array, though.
  21. @tpr I am not sure I know what you mean, but I changed the code within Tracy Debugger to $fg = $this->wire('fieldgroups')->get('document'); $t = $this->wire('templates')->get('document'); $example = $this->wire('pages')->get(1624); dump($fg, $t->fields, $example->fields, $example->files, $example->document_Files, $example->data); ...and all the dumps were the same as when the Page variable was named $page.
  22. This is a strange error I am totally unsure how to fix! It started when I was trying to get a file from $page->files. I know that there is a file in a field called document_Files. But $page->files returns null. So I popped into Tracy Debugger and wrote this code: $fg = $this->wire('fieldgroups')->get('document'); $t = $this->wire('templates')->get('document'); $page = $this->wire('pages')->get(1624); dump($fg, $t->fields, $page->fields, $page->files, $page->document_Files, $page->data); Resulting in 6 Dumps: $fg, $t->fields, $page->fields all result in the same object, which is to be expected. (fieldgroup): Fieldgroup {#173 +"count": 4 +"items": array:4 [ 1 => "title" 199 => "document_customizableCheckbox" 197 => "document_Files" 200 => "document_thumbnails" ] } But then it gets strange with $page->files null ...and $page->document_Files. Pagefile {#267 +"changes": array:1 [ 0 => "formatted" ] +data: array:6 [ "basename" => "example.pdf" "description" => "" "tags" => "" "formatted" => true "modified" => 1497976118 "created" => 1497976118 ] } I would expect those two to match. But obviously they don't. But then it gets weirder, still! $page->data should have four elements in the array - one for each field in the Fieldgroup - but two don't show up: array:2 [ "title" => "Introduction" "document_Files" => Pagefiles {#264 +"count": 1 +"items": array:1 [ "payroll_vault_brochure_markbeaton_2016_12_01p.pdf" => "payroll_vault_brochure_markbeaton_2016_12_01p.pdf" ] } ] Also, in the $page->data array, document_Files (the field) outputs as a Pagefiles class, whereas getting the field directly only returns a Pagefile. I don't even know where to start! Has anyone else had something like this happen? I have looked at the database starting with the template. I can confirm it has the correct fieldgroup_id, and that fieldgroup has all the correct fields. The page in question also is the correct template.
  23. I've built a couple PW sites now, and often I break my directories up like this: assets files cache logs sessions active.php index.php installed.php backups fonts js modules scss templates vendor But I kind of wish, in that schema, that I could change it to something like this: modules resources fonts js images scss storage backups cache files logs sessions active.php index.php installed.php templates vendor My reasoning is that JS/CSS/Theme Images/Fonts are site assets (or "resources"), while the caches/files/logs/sessions are more storage. And that is fine to set up manually - but in looking over the config.php file, I can't find a place where I can set that so that ProcessWire will respect it. Every part of this CMS is flexible, so I do assume there is a way to do this - I just don't know what it is. Has anyone else done something like this?
  24. If it's shared hosting and all of the sites on your IP are potentially sending emails, that is almost certainly your problem. Again, I'd look into an email delivery service like Sendgrid, Mandrill or even TurboSMTP - these will help with deliverability, and you won't be competing with other sites on the same IP to get emails out.
×
×
  • Create New...