-
Posts
733 -
Joined
-
Last visited
-
Days Won
9
Everything posted by SamC
-
Not sure I'm 100% on the point of this module. I find I learn best when I get a problem, then have to find a way to fix it, meaning, I'll see the point once it solves a problem I have!
-
Thanks @abdus I like the idea of listing the categories with a few posts under each one at /categories/. Is a good use of that page. Might try the /blog/categories/ too, see which works best for me. Not got into hooks yet but that's the second time I've read about Page::path tonight. On the bucket list along with writing a module.
-
I'm creating a blog which I hope to write PW tutorials for beginners. So, I have the following tree structure: Paths like: /blog/ (lists posts) /categories/processwire/ (will list all posts with that category etc. I choose the category within the blog post thus: Path on the category page: However, I have a couple of problems. I was going to enable URL segments on category-index template. However: 1) My paths exactly match my anticipated URL segment enabled URLs i.e. /category/processwire/ actually exists as a path therefore taking precedence. Because there is no category-entry.php file, this gives me a 404 i.e. "You can use URL segments on any page where your template settings allow, regardless of whether it has children or not. Should there be a child page that has the same name as a URL segment that the parent page's template is looking for, the pages in the tree always have precedence." https://processwire.com/docs/tutorials/how-to-use-url-segments/page2 2) I have no real use for /category/ page other than organizing the child categories in the tree. Going to that URL makes no real sense, what would be shown there? 3) If I decided to NOT use URL segments, but to use a category-entry.php file instead (category-entry template is used to create these pages), the URL /category/processwire/ would work and render whatever was in category-entry.php. In both scenarios though, how do I handle the /category/ URL? I mean, I could list all blog posts there or something but /blog/ already does that. Any advice would be awesome, thanks
-
@pwired yeah, but it BS3 unfortunately. It's not hard to use BS4 from npm and use the scss source though.
-
You prefer it to bootstrap 4? I had a bad time trying to get uikit into my node/gulp workflow. I only wanted the sass and BS4 is pretty simple to integrate with npm and compile only the parts I need + custom sass on top of that. I haven't used any JS from these frameworks yet. Seems uikit is popular around these parts though.
-
I think it's safe to say I didn't read Ryans' posts properly. I will hang my head in shame for a few mins.
-
I agree, the WP interface is very pleasing to the eye compared to my current bright white admin. The colour scheme is similar to the Apple website, and there's a reason for people liking varied greys and softer contrasts. I was slightly concerned when I saw the new PW uikit demo admin. It was just so white, like the inside of a dentists room. This is one area where I would be quite happy for PW to follow WP. I don't think imitation of something so massively popular is a sellout. CraftCMS has a very good looking admin too. Again, with the shades of grey, darker grey to contrast, soft drop shadows, not too much white. https://www.google.co.uk/search?q=craftcms+admin&source=lnms&tbm=isch
-
Feel free to PM me if you want any help with testing, CSS etc. maybe not so much the actual module side, haven't got into that yet.
-
Awesome module, but one thing for me, I'm not a fan of the centred login, specifically the centred text above the text boxes themselves (I would personally prefer the text and the button to the left but the whole form still centred): ...so I turned it off: ...but the default usually looks like this: I actually prefer branded logins like this which to me are more stylish (this is not my site nor my image, just from a google search): Not got into CSS theming the admin yet.
-
Installed AOS and Reno theme now, totally taken the editing to a new dimension, nice one @tpr unfortunately it does makes the old classic theme (used on my previous sites) look very dated.
-
$user there was supposed to be checking whether the username used in the signup form, i.e. the current value of: // sanitize input field values $user = $sanitizer->userName($input->post->inputUsername); ...is already a username in the system. I forgot to mention my form checks whether a username exists, also whether an email exists. Usernames and emails must be unique. Maybe I should have used a different variable name to avoid confusion. Or maybe it doesn't do anything, have to check that. Ah, that's useful to know, thanks. I'll have to test this out, can't say I fully understood the writeup on that, would have to see it in action.
-
Following on from this post: I got to work in trying to make this a reality. After studying the API for a bit plus reading examples, I got a sign up form going: //views/signup.php <?php namespace ProcessWire; function createUser($user, $email, $password) { // create user $u = new User(); // set name $u->name = $user; // set email $u->email = $email; //set password $u->pass = $password; // assign role of "member" $u->addRole("member"); // save new member $u->save(); // if successful $success = true; return $u; } function createProfile($user) { // create profile page $p = new Page(); // set template (can only be child of profile-index) $p->template = "profile-entry"; // set page name $p->name = $user->name; // set page title $p->title = $user->name; // set page title $p->altTitle = "Profile page for " . $user->name; // set page reference to correpsonding user page $p->userRef = $user->id; // save page $p->save(); } // input field validation wireIncludeFile("./vendor/vlucas/valitron/src/Valitron/Validator.php"); // sanitize input field values $user = $sanitizer->userName($input->post->inputUsername); $email = $sanitizer->email($input->post->inputEmail); $password = $input->post->inputPassword; $v = new \Valitron\Validator(array( "user" => $user, "email" => $email, "password" => $password ) ); $v->rule("required", ["user", "email", "password"]); $v->rule("email", "email"); $v->rule("lengthMin", "password", 6); // if form has been submitted if($input->post->sendMe) { if ($v->validate()) { // return user if exists $u = $users->get($user); // return user if email address exists $e = $users->get("email=$email"); // if both user or email don't exist if (!($u->id) && !($e->id)) { // create user and profile createProfile(createUser($user, $email, $password)); // return result of attempted login $u = $session->login($user, $password); // check if user now exists if (!is_null($u)) { $session->redirect($pages->get(1037)->url . $user); } } else { $session->success = false; // email taken if ($e->id) { $session->flashMessage = 'Email already exists. Please use another email.'; } // user taken else { $session->flashMessage = 'User already exists. Please choose another username.'; } } } else { $session->success = false; $session->flashMessage = 'All fields must be complete.'; } } ?> <div class="container"> <div class="row justify-content-center py-5"> <div class="col-6"> <?php if($session->flashMessage):?> <div class="alert <?= $session->success ? 'alert-success' : 'alert-danger'?>" role="alert"> <?php echo $session->flashMessage;?> </div> <?php endif;?> <form action="./" method="post"> <div class="form-group <?php echo $v->errors('user') ? 'has-danger' : ''?>"> <input type="username" class="form-control" name="inputUsername" placeholder="Username" value="<?= $user; ?>"> </div> <div class="form-group <?php echo $v->errors('email') ? 'has-danger' : ''?>"> <input type="email" class="form-control" name="inputEmail" placeholder="Email" value="<?= $email; ?>"> </div> <div class="form-group <?php echo $v->errors('password') ? 'has-danger' : ''?>"> <input type="password" class="form-control" name="inputPassword" placeholder="Password"> </div> <div class="form-group"> <button type="submit" name="sendMe" value="1" class="btn btn-primary">Create account</button> </div> </form> </div> </div> </div> <?php $session->remove('flashMessage'); ?> I've got templates: profiles-index (just used in the tree to hold the profiles) profile-entry (hold the individual profiles) I put a page ref field on profile-entry, which points to the user. See question (3) below. So, I end up with a URL like 'mysite.com/profiles/beastman' So the questions I have: 1) Is there a better way of doing this: // return user if exists $u = $users->get($user); // return user if email address exists $e = $users->get("email=$email"); // if both user or email don't exist if (!($u->id) && !($e->id)) { Any advice on writing better code, then throw it my way please. I'm trying different techniques like using functions etc. for practice. 2) I haven't used this code, but what does: $u->of(false); ...do? I see this in a lot of the login forms examples. i found it in the API but still not sure why to use it. 3) Have I done this the right way round? Should the page reference be on user template pointing to the profile, or the on the profile template pointing to the user? The whole process goes something like this. Go to /signup/: Validation, fields not filled out: Validation, user already exists: Validation, email already exists: Enter some details, logs you in and redirects: Default login page: Refresh the admin login page: So now I can at last demonstrate my issues with users getting the tree view vs having a custom dashboard. Bear in mind they will only get to this page if they use the admin login form. If they go to the tree view here, I have another problem. If they click profile name (top right), then go to change the password, the rules are different from the ones I set in the initial sign up form. The built in rules are "Minimum requirements: at least 6 characters long, letter, digit." My rule was just 6 characters at least. Anyway, going off topic. The "where does the user go and how do they change their profile details once they've logged in" bit part confuses me. Presuming they could go to a dashboard or something else if they used the 'other' login form block I'm working on and avoid the admin backend entirely: So, the new user is in the system: and: Sweet! Basic, pretty useless, but a great learning experience so far --EDIT-- Added some more images to show how the form works when validation fails. I would recommend recaptcha too though to stop spam users: https://modules.processwire.com/modules/markup-google-recaptcha/ Once you've got a site key from Google, it's as simple as configuring the module in the PW admin then in your template: $captcha = $modules->get("MarkupGoogleRecaptcha"); // render the recaptcha <?= $captcha->render(); ?> For valitron, install composer then (I ran this command from inside /site/templates/): composer require vlucas/valitron ...results in '/site/templates/vendor' folder which has valitron inside. Then just include the file: wireIncludeFile("./vendor/vlucas/valitron/src/Valitron/Validator.php"); Hopefully this will help someone
-
Much better! I was gonna attempt to make a module that did this. Maybe I could adapt the module so skinning it would be easier i.e. a bunch of premade ones with added radio buttons in the module settings to choose skin. Food for thought, might get me into the modules game a bit, see how they work etc. Drupal had a great admin bar, much like the above. If a client is on a page, I see it as absolutely essential they have an edit link visible on that page. No way do I expect them to open a new tab, find the tree, find the page, click edit... bleeeurgh. An admin bar makes a lot of sense to clients, I've seen them use it. Thanks @adrian
-
We should work on a project together then and combine what we've learned so far. Can use git and all that fancy stuff that I still don't understand
-
That iPhone X looks grim! The missing part of the screen at the top is just horrible, and the dock looks so out of place to me. Sticking to my S7 over here (which can then be hacked with a custom ROM when it gets old so it lasts me way longer than it's supposed to).
-
This exactly. Drupal had a module (can't remember the name) but when clients would log in, they would get a bunch of blocks like latest posts with EDIT/DELETE next to each etc. and stuff like that. They didn't see the proper admin at all. I'm quite liking the front end editing, as a user only needs to log in and then they can edit their pages right there on the page they're looking at rather than needing the admin area. I'm starting to learn how to build more 'user-centric' sites now and the big question I always have: 1) Do I provide a custom login form that goes to some kind of dashboard i.e. they never touch the admin area. Caveat being that the dashboard would need to let them upload images, edit content, basically do all the stuff they can do in the admin area anyway. OR 2) Let them use the standard login form (which is easily redirected to if a user doesn't have permission to view a page) and then use the page tree with strict user permissions, i.e. they end up with a 'tree' with about one branch (if editing their profile is all that's allowed). I'm finding it a bit confusing as I've never had the chance to see how experienced people do it. That's always the problem to a beginner. 10mins logged in to a pro site and you'd move forward so much quicker.
-
I think a theme refresh for the admin would make a big difference. Problem I have is I don't know how I'm gonna convince clients that PW is a better choice than WP. As in, off the top of my head: 1) They know WP, everyone talks about it, their mum told them it's amazing! 2) Themes. 3) When you leave, who's gonna take over their PW site long term? 4) They want extra functionality, you can't do it for whatever reason, who can? 5) I like the simplicity of the hierarchical tree in PW. So far, my clients have been a little confused because of hidden/unpublished pages. They think everything in the tree is on the site to view. In fairness, I may have missed a setting that makes these actually hidden from clients. For example, one page that needed to be in the tree, but also hidden (to stop it being in the main menu) was a settings template. Client needed access to it, but it had to remain hidden. 6) Loads of plugins (whether good or bad, the client knows they're available). And they haven't looked into how they are coded, and why would they? They think they can simply install it and get going (although the truth differs somewhat). 7) Images/docs uploaded per page, not centrally. I've never liked this so much, however there is a paid module for media. If there is a file download on two different pages, this is awkward for the user. They can't just open 'all docs' or something and just sling it in. 8) They think WP is free, as in, downtime after being hacked, decent plugins are paid, you need plugins to do things a proper CMS just has as standard... not so free really. Now I've really liked PW from the get go, but in reality, I can't see how I can avoid learning WP too. Literally all the web design jobs round here list the same requirements, HTML, PHP, CSS, JS/jQuery, Wordpress. I've spent a fair bit of time with PW and this really irks me. --EDIT-- So I just looked up how to make some basic custom fields, post types and custom menus in WP as a refresher. It made me sad. And made me think twice about going down that road.
-
Handy! Thanks @Peter Knight
-
Been meaning to come back to this as I wanted to try it out. Custom hooks and/or logic? Are there any examples of this floating about? Ok, don't know what a hook is so it's not a great start, but willing to learn. How about this for my idea: 1) User can either login or sign up n a little content block. Would need a create account like which would go to (a) a custom login form or (b) the standard admin login (not sure which) 2) Signs up, is redirected to site.com/my-profile 3) They can edit profile info, click save 4) Profile page is automagically created TREE: Home About Profiles - John Doe - Jane Doe Something like this? Then when they log in (in future) they are redirected to their profile page. Ok, so it's a bit naff, they can't actually do much. However, I really need to start making some more interactive things but I seem to be trapped in this void between brochure type sites (with one admin and one client) and more interactive sites (with automatic user creation etc.). Seems my problem is how to handle new users, and how they create content themselves. Do they use the admin tree? Or have a separate dashboard? So many questions. I guess experience will help to guide me eventually but right now I'm up the creek without a paddle. Wish I knew someone round here that used PW so I could see some real life setups in action, would make so much more sense.
-
Ah I see. Aha! I never knew this existed, found how to enable here: Gonna give it a whirl.
-
Yeah, it does actually. The screenshots I showed here are for ProcessWire 3.0.41. I just did a fresh install of ProcessWire 3.0.62 and CKEditor looks much better (plus ripped off your wonderful idea of putting the images next to the field...) ...and the RTE button insert image modal: The modal still looks different from your though. This is a fresh install, no AOS or anything.
-
Wow! Where has this been all my life
-
Thanks @Peter Knight I am aware of the module, not sure I need anything so fully featured though. I had a thought, the confusing thing for a user could simply be the actual presence of this field: They look at this and might think "what is the Images bit for?". In reality, this field does not need to be shown to the user at all. It could be hidden and when they inset image via RTE, this field would still be used but would work behind the scenes. However, I found a problem with this. If you set the field to closed: ...and insert an image via RTE, then choose 'Upload', it provides a choose file button: ...but, if you set the field to hidden: ...and insert an image via RTE, then choose 'Upload': ...it's blank. No way to actually upload the image. I thought you would still be able to upload an image even though it wasn't shown in the edit page.
-
Awesome, thanks @AndZyk
-
Nice. I like this approach, I tried similar but failed a while back, just couldn't get the desired HTML output. Will give it another shot with repeater matrix.