New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
alt. pageclass not honored by pagestype classes #1412
Comments
This can be circumvented by using |
Ok found one issue with that. It's not going to work for the current user obj $users->setPageClass($templates->get("user")->pageClass);
$uid = $user->id;
$pages->uncache($user);
wire('user', $users->get($uid)); |
Since User objects are managed by a PagesType class, and a PagesType class is designed just for an object of a specific class, that's what specifies the object type (rather than the template). So it's not currently designed for using different types of objects for something like User. Though it's likely possible and I can look into it further. Have you considered extending the User object with hooks instead? |
I have, but it has ended in unmaintainable bulks of hooking functions
|
I can certainly see you point with the PagesType class managing (currently) only a single type of page, but when using an alternative user template one might also want to use an alternative class for it (can prevent a damn lot of switch/ifelse statements). Additionally $users is a deep part of the processwire api, so I wouldn't want (and maybe even couldn't) add my own custom implementation. |
Do you know of any downsides when overwriting
|
Depends on how you mean to overwrite that part. |
I added
to the
|
Changing core classes directly is considered bad practice, because it'll break with the next update you're doing. Rather use the code I posted above and just set the pageClass to an empty string. |
Yes, that's right. But would adding this to the core break anything? Because if not, I'd like to create a pull request... |
You certainly could, but Ryan does not use pull-requests, therefore it'll probably have as much effect as giving this issue some attention. He already stated above that it was not intended to work that way initially. Also even if it wouldn't break anything, as long as there are only 2 people voting for a change (which you can do on your own) it's hardly a important topic. |
Can not find where to vote for a change, but I'm +1. |
When extending the User class with an custom one
$users
is stil loading pages as User objects.The text was updated successfully, but these errors were encountered: