6
votes
Customize Client to distinguish client from agency
A good way to have different rules apply to different users are User Groups. You can create one user group for regular clients and one for your agency clients. Then you can offer different prices and ...
3
votes
Accepted
Craft 4 Building a Plugin not saving all properties
Craft automatically sets values from the incoming POST data on your Settings model, which means the input name attributes must match exactly (or that the Settings model must expose an appropriate “...
3
votes
Cannot pass where Params to query with Twig variable
You may be overthinking this! It's pretty rare that you'll need to reach directly for the ActiveQuery where, orWhere, and andWhere methods—unless I've misunderstood what kind of results you're going ...
2
votes
Separate User Groups / forms
Why do you want to let them register twice? Maybe re-think the way you go about this:
Possible solutions:
Add them to a certain user group (via a plugin) on registration with the appropriate ...
2
votes
How do I add class to redactor format list?
This works in Craft 3.0 (tested with Craft 3.7.12) - what you get is a menu entry in the formatting menu - the selected paragraph then gets the class "redactor". You put it in your config ...
2
votes
Can we define routes (non-CP) in plugins?
In Craft 3, you can accomplish this by hooking into the UrlManager::EVENT_REGISTER_SITE_URL_RULES event.
2
votes
Custom Clickable Image
Whilst this mainly seems like a front-end development question, and Dr_Codswallop has perfectly summed up some steps in the comments to tackle that, as an answer for the Craft CMS specific side of the ...
2
votes
CraftCMS Commerce order by most sold products
Here is a simple start. It builds a query, which goes into the commerce lineitems table, groups the rows by purchasableId and gives the top 20 counts. Be aware, that the result consists of Variants-...
2
votes
Accepted
How to run custom module controller actions from console?
Fixed this - was due to a couple of issues with this line:
if (Craft::$app->getRequest()->getIsConsoleRequest()) {
$this->controllerNamespace = 'custom-module\\console\\controllers';
}
My ...
2
votes
Accepted
Cannot pass where Params to query with Twig variable
Guessing the issue is that your whereParams variable is actually a string, brackets and all – not an array. So, you'll just need to make sure that it's an actual array instead.
The good news is that ...
2
votes
It's possible to display "User" menu history like "Entries" menu history on admin dashboard
For something like the Entries widget, you'll need to code your own custom widget. There's instructions you can dig into here:
https://craftcms.com/docs/4.x/extend/widget-types.html
The queries you'll ...
2
votes
Accepted
Custom module controller: how to impersonate any user and start its session
Technically, there is no real "impersonation" in Craft. All the "impersonate" action in the CP does, is to log in the currently logged-in user as a different user; albeit with some ...
1
vote
Accepted
CKEditor and building custom links
When inserting a link, CKEditor gives you the option between selecting an element (for example, an entry or category), or entering a URL manually.
Your users will be able to create links in the above ...
1
vote
How to access craft custom variable from PHP
Because MyVar is a service, the easiest solution is to just access it the same way you'd access any other service, e.g.:
$whatever = MyModule::getInstance()->myVar->whatever
1
vote
How to add Field to Template hook cp.entries.edit.settings and save value to entry?
There are several way to to this, here is one of them that I preferred.
First, create a custom bahavior by hook into entry event define behavior, register you class, here is the hook code.
Event::on(
...
1
vote
Possibility to create / link custom (global) variables to shortcuts
There's no blanket solution for this, there are many options to providing reusable snippets, variables etc. As a rule of thumb, only use abstractions like this if you're gonna need them in more than ...
1
vote
Updating craft user fields from plugin
To Create a user do
$request = Craft::$app->getRequest();
$user = new User();
$user->username = $request->getBodyParam('username');
$user->email = $request->...
1
vote
Displaying entries from a specific custom date year
I ended up using this code.
{% set upcoming = craft.entries.section('section').order('customDate')%}
{% for entry in upcoming %}
{% if entry.customDate =='2018-10-12' %}
...
1
vote
Custom Pluging Entries FieldType
You can use a Relation Field for each of your element types and include a custom js rule so if one of them has a value, the other one can't be selected.
The more difficult way would be to extend the ...
1
vote
How do I add a tab to my home page
The front-end of a Craft site is 100% custom and leaves you with complete control over the HTML, CSS, JS and images that are generated, so there's really no way for us to give you step-by-step ...
1
vote
no element type exists with getCriteria and custom element type
As Stephen pointed out, you're getting that error because your Commerce_GroupModel class is a Model that extends BaseModel, not an Element Type, which is what ElementsService->getCriteria() is ...
1
vote
Using getCriteria with a custom element type
Fixed it for now by including a custom enum class in the base plugin file:
abstract class CustomElementType extends BaseEnum
{
const Badges_Badge = 'Badges_Badge';
}
and then querying for ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
custom × 37plugin-development × 9
templating × 4
craft3 × 3
entries × 3
modules × 3
sorting × 3
plugin-craftcommerce × 2
users × 2
entry × 2
field × 2
redactor × 2
image × 2
elementcriteriamodel × 2
admin × 2
controller × 2
craft4 × 2
plugins × 1
categories × 1
form × 1
url × 1
structure × 1
config × 1
datetime × 1
routes × 1