Questions tagged [php]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3
votes
1answer
57 views

Update from 3.3.4.1 to 3.6.11.2 advice

What is the best way to do this? I also have a number of plugins that all need updating from the same time period. I don't think any of the breaking changes affect anything I've done, but I wonder/...
2
votes
1answer
29 views

Force craft to do another job (queue) and pause the current one

I'm currently working on a plug-in for Craft. I have to work with a lot of data and, some steps are slow. So that's why I added them to a job system. This job is doing a lot of stuff. That job is ...
0
votes
0answers
8 views

Echo locale title in controller (craft cms 2)

I want to echo the translated title of an entry in the controller of a plugin. How can i acces the locale data?
0
votes
0answers
34 views

How can I get field values for the sections that I created

New to Craft CMS. We decided to make Craft headless and have an api fetch the data. I have 5 (simple) sections that represent 5 pages and they all have some fields in them with some texts or images. ...
0
votes
0answers
15 views

How to programatically (e.g. in a custom a plugin) create a Discount Code? (Craft Commerce)

I've been working on some custom plugins recently to handle various bits of API functionality for the project I'm working on, and I'm now roughly familiar with Craft's OO approach to carrying out this ...
0
votes
0answers
21 views

Has anyone experienced any cURL error 28: timeout errors using php 7.4 and craft 3.5?

So the site was working on a new server. But over night I am now seeing the site hang and not load. When it does give an error it gives a cURL error 28 with connection timed out on various resources ...
1
vote
1answer
39 views

Trouble running craft with docker

I'm trying to set up craft to run with the docker images provided here. When I run docker-compose build, it gets through a few lines in the Dockerfile and then stops with an invalid reference error ...
0
votes
0answers
17 views

Using Element API to pull child categories

On Craft, I can assign categories to my different customers: a customer might be "Cloud", "Software" or "Energy". I have set it up so that you can also choose ...
0
votes
0answers
27 views

How to develop API with TWIG

I want to develop an API within Twig template that will have PDO implementation to get data. My application will be using content through CRAFT. Is it possible to develop API with TWIG template? ...
1
vote
1answer
45 views

Issue on new craft (craftcms3) setups: vendor Twig can't read system variable

After installing craft through composer, setting up the database and running craft setup, I have a craft application ready to go. When I go to settings/general, I always get a crash with following ...
2
votes
1answer
35 views

Use of App::env() compared to getenv() since Craft 3.4.18

I've noticed since Craft 3.4.18 there is a App::env() function from craft\helpers\App::env(). This was created from the discussion here it seems: https://github.com/craftcms/cms/pull/5893 It seems ...
1
vote
1answer
25 views

How to get all Element Types?

From within a plugin/module using PHP; is there a way to query all element types being used, including custom elements? I know in the elements database table there is a type column that I could ...
1
vote
2answers
239 views

mkdir(): Permission denied

I have an old craft 2 installation. When I want to go to the frontend I get: mkdir(): Permission denied 745 { 746 if ($permissions == null) 747 { 748 $permissions = ...
0
votes
0answers
34 views

Using PHP 7.4 on Laravel Forge, the storage folder has a permissions issue

Standard Craft install on Laravel Forge with PHP 7.4 installed. The storage folder is marked as unwritable so the site won't load. Switching back to PHP 7.3 fixes instantly. I think it's related to ...
1
vote
1answer
49 views

PHP error when trying to access dates in Sprout Reports

Basic Sprout Report here, settings page: {{ forms.dateTimeField({ label: "Start Date"|t, instructions: "The start date of the date range you wish to display in your report."|t, ...
0
votes
0answers
35 views

Add matrix block content to newly created Entry

Help. I feel this is almost basic and many have asked similar questions, but I cannot get this to work. I have an entry type which amongst other things has a Matrix field ph_selectorViews, which has ...
4
votes
1answer
88 views

Is there a way to compare what has changed on an entry while it's being saved?

I'm taking my first baby steps into the php side of Craft, and my php experience in general is extremely fledgling. But I'm pretty much forced to create a module for a project I have, so here I am ...
1
vote
1answer
91 views

Get a key value from a JSON asset in PHP

I'm using the Apple News plugin to try and display a tweet that's been added as a JSON asset in a matrix field. The JSON looks something like this { "title": "https://twitter.com/...
1
vote
1answer
14 views

How do entry elements render a default string but also return an object at the same time?

So this is more of a PHP question than a Craft question, but the only example I can offer is one I've seen in Craft. {{ craft.entries.id(4).one() }} Returns a simple string like: "About Page"...
1
vote
1answer
52 views

Why does Bootup.php run with PHP 5.4.16 from with Craft script but PHP 7.4.10 from the terminal command line?

This is a problem encountered apparently by a lot of users when installing from the Craft setup/install files from the Craft web site. PHP Warning: Unsupported declare 'strict_types' in /var/craft/...
1
vote
1answer
25 views

LineItems not showing in CMS

I'm scratching my head. My orders are shown perfectly except for one product. I have no idea why so I looked at the Order object before saving and I can't seem to figure out why he won't show the ...
1
vote
2answers
144 views

Site moved to new server - Error 500

I inherited a site running craft and I was asked to move it to my server to host it. The other developer zipped the files and made a database dump for me. Usually, when I move a site, they have Cpanel ...
2
votes
1answer
231 views

Craft Nitro PHP extension ext-zip * is missing

I'm not particularly tech minded so MAMP has served me well for a good while. However I more recently decided to give Craft Nitro a try. I got everything (Multipass and Nitro) set up really easy. I ...
0
votes
0answers
29 views

Website Stuck on Load after few requests

I'm facing a weird issue here. I'm developing a CraftCMS based website and all seem to be working fine, until after a few requests (clicking around 4 ~ 5 requests) the website seem to keep loading and ...
1
vote
1answer
40 views

Updates always error out

Every time I try to run an update, I get these errors. Installing plugins won't work either. I'm using Media Temple / Grid server hosting. I've increased the file size limits in php.ini as well. But I'...
1
vote
1answer
49 views

Put SEO and Twitter card Meta tags in the Head section prior the render of the template

I need to put some <meta /> tags in the <head /> section of the html document prior the rendering of the template. I would like to know how can I achieve this? I also need to query an ...
0
votes
0answers
46 views

How can I add data to a matrix field from a module without overwriting existing data?

I have an entry that has a matrix field. From a controller in a module I want to add additional data to it (e.g. some text that I have in a variable $messageText) but without overwriting the existing ...
1
vote
1answer
41 views

Error when trying to update Craft

I'm pretty new to CraftCMS and am trying to install updates for a client. I am getting this error and I don't really know what it means. Any help of brief explanation for this would be appreciated. ...
0
votes
0answers
24 views

How to get a few category groups in a single endpoint using Element API plugin?

I have many category groups and want to get some of them using single endpoint. Is it possible? If so, how? Code like this return only one group: 'api/header.json' => function() { $...
1
vote
1answer
1k views

The requested URL was not found on this server. Apache/2.4.18 (Ubuntu) Server at localhost Port 80

The frontend just work fine. But when I call the backend http://localhost/craft3/web/admin/dashboard/ or http://localhost/craft3/web/admin/ I get the error requested URL was not found on this server. ...
1
vote
1answer
27 views

Setting relative path to ElementAPI in PHP

I need a few small bits of data from Craft in a PHP file. It’s a really small task, so I don’t want to delve into writing plugins or anything hardcore. It seemed to me the simplest way to approach it ...
2
votes
1answer
77 views

Get currentSite.handle in Element API

I need to get the currentSite in Element API. How can this be achieved? Is it as a slug in the endpoint URL? or as a Query param? Here is the current code: <?php use craft\elements\Entry; use ...
0
votes
0answers
65 views

How to load more entries of a category on that category's page with Element API?

Following up on previous questions of mine: How to use multiple different instances Element API "Load More" button? I have a website that utilizes the "load More" (button) method ...
1
vote
1answer
55 views

How to use multiple different instances Element API “Load More” button?

Following up on a previous question of mine: How to skip the first few entries in a "load more" scenario with Element API? I have a website that utilizes the "load More" (button) ...
1
vote
1answer
39 views

How to skip the first few entries in a “load more” scenario with Element API?

I have a website that uses a "load more" button. The process for this button can be found here: http://craftsnippets.com/articles/infinite-scrolling-and-lazy-loading-with-craft-cms I made it ...
1
vote
1answer
72 views

Change php.ini to max execution 120

I found the php.ini file, but I don't see where to change max execution to 120. Thank you for your support.
1
vote
2answers
49 views

How to use entry data?

My question: How can I use entry data in the craft backend? An example for the use-case: Author creates an entry for the section "Generate item". The entry has only a title/single word. ...
1
vote
1answer
45 views

How to auto enable a plugin after install?

I am developing a plugin for craft 3 and the plugin just got published to the store. I can browse through the store and install the plugin but it stays disabled. The user will have to goto Settings -&...
1
vote
1answer
60 views

Controller redirect not working in craft 3

I am working with Craft 3 and in my controller, I am trying to do this $this->redirect('https://foobar.test'); But it is throwing me back to the root url of my craft site. I am confused, what else ...
1
vote
1answer
35 views

How to get my craft projectConfig settings inside JS on the front end

So I am trying to work with twig templates and I want to inject my project configuration in my js so I can use it. I can do this {% set admin_email = craft.app.projectConfig.get.email.fromEmail %} ...
1
vote
1answer
200 views

Register custom REST routes while building a plugin for Craft 3

I am building a custom plugin for Craft and I am hitting some REST APIs in my backend service to fetch some data using Ajax calls in JS. What I would like to do when the AJAX calls complete and come ...
0
votes
0answers
324 views

Error:unable to open using mode r:fopen() :filename cannot be empty(1) [duplicate]

This is my problem please give me solution My process is in this url http://solution.ap-south-1.elasticbeanstalk.com/solutionpage.php
1
vote
1answer
140 views

Work with data/content from entries

I'm usually working on Backends with PHP and ZF/Laminas. Now I'm building a headless (only Backend) Craft CMS website and have a couple of questions that I didn't find a clear answer on. The Craft ...
1
vote
3answers
70 views

How to add content to pages using a plugin?

I am developing a plugin for Craft 3. And I am trying to add some content to all pages in the CMS using this plugin. How can I do that? Is there a method or class call I can use for this? I am not ...
1
vote
1answer
132 views

Images not showing even after bundling them with asset bundle

So I am trying to build a simple plugin for Craft CMS and I am wish to use my assets in the twig template like css, js, images etc. From what I have read and understood from Asset Bundles, I have ...
1
vote
1answer
46 views

How to use assets while building Craft CMS plugins?

I am trying to build a basic plugin, when installed has a single nav bar item, and of course a twig template which shows up on clicking on that navbar item. I have used the basic template to extend ...
0
votes
0answers
67 views

Date Field Validation by PHP plugin

I have a form for updating user info, with a field of birth date. However, I am struggling to develop a validation for this date field by PHP. Its frontend code is this; {% set tz = craft.app....
0
votes
0answers
69 views

How to add new Matrix block to entry field in php?

$draft = new Drafts(); var_dump($entry->slug); $draftEntry = Entry::find()->slug($entry->slug)->one(); $draftEntry->typeId = 32; ...
1
vote
3answers
73 views

Craft v3 gives 500 error on installation… how to get v2 instead

I installed Craft v3 on a live server running Debian 10, apache, latest PHP, and Mariadb. My structure is /var/www/html, and everything except for the files in "web" are in the www folder (along with ...
1
vote
2answers
39 views

How to call abstract method from interface

I would like to use a method of fileExists. It belongs to VolumeInterface. https://docs.craftcms.com/api/v3/craft-base-volumeinterface.html I suppose the code would be like \craft\base\Volume::...

1
2 3 4 5 6