Questions tagged [yii]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
1 answer
33 views

evaluateDynamicContent() is disallowed

Bug while installing debug toolbar in Craft 4 latest version: An Error occurred while handling another error: yii\base\NotSupportedException: evaluateDynamicContent() is disallowed. in /craft/vendor/...
user3086053's user avatar
0 votes
0 answers
38 views

Prevent user email validation message showing twice In craft panel

When i enter same email which is already exist and click on save it is showing twice message. Can you please tell me it is craft cms's behavior? I have checked by disable custom modules and also ...
developer's user avatar
1 vote
2 answers
41 views

Help building a query with related to

I'm trying to create an or query with 2 related fields and 1 title field. My version so far is this: $searchQuery->where([ 'or', ['relatedTo', 'targetElement' => $ids, 'field' => '...
bartpulse's user avatar
4 votes
1 answer
997 views

Yii2 not maintained?

Craft is based on the PHP framework Yii2. I heard that this framework is less and less maintained. And yes, it seems to be the case if you go on contributor page : https://github.com/yiisoft/yii2/...
emilie zawadzki's user avatar
1 vote
1 answer
145 views

How to generate a token, retrieve it and delete it

I have a workflow were a user will be given a link, with a token attached to it, upon clicking that link, the token will be read from the query string, if it is valid the user will be presented a ...
Wally's user avatar
  • 343
0 votes
1 answer
764 views

Not instantiable – yii\di\NotInstantiableException when setting and reading cookies

Hello, within a craft template I query the existence of a cookie to visually highlight new entries in the CMS with CSS. This worked for a long time without any problems. A visitor told me that on ...
Andreas Ploch's user avatar
1 vote
1 answer
184 views

How to Extend Craft CMS frontend controller?

How to extend craft's front end controllers? I don't want to use twig. I like twig but I don't want to use it in craft. Respect my decision and help me. Is there a good way to do that?. So I can ...
user's user avatar
  • 63
2 votes
1 answer
3k views

Debugging with dump()/dd() within Twig templates

This feels like it falls under silly/obvious questions, but I can't seem to find a decent answer anywhere, so I'm asking here: How do I find out which methods for example, is available on an object? ...
InanisAtheos's user avatar
1 vote
1 answer
98 views

Sequential numbering from global field

I would like to add sequential numbering to each entry, which is obtained from a global field. After saving the entry, the global field should be assigned the next number (+1). Does anyone have any ...
nicbent's user avatar
  • 11
1 vote
0 answers
78 views

Building a yii query for Connect plugin

I'm using the Connect plugin by Andrew Welch to get some data from an external database. Somewhere in the data, I need data from another related table. The way I'm doing this now is like this: {% set ...
Bart Rylant's user avatar
1 vote
0 answers
105 views

Very slow `INSERT` transactions on the resourcepaths table

After a recent update (Craft 3.4.x to 3.5.x) I'm seeing some suspiciously slow response times in relation to INSERT actions on the resourcepaths table. Some in the upwards of a half second for a ...
Aaron Bushnell's user avatar
1 vote
2 answers
3k views

Twig json_decode gives Syntax Error

I'm trying to use the json_decode twig filter from Craft to decode an array of entry objects that got encoded in a macro. In the macro, the array of entry objects gets encoded by json_encode and ...
Joorren's user avatar
  • 305
1 vote
1 answer
98 views

Show dev mode and Yii toolbar on secondary site

I am unclear on how to turn on dev mode as well as the Yii toolbar when viewing a secondary site in Craft.
4midori's user avatar
  • 656
1 vote
1 answer
1k views

Nesting level too deep - recursive dependency?

I've got a page with a couple of levels of loops. It takes a section of speakers, groups them by state, and then loops through the states, and then loops through speakers in that state. It's not too ...
Jake Dohm's user avatar
  • 766
0 votes
0 answers
91 views

Yii2 2.0.31 in Homestead errors

I am getting the following error when trying to update Craft from 3.3.18.4 to 3.3.19 and any version after. It seems like Homestead or Vagrant is having some sort of issue with IpValidator or the ...
kayq's user avatar
  • 77
2 votes
2 answers
469 views

Is it possible to allow logging at LEVEL_INFO without logging all the SQL queries?

We're currently logging our site at LEVEL_INFO to have a good idea of what's happening on the site. We find it useful, and appropriate, to log informational messages at that level rather than at ERROR ...
Aaron Cimolini's user avatar
2 votes
2 answers
132 views

Combine AND and OR in a ElementQuery

I have a category with 2 levels. And I want to be able to let the user do a search based on those. The problem is that it needs to be AND between all level 1 categories, and OR within child categories....
peirix's user avatar
  • 431
2 votes
1 answer
241 views

Pass params to transform function of Transformer class in split Transformer class

I have transformer like down below in the element API. 'transformer' => 'MyTransformerClassName', Or 'transformer' => new MyTransformerClassName(), I am going to pass a param like $user ...
apollo's user avatar
  • 63
2 votes
0 answers
300 views

How to wire html template to twig extension? (Mainly `Twig\Error\SyntaxError: Unknown filter Error`)

I am going to use a Twig filter function by using Twig extension in my HTML file. I followed this guide. https://cameronspear.com/craft-cms-twig-filter-extension/ But when I run <p>{{ 123 | ...
apollo's user avatar
  • 63
1 vote
1 answer
285 views

Fetch Entries with Tags Only

I'm trying to get all the entries which have tags associated with them. At the moment I'm doing: $entries = Entry::find()->with('tags')->all(); and then filtering the results in PHP as ...
Alk's user avatar
  • 123
1 vote
1 answer
1k views

Select specific fields from query

I'm trying to get tags out of the underlying craft DB and serve it as a REST endpoint - however, I'm only interested in exposing the tag id and title, so my data should look like this: {id: 1, title:...
Alk's user avatar
  • 123
1 vote
1 answer
1k views

Custom module controller getView()->renderTemplate() path not working

Module loads and controller actions work. Craft 3.3.7. I'm trying to find out what is the path to use to render the view. From the Doc: return $this->renderTemplate('plugin-handle/path/to/...
Jessica Talzor's user avatar
1 vote
1 answer
419 views

Can access admin page (now), but not any site pages...yii not found http execption

Have not accessed my local .test sites in a bit. I tried today. I am getting a series of errors. At first I could not access any page to include the admin page. I ran Composer update from the ...
Hellyar's user avatar
  • 921
4 votes
2 answers
5k views

How to access HTML input values from Twig and vice versa

I am new to Craft and Twig in general. I have encountered the following problems and struggling to find a solution for hours. I want to access the value of "foo" input field inside the twig ...
ves's user avatar
  • 117
0 votes
1 answer
106 views

Fatal PHP error upon installation

I attempted to install the newest version of Craft and received this error in my logs: PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\craft-cms\vendor\yiisoft\yii2\...
syntaxanalyst's user avatar
2 votes
1 answer
905 views

PHP Fatal error during installation

I am trying to run craft inside a homestead box. The box boots and installs everything correctly, and when I navigate to http://localhost:8000/admin I see the install screen and can click through the ...
Ethan Davidson's user avatar
1 vote
2 answers
357 views

CraftCMS config on WTServer / WinNMP for Windows with Nginx

Has anyone had success with using Craft and WTServer (WinNMP) together? I'm getting a 400 error at "http://craft.test/index.php?p=admintrigger/actions/users/login" after trying to login the admin. I'm ...
Jim's user avatar
  • 139
4 votes
1 answer
1k views

Craft CMS V3 Create New User

Having difficulties creating a new user in a custom controller, here's my implementation: use craft\records\User; $user = new User; $user->firstName = $userData['firstName']; $user->lastName = ...
user3010455's user avatar
1 vote
1 answer
516 views

upgrade issue Yii Framework from version 2.0.15.1 to 2.0.16.1

I tried installing a site I developed on my work mac (high sierra), pushed to its repo, pulled it down at home on my mac (mojave)and on running composer update get this displayed in my terminal: ...
Kev N's user avatar
  • 151
1 vote
0 answers
87 views

Order entries by a matrix field category

I have a lot of trouble in understanding the database/model structure and how to work with the query builder. I tried playing a bit with leftJoins but i cannot seem to make complex queries in craft 3. ...
Dimitri van der Vliet's user avatar
2 votes
2 answers
243 views

How do I prevent a controller from creating unwanted routes?

I have a custom module that is adding sections to the CP, like this: // Register CP routes Event::on( UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES, function(craft\events\...
benface's user avatar
  • 226
1 vote
1 answer
1k views

Integrating Yii 2 modules and frontend widgets with Craft CMS 3

I'm experienced in Yii2 framework, but I just discovered Craft CMS and I already love it. I use to develop Yii 2 modules using their own DB tables, models, controllers and views. I usually use Yii ...
Alain Rollmann's user avatar
2 votes
1 answer
2k views

How do I create console commands for my module or plugin?

I would like to create a custom console command for my Craft 3 plugin. I've looked at the Yii docs and understand commands are defined using controllers extending \yii\console\Controller but cannot ...
Mike's user avatar
  • 277
1 vote
1 answer
222 views

Connect to an external database from a Craft 2.x plugin

I recently saw a very helpful post about how to connect to an external database from a Craft plugin and I wanted to confirm I understood the implementation correctly. On this response the author ...
Aaron Bushnell's user avatar
1 vote
1 answer
260 views

Craft Rules and Validation

Some of the changes in craft 3 have been killing me. I know Yii does validation using the public rules function. Here is a rules function I grabbed from the MatrixBlockType model. function rules() { ...
Mat Weaver's user avatar
1 vote
1 answer
203 views

where command sql query not working

My problem is that I can't update the specific $userId. have the values I've selected. I also get an error: Call to a member function where() on integer I just started to learn Craft. It can be ...
olifantT's user avatar
2 votes
1 answer
2k views

Craft 3 Element API Authentication/Login

First things first: This is quite similar to this, yet different. I'm trying to get authentication/login for Element-API for Craft 3 to work. Meaning I would like to restrict access to certain ...
Eternal Black's user avatar
1 vote
3 answers
902 views

400 error logging into local Craft 3 project

I have just tried to log into an old local Craft 3 project that hasn't been worked on in a few months and I'm getting the following: HTTP 400 – Bad Request – yii\web\BadRequestHttpException Unable ...
Jay's user avatar
  • 1,042
4 votes
2 answers
679 views

Craft 3 Custom Plugin: model validation

Struggling a bit here - have created a custom plugin where I want to validate form submission against a predefined model before saving to the database. All pretty straightforward so far … However, if ...
Cole Henley's user avatar
  • 1,741
2 votes
1 answer
455 views

Yii Modules in Craft, samples?

Does anybody know of a collection or library of Yii Modules online? I'm trying to understand how easy they can be moved from one application to another, are we going to see something similar to the ...
cballenar's user avatar
  • 1,409
1 vote
1 answer
249 views

Craft 3 icons not found in craftcms/cms/src/icons

Craft 3 version 3.0.4 When logging into the admin panel on Craft3 for some reason I'm getting a Yii2 PHP Warning for missing icons. Error message: PHP Warning – yii\base\ErrorException ...
Exziled's user avatar
  • 293
1 vote
0 answers
439 views

What are my caching options when using CraftQL and React?

I’m experimenting with the CraftQL plugin and React with Craft 3, and I’m really liking the similar syntax to standard Twig element queries, and the fact I don't need to manually configure API ...
Alex H's user avatar
  • 945
9 votes
3 answers
8k views

Craft 3: how to show the Yii Debug Toolbar?

I'm using Craft 3 RC and I am logged as an admin. How can I display the Yii debug toolbar on front-end and Control Panel requests? By default, I don't see this toolbar.
Romain P.'s user avatar
  • 1,818
5 votes
2 answers
2k views

Craft 3 404 and 503 pages in devMode

Is there any way to get Craft 3 to display 404.html and 503.html for the 404 and 503 pages while in devMode, as it did in Craft 2, rather than returning the entire Yii 2 error stack? Sometimes, we ...
Dustin C's user avatar
  • 379
1 vote
2 answers
190 views

Craft login problem with memcache and ubuntu?

session_regenerate_id(): Session object destruction failed is the error i'm receiving after attempting to log in. I just updated to Ubuntu 16.04LTS using PHP7 and php-memcached. Is there a fix for ...
Exziled's user avatar
  • 293
5 votes
2 answers
3k views

Craft 3 Plugin Routing Problems

So I am working on converting a previously-standalone Yii 2 app into a Craft module and am having some issues with routing. I wish to keep my old URL structure as much as possible. As such, I ...
Justin Cherniak's user avatar
1 vote
1 answer
150 views

Getting back after forwarding to another controller function

I want to assign a new user to a user group using a variable passed in the frontend registration form. I was going to listen for the OnSaveUser event but I don't think there's a way to get the ...
Clive Portman's user avatar
1 vote
1 answer
828 views

Joining two plugin tables by reference Id causes duplicates

I'm running a query in which I need to join two tables table_views and table_clicks. Both tables share several column names (mainly refId, month, year and total). However when I try and join these ...
Adam McCombs's user avatar
  • 1,695
2 votes
1 answer
83 views

Craft equivalent to Rails runner

The Rails cli has a runner feature that allows you to run a file (or a string of code) from the command line. E.g. rails runner my-script.rb (where my-script.rb will run in the context of a fully ...
Nick Tomlin's user avatar
1 vote
1 answer
333 views

Setting query offset

I need to batch process a set of data. To do this I am using the code below. I am trying to process 100 at a time, but the offset doesn't seem to work. It works the first time, but in the second ...
user2997606's user avatar