Jump to content

ProcessWire Cheatsheet


Soma

Recommended Posts

I scroll just because I forget what can be done with the API and sometimes it's handy if you can't think of what a particular function might be called (prime example was me looking for $page->images-getRandom() when images is just an array like most other things and I found it by scrolling through).

Link to comment
Share on other sites

I understand that, but since the content is scrollable, to me it feels more right to have the menu always there. Not very important though, the cheatsheet works great as it is :)

Link to comment
Share on other sites

I just updated the sheet.

- added fix to menu when scrolling

- moved some entries to advanced mode

- added toggle button on sections

- minor changes

Hope it still works well for you guys.

Link to comment
Share on other sites

There are two things that are bothering me. I think the + button would work better next to the title of the block instead of the bottom, and the animations feel to slow, I would say they aren't even necessary...

But this is getting greater and greater. Much better than a simple pdf for sure  :D

edit: I meant only the animations for the advanced items toggle. The animations on each individual items are ok

Link to comment
Share on other sites

The speed of the animations seems alright here, but I think it's going to depend on what computer and browser one is using. I'm generally indifferent about animations too. They seem nice here, but I'm not experiencing a slowdown either. If they are slow for lots of people, maybe better to get rid of them or whatever Soma thinks is best.

Animation or not, I just really like the functionality of being able to expand one section like this, as well as the "+" sign to do it. While I think visually it might fit nicely in the top and make closing easier, I also think it would be easier to miss at first glance. I like it at the end because it's very clear about what that "+" is for. If it were at the top of each section, people might think that it means "make sticky" or "open in new window" or something like that. Whereas at the end of the list, the placement context becomes part of the message – its hard to confuse it with anything other than "show more". But ultimately I love the functionality of it regardless of where it's placed.

Link to comment
Share on other sites

Yeah, I'll make the animation of the advanced toggle faster, just simply forgot about it to make it as fast as the other slide animations. Thanks fro mention it diogo.

I'm pretty much with ryan here, after all I think it does fit better on bottom of the list.

Link to comment
Share on other sites

  • 5 months later...

This was one of the resources that as soon as I looked at it, it kicked me from a looker to a doer with PW. Fantastic resource Soma. Thanks.

I have worked with many CMS's and clarity (good clean documentation) is a very crucial aspect to get people involved and to stay with a project. I give 5 out of 5 stars to PW for this. I look forward to helping where I can.

  • Like 3
Link to comment
Share on other sites

Hey Jeff, thanks for the nice words. I agree with you here. ProcessWire aim is to keep things simple and I enjoyed contributing to it with this nice little resource. Hope you enjoy your stay ;)

Link to comment
Share on other sites

Just wanted to mention that I added $input->urlSegments to the sheet. Along with some code cleanup.

I also added the possibility to link and tigger the filter/search on the sheet.

Examples:

http://processwire.c...ter=urlsegments

You can set the advanced mode with &advanced.

http://processwire.c...gments

It also supports hashes

processwire.com/api/cheatsheet/#input

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

Hi Soma, maybe i'm overlooking something but $page->sort seems to be missing from the cheatsheet. This one maps to the integer sort value present in the pages table. Sometimes it can be useful.

Link to comment
Share on other sites

Thanks sinnut for the report. It's not there because it's also not on API docs. But will gladly add it.

I'm not sure why it's missing in the docs, is there any reason Ryan?

Edit: well my guess is that is is not really reliable.

Link to comment
Share on other sites

I think I found a small error in the Cheatsheet.

$session->login($name, $pass)

returns a user, not just boolean true, so

$user = $session->login($name, $pass);
if($user) {
// login successful
if($user->hasRole('customer')){
	$session->redirect("/customers/");
} elseif($user->hasRole('staff')){
	$session->redirect("/staff/");
}
}

works, while this

if($user = $session->login($name, $pass)) {
// login successful
if($user->hasRole('customer')){
...snip...

doesn't.

Link to comment
Share on other sites

Thanks Dave for the report. Yes it returns the user. Well it's like this on http://processwire.c...iables/session/ that's from where the cheatsheet has its content originally. :)

So it's wrong there already or Ryan changed it and forgot to change it in the docs.

Anyway your code example both works... Not sure why it wouldn't work. If returned something else than null, false, 0 etc. it will be true even if it's a object... If conditions doesn't require to be "true" to work.

if($loggeduser = $session->login($username, $pass)) {
// if logged in succesful
echo $loggeduser->name;
} else {
  // failed
}
Link to comment
Share on other sites

The trouble was, the second example produced a 'Property of a non-object' type error at the line

if($user->hasRole('customer')){

so, in my case at least, the $user object wasn't being fully set for some reason. It was only when I explicitly set $user (as in the first example) that it worked. Don't know why, can't imagine it's to do with server config or anything.

Link to comment
Share on other sites

Your 2 examples are the same, so I don't understand what's going on on your side. BTW I recommend not using "$user" variable as it is a template variable which holds the current user so you overwrite it, but it should work anyway.

Link to comment
Share on other sites

  • 3 weeks later...

I've been working for some time on an updated version to functionality of the cheatsheet and have commited it now. All code and functionality, no content changes.

  • removed table layout and added the excellent Masonry/Istope js for block layout and filtering
  • added setting for column count so you can change it to your best fit in the toolbar
  • improved live search, especially in Firefox (which wasn't really working before)
  • now sections not containing any filter results will be hidden (not get in the way anymore)

These changes also will help adding more content to the sheet. Preparing to launch the rocket! :)

Enjoy.

  • Like 3
Link to comment
Share on other sites

Nice updates, my only thoughts are when opening some elements it switches some blocks to different columns - I guess this is simply to keep the column lengths more or less the same length? Is there any way to turn that off as I'm not sure the animation/reordering is necessary and could be a bit confusing even if you use the cheatsheet so much you know things are supposed to be in a certain column.

Certainly not a big/important issue ;)

Link to comment
Share on other sites

Thanks for the feedback. Yes I know, but I don't know a way to turn it off because it's doing what it's supposed to :D Well it doesn't happen often, so I can live with it. One way to get around it would be to make the description hover. I tried something but there's some issues with indexes and would complicate things or would have to add another tooltip like functionality. But got so used to the toggle slide and like it so far.

Link to comment
Share on other sites

Don't know why, but the new version looks really wierd and behaves glitchy in Firefox 13.0.1 for me. Works great in Chrome though. Can anybody else see this things or I see things? :huh:

Link to comment
Share on other sites

Don't know why, but the new version looks really wierd and behaves glitchy in Firefox 13.0.1 for me. Works great in Chrome though. Can anybody else see this things or I see things? :huh:

Have you deleted cache and maybe cookies? Looks and works fine here. What OS?

Link to comment
Share on other sites

Yep. It was cache. I thought I had it disabled. Great work, Soma! This became an indispensable tool for me! Thank you!

+1 to ditch animation in favour of speed and simplicity :) Or maybe make it quiker and more subtle. What do you think, guys?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...