Skip to main content
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 ...
MoritzLost's user avatar
  • 11.9k
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 “...
August Miller's user avatar
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 ...
August Miller's user avatar
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 ...
Tom De Smet's user avatar
  • 1,456
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 ...
MisterMike's user avatar
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.
Matt Stein's user avatar
  • 4,006
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 ...
Jamie Wade's user avatar
  • 3,644
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-...
Volker Andres's user avatar
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 ...
iamkeir's user avatar
  • 468
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 ...
Mats Mikkel Rummelhoff's user avatar
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 ...
cherrykoda's user avatar
  • 1,114
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 ...
Mats Mikkel Rummelhoff's user avatar
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 ...
Mats Mikkel Rummelhoff's user avatar
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
Jalen Davenport's user avatar
  • 3,045
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( ...
aodihis's user avatar
  • 801
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 ...
MoritzLost's user avatar
  • 11.9k
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->...
Robin Schambach's user avatar
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' %} ...
Redbloc's user avatar
  • 81
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 ...
Robin Schambach's user avatar
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 ...
Brad Bell's user avatar
  • 67.6k
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 ...
Brad Bell's user avatar
  • 67.6k
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 ...
Matt Rose's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible