Jump to content

applab

Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by applab

  1. Thanks @kongondo, that is precisely the info I needed. Next time I'll RTFM a bit more before I post!
  2. Hi @Zeka, Yes, I am using $modules->get("MyModule") in my front-end template. I was just surprised to see MyModule get installed as a result of that code rather than throwing an error, which is what I was expecting. I've achieved my original goal of preventing the install in that situation but I've realised that I still need to use isInstalled() in my front-end templates to avoid runtime errors so, thanks.
  3. Hi All, I'm making my first serious foray into module development and I've discovered some behaviour which I found surprising... If I uninstall my module from the backend but do not delete the file, then I refresh a front-end page that is using that module, I would expect to see some kind of error but what happens is the module gets automatically re-installed. I can mitigate this behaviour by wrapping my front-end code in: if(modules()->isInstalled('MyModule')) { ... } but that doesn't seem like the best approach if the module is used in multiple places. Is there something I can add to my modules install() method to prevent it getting auto-installed in this situation? Thanks.
  4. Has anyone implemented Flarum yet? I like the look of it but I'm concerned that it seems to be in perpetual beta. My top contender at the moment is Vanilla but it's use of Smarty is putting me off.
  5. My method is this... The user will register using their email address and never actually know the username that's used to log them in behind the scenes. On registration the username will be derived from the email address and if there's a clash I'll simply add an incremental numeric suffix. When the user comes to login, the username is looked up from the email address (which is, of course, unique) and it doesn't matter if a suffix has been added or not, as long as it's the right username for the email address.
  6. I had a feeling that the failure of $session->login($email, $pswd); might be related to email sanitization, but since my solution worked I gave up pondering. Before trying it I didn't expect it to work as I thought that without a logged-in admin session I wouldn't have permission to query admin pages. But your solution of using a sanitized email as the username and then sanitizing $input->post->email before calling $session->login() also makes a lot of sense. I'll be doing the registration form next so I might adopt that approach.
  7. Ok, I've found a workaround by using the email to lookup the user name and then logging in with that instead. $e = $input->post->email; $p = $input->post->pswd; $u = $pages->get("email={$e}")->name; $session->login($u, $p);
  8. I have configured ProcessLogin to use email instead of username (and enforced unique values for the email field). I can login to my admin just fine using an email address but I'm trying to create a front-end login form and it's failing. I've copied the example from https://processwire.com/api/ref/session/login/ and replaced the two params with hard-coded values known to work for backend login but I just get 'Sorry Bob'. Anyone have pointers on how to get this working from the front end?
  9. Doh!, you are indeed correct. How did I miss that in the 2 line readme! Thanks.
  10. The last time I used this module was on Dev 3.0.149 and it worked fine (in conjunction with your AdminCustomPages module). I've just installed on Dev 3.0.155 and it seems to be having no effect. Any ideas?
  11. Hi Sierra, It looks like you haven't disabled the 'automatic prepend/append' option for your template. Navigate to Setup->Templates->YourTemplate Go to the 'Files' tab and tick the two 'Disable automatic...' boxes. Does that fix it?
  12. I'm still at the shallow end of the learning curve with Docker so I can't answer from experience but, AIUI... Yes, build a Docker image locally for your app/site and it should run seamlessly on any Docker-supporting host, which includes things like AWS. Regarding performance, according to this IBM research paper "The general result is that Docker is nearly identical to Native performance and faster than KVM in every category" http://domino.research.ibm.com/library/cyberdig.nsf/papers/0929052195DD819C85257D2300681E7B/$File/rc25482.pdf Just found this, it looks like others have made more progress
  13. I'm a Linux guy end-to-end, but if I had to develop on a Windows machine my go-to solution would be to use https://www.virtualbox.org/ to setup a local Linux dev environment. I've also had a tinker with https://www.docker.com/ which looks like "the right way to go" but I don't it well enough yet.
  14. thanks Teppo, worked great after 1 amendment: on first attempt I got an error: "Error: Exception: Can't save field from page 1028: /blog/posts/test-post/: Call $page->setOutputFormatting(false) before getting/setting values that will be modified and saved." so, I did as the error suggested end ended up with: $comment = new Comment; $comment->text = "my text"; $comment->cite = "my name"; // etc. $p = $pages->get('/about/'); $p->setOutputFormatting(false); // added $p->comments->add($comment); $p->save('comments'); checking the PW cheatsheet for $page->setOutputFormatting() makes it clear why that's needed.
  15. I have a template which includes a "comments" field using the core Comments field type (FieldtypeComments) Is there a way to post a comment to a page which uses this field, programmatically, from a different page?, ie. not the current $page. something along the lines of: $my_comment = array( 'cite' => $comment_cite, 'text' => $comment_text, 'created' => $comment_date ); $p = $pages->get('my-selector'); $p->comments->add($my_comment); // no such method! tia.
  16. Hi All, I've just noticed that the latest stable version has moved on to 2.4, when did that happen?, did I miss an announcement?? I'm too busy to download and take a look right now, is there a changelog anywhere that will inform us what to expect in the new version?, or maybe a forum post that I should check out? cheers, Martin.
  17. Hi Manaus, how about adding page.template to $twigvars before the call, eg. $twigvars = array("page" => $page, "template"=>$page->template->name); then in your twig template having: {% if template == "project" %} disclaimer: i haven't tried this, i'm just thinking out loud.
  18. Having used Bootstrap 2 and Foundation 4 I have a definite preference for Foundation, but that might just be my pathological avoidance of "the popular option". Contrary to your experience Joss, I found Bootstrap to be the *more* clunky of the two. If all you need is a mobile-friendly responsive grid then take a look at http://arnaudleray.github.io/pocketgrid/
  19. Maybe something like the "Amazon Elastic Compute Cloud"? (http://aws.amazon.com/ec2/) According to that page... "... increase or decrease capacity within minutes, not hours or days. " "On-Demand Instances let you pay for compute capacity by the hour with no long-term commitments." I haven't used it so can't comment on what it's like in practice, but it sounds promising in principle.
  20. Hi pogidude, This won't handle dependencies but will allow you to load scripts on per-page basis... In your master template place the following code <?php foreach($config->scripts->unique() as $file) echo "\n\t<script type='text/javascript' src='$file'></script>"; ?> In your partial templates add $config->scripts->append("/path/to/script.js"); You can also do the same with styles: // in master <?php foreach($config->styles->unique() as $file) echo "\n\t<link type='text/css' href='$file' rel='stylesheet' />"; ?> // in sub-template $config->styles->append("/path/to/style.css");
  21. hi apeisa, Thanks for the pointer. I haven't built an admin module yet, is this what you're referring to? https://github.com/ryancramerdesign/ProcessHello cheers, Martin.
  22. Hi Adrian, Thanks for the welcome, and the link. I can certainly see me finding a use for that module but it doesn't cover my requirements in this instance. I need the fields that are shown to be dependent not on the currently logged in user, but the on the type of user being editing. I.e. It will always be 'staff' who are in the back-end editing 'students' & 'agents', but I'd like a different set of fields depending on which it is. My current thinking is along these lines: 1) create 3 roles [staff,agent,student] 2) add all fields for all roles to the user template 3) use a hook to hide some fields depending on the role of the edited user (not the editing user!) If anyone with more experience can see a flaw in my plan or suggest a better method then I'm all ears. thanks, Martin.
  23. Hi All, Another ex-modxer here. After 6 years of Evo I've tried my best to bond with Revo and it's just not happening. I've built one simple site with PW and it was a delight to work with so now I'm hoping it's able to cope with the next two projects I have lined up, both of which are quite involved. If I was doing my next project in Modx it would require several custom db-tables and I'd be coding a number of custom admin screens whereas with PW I get the impression that I could do *everything* using standard features. Anyway, here's my first question... The site I'm working on has three types of users (ok, 4 if you include 'guest'). Only one type ('staff') will have access to the backend. The two front-end user types are 'student' & 'agent'. The fields I need to store for 'student' are different to those for 'agent', which are different to those for 'staff'. So, is it possible to have a different set of fields available for each user type? Any pointers on how I might approach this in PW would be much appreciated. Thanks, Martin.
×
×
  • Create New...