Questions tagged [php]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
1answer
56 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/...
0
votes
0answers
20 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 ...
1
vote
1answer
126 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-...
1
vote
2answers
457 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 ...
2
votes
2answers
20 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
12 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
23 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
1answer
266 views

Getting PHP Error on upgrade from 3.0.36 to 3.1

I just updated to 3.1 and I'm getting the php error: PHP Notice – yii\base\ErrorException Undefined index: settings It probably has to do with the Cheat Sheet plugin. I deleted that folder in the ...
1
vote
3answers
1k views

Security Headers in htaccess Don't Work

We have an issue on our server when our Security Headers are not working. We added the following to our htaccess file after installing Craft CMS: - <IfModule mod_headers.c> Header always ...
1
vote
3answers
129 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
47 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 ...
0
votes
0answers
28 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
1answer
41 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
45 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 ...
2
votes
1answer
64 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) ...
4
votes
3answers
733 views

How do I “register” a service in a Craft 3 plugin?

In Craft 2, services were auto-loaded when using the craft()->plugin_serviceName->myMethodName() signature, but it seems like there's a catch in Craft 3, when using the new MyPlugin::getInstance(...
0
votes
0answers
36 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
11 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
64 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
96 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
72 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
67 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
28 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 ...
1
vote
1answer
51 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
93 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 ...
0
votes
0answers
33 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
74 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
43 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 ...
1
vote
1answer
88 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
222 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
27 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/...
4
votes
2answers
836 views

Twig Filter in Plugin/PHP?

Is it possible to access twig filters in a plugin? I want to be able to preview how text will look in a textarea using Markdown for a discussion board, it'd be awesome to use ajax to send the content ...
1
vote
0answers
52 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
93 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
124 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
740 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 ...
1
vote
1answer
1k views

Craft CMS login 500 (Internal Server Error)

I transferred a website using Craft CMS and now when I want login to admin the console return me jquery-2.2.1.min.js?d=1493126871:4 POST http://website.com/index.php/admin/actions/users/login 500 (...
0
votes
0answers
37 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 ...
0
votes
0answers
372 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
vote
1answer
63 views

User query in PHP does not work

I would like to get user query in my custom PHP plugin. According to this document, the code would be like this. https://docs.craftcms.com/v3/dev/element-queries/user-queries.html#example $...
1
vote
2answers
68 views

Prevent EVENT_BEFORE_VALIDATE in specific case

I have a registration form and its custom validation in PHP plugin code. However, the validation works when user set a new password. I supposed that $event->isNew is good to detect if it is a new ...
1
vote
1answer
50 views

Get radio button's value from a form by PHP

I have been developing validations for my form. It is possible to get text input's value like; $password = Craft::$app->request->getBodyParam('password'); However, this function seems not to ...
1
vote
1answer
22 views

Detect if it is a new user or not in PHP

I have been developing some plugin code for my registration form in Craft 3. The event will be EVENT_AFTER_SAVE_ELEMENT, but I do not know how to detect if it is a new user or not. In Craft 2, the ...
3
votes
1answer
158 views

How can I get tasks to complete when not logged in to the CP?

I've noticed that tasks only run when logged into the admin panel, is there anyway to avoid this? For some context: I have jobs scheduled on a cron to run every 30 minutes, when I log in it seems ...
1
vote
2answers
100 views

Rename Assets when it is uploaded

I would like to rename new assets by PHP, but somehow it does not work. In Craft 3, I suppose it is like; Event::on(\craft\services\Elements::class, \craft\services\Elements::EVENT_AFTER_SAVE_ELEMENT,...
0
votes
1answer
41 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
1answer
307 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 ...
2
votes
1answer
47 views

Create Matrix Block via Module

I'm having an issue creating a matrix block from a module. I'm currently doing the following: Calling an API using Guzzle Getting that request and iterating over a media block. Trying to create a new ...
0
votes
0answers
38 views

Craft CMS: Goes Unresponsive

I have an issue with the Craft3, after a few requests and clicking around the whole site (front-end and CP Admin) seems to hand and lag. Also I get a popup message on Google Chrome mentioning that ...
1
vote
2answers
242 views

Simple Module in Craft CMS 3

How do I create a simple module for one website in Craft?. I don't have much experience in Craft CMS. I have tried from 3 days but I cannot get an answer. I'm following all the tutorials that I can ...

1
2 3 4 5