Questions tagged [yii]
The yii tag has no usage guidance.
55
questions
0
votes
0
answers
26
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?
1
vote
2
answers
29
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' => '...
4
votes
1
answer
833
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/...
1
vote
1
answer
98
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 ...
0
votes
1
answer
548
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 ...
1
vote
1
answer
163
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 ...
2
votes
1
answer
2k
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? ...
1
vote
1
answer
88
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 ...
1
vote
0
answers
68
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 ...
1
vote
0
answers
96
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 ...
1
vote
2
answers
2k
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 ...
1
vote
1
answer
75
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.
1
vote
1
answer
919
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 ...
0
votes
0
answers
90
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 ...
2
votes
2
answers
376
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 ...
2
votes
2
answers
126
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....
2
votes
1
answer
199
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 ...
2
votes
0
answers
282
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 | ...
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 ...
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:...
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/...
1
vote
1
answer
382
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 ...
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 ...
0
votes
1
answer
95
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\...
2
votes
1
answer
817
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 ...
1
vote
2
answers
340
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 ...
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 = ...
1
vote
1
answer
499
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:
...
1
vote
0
answers
83
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. ...
2
votes
2
answers
233
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\...
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 ...
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 ...
1
vote
1
answer
215
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 ...
1
vote
1
answer
253
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()
{
...
1
vote
1
answer
191
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 ...
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 ...
1
vote
3
answers
878
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 ...
4
votes
2
answers
646
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 ...
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 ...
1
vote
1
answer
241
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
...
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 ...
9
votes
3
answers
7k
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.
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 ...
1
vote
2
answers
189
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 ...
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 ...
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 ...
1
vote
1
answer
807
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 ...
2
votes
1
answer
79
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 ...
1
vote
1
answer
326
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 ...
1
vote
1
answer
616
views
CraftCMS 3 - Composer Update
How can I update all the packages under craft/app/vendor for Craft CMS 3 (Yii 2)?