Questions tagged [php]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
20 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
38 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
17 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
16 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
21 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
18 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
11 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
52 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
39 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
9 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
21 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
56 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
16 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
56 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
25 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
vote
1answer
23 views

How to exclude multiple email addresses from an order query

When doing an order query I want to omit results for 2 particular email addresses. It's easy enough to omit results for one address; $order = Order::find() ->isCompleted(true) ->email('...
0
votes
0answers
21 views

Inconsistency in Channel Section Type of Craft3

I'm trying to mess around the Entry URI Format and the Template trying to understand how it work. Using the News settings below, when I access the http://site.dev/news/save-our-seas, it's working fine ...
2
votes
2answers
25 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 ...
0
votes
0answers
14 views

Trying to get Git clone to run on local Map server

I have been trying to get a Git clone of my companies website running so we can make small changes locally and send it to the developer to save costs, but I can't get the website up and running. My ...
1
vote
1answer
27 views

Click counter for links (craft v2)

So I'm new to PHP and ok with Javascript. I have a page on my site with a long list of external links, would it be possible to add a counter to be displayed next to each link that shows how many times ...
1
vote
3answers
308 views

Programmatically add entries to an Entry field (craft\fields\Entries)

I work with Craft 3. I have an Entries field in a global set, I am able to get the global set, and then "read" this field programmatically (in a plugin) to fetch the entries that where added to it by ...
2
votes
1answer
55 views

How can I write a PHP script to zip and download an Assets subfolder?

I've searched everywhere but can't seem to get a straight answer. I want to write a php script to zip and download an entire subfolder in my assets directory. The subfolders are named based on a ...
1
vote
1answer
261 views

Undefined index: siteSettings when updating entry types

I'm receiving an Undefined index: siteSettings when trying to save changes to entry types (both new and existing). Of course, this is only occurring on a production server - local server with up-to-...
0
votes
0answers
43 views

How to save a product via PHP in Commerce 2?

I'm trying to save a new product with variants via PHP. $product = \Craft::$app->elements->createElement(\craft\commerce\elements\Product::class); $product->typeId = 1; $product->enabled =...
1
vote
2answers
1k views

ext-zip trouble

Issue: craftcms/cms 3.3.9 requires ext-zip * -> the requested PHP extension zip is missing from your system. Details: I am running on MAMP Pro 5.3. Currently using PHP 7.3.3 (but previous versions ...
2
votes
1answer
88 views

How does the Craft CMS built-in web server works?

I just found this while using ./craft help in the Craft CMS command line utilities: - serve Runs the PHP built-in web server. serve/index (default) ...
0
votes
0answers
48 views

Set redirect URL according to some conditions

I implemented an API and in one controller I need to open a webview for the user to enter some data from another site and then come back to my site. I am having trouble setting the redirect URL since ...
0
votes
0answers
12 views

Set the redirect url for a request from a plugin

I implemented an API for my Craft 2 site, One of the requests requires me to open a webview where the user can fill in some forms. What happens is that he enters some info from the app that will be ...
1
vote
1answer
139 views

Craft 3 plugin - how to update entry with field of Entries type

Using PHP, I want to update a field of Entries type of an existing entry. Fields of type Text and Number will update with the following code: $entry = Entry::find()->id($entryId)->one(); $...
2
votes
0answers
121 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
1answer
53 views

How to build a web page using different sections created in Craft

I am a beginner in Craft. I have a Craft website. There is an HTML design with me. From admin, I divided the HTML into sections and created entries based on that. All the coding related to each ...
1
vote
1answer
116 views

Custom Token Authentication with Craft 3 Login Form

I am building token auth system in Craft 3. https://docs.craftcms.com/v3/dev/examples/login-form.html I used this Login Form. Now I am going to create my own token and save it in user profile. First ...
1
vote
1answer
85 views

How to debug or log some special variables in Craft CMS? (Especially in a controller)

I am going to debug the variables in controller files. But I couldn't figure out how I can debug it and show the values into front-end site or in log files. Do you have any ideas about this? What ...
1
vote
1answer
106 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
1answer
90 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
1answer
36 views

Steps for integrating an HTML design to a website page and managing its content from backend

I am a beginner to Craft CMS. I have an HTML design for Craft integration. I need to covert this to a live URL page on my website. Also, I need to manage its content from the backend. I think we need ...
0
votes
0answers
38 views

Contact form plugin ajax submit URL not working

I am using contact form plugin for forms in my craft website. For avoiding page redirection, I followed ajax submit for the form, but it is not redirected to controller code. My form is as below:- ...
1
vote
1answer
103 views

How to pull an entry's SEOmatic meta tags with Element API?

How do I get the meta tags used in SEOmatic for a specific entry and returning it through the Element API? Not sure how the PHP code looks like when using SEOmatic's PHP API.
2
votes
1answer
53 views

Craft 2 FormBuilder 2 equivalent plugin in Craft 3

Is there any plugin equivalent to Craft 2 FormBuilder 2 plugin in Craft 3? My Craft 2 website forms are built with FormBuilder 2. I upgraded the website to Craft 3, but FormBuilder 2 is not working. I ...
2
votes
1answer
60 views

How to get current site (locale) api / plugin

For my form plugin I'm using a global set of fields. These can be set in 2 languages default and en. Problem is whenever I try to output them I cant dynamically make them use the current site locale/...
1
vote
1answer
136 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/...
0
votes
0answers
445 views

Craft can’t connect to the database with the credentials in craft/config/db.php

I'm trying to upgrade from 2.7.10 to Craft 3. I follow the instructions/ docs to the letter, go to https://###.com/admin and am greeted with the above can't connect to database message. So far, I ...
0
votes
0answers
30 views

Undefined property: DOMElement::$tagName HTMLPurifier

I got asked to edit the content on a website but whenever I edit an article and try to save it I get the following error: Undefined property: DOMElement::$tagName (/home/user/craft/app/framework/...
1
vote
0answers
55 views

Craft Commerce Adjuster API/PHP questions

I've got a module set up to add discounts based on criteria defined in a category group (handle 'productPacks') -> category (which is a "pack"). Now, everything works great for one type of pack, and ...
1
vote
1answer
143 views

Local DB SQL 'CDbException' Errors on Craft 2 site

Just tried to get a local site working again but getting all sorts of issues. I have updated the website online and downloaded the database, installed locally. I have also the craft/app folder to my ...
2
votes
2answers
196 views

Laravel Forge not honoring Craft 3 maxUploadFileSize config setting

I have a Craft 3 site deployed to a Digital Ocean droplet via Laravel Forge. I have the maxUploadFileSize set to 256B (268435456 in bytes) in my config/general.php like so: <?php return [ // ...
3
votes
2answers
967 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
0answers
52 views

Update asset index by PHP in Craft 3

In my plugin, I need to update asset indexes because it makes new asset folders. I found this question, but the answer is for Craft 2. How do you programmatically update an asset index? It does not ...
1
vote
1answer
48 views

PHP Login & Sessions without Craft Commerce?

I'm trying to implement this tutorial in my Craft CMS site, I've created all the files and they currently reside in public_html, but twig and the .htaccess of Craft CMS is interfering with it. Does ...
0
votes
0answers
411 views

MacOS 10.15 Beta and CraftCMS

i'm running a macOS 10.15 Beta (to check out SwiftUI) but now i'm running into problems with craft, specifically with the php zip extension. It's PHP 7.3.5 and i can't update it, because the install ...

1
2 3 4 5