New answers tagged

2

Searching against lightswitch should work. Make sure Use this field’s values as search keywords is checked in Settings → Fields → your field then run ./craft resave/entries --update-search-index to (re)index your values.


1

You'll need to do something like this. entry is a How to videos entry. {% set relatedProducts = entry.productsEntryField.all() %} {% if relatedProducts|length %} {% for product in relatedProducts %} <a href="{{ product.url }}">Click here to view</a> {% endfor %} {% endif %} The Craft docs on Entries Fields has more ...


0

Craft will store any temporary files it generates into storage/runtime/temp by default, but both Imagick and GD will also likely write to the system's temp folder (likely /tmp but could vary depending on OS and distro).


1

Anyone else who ends up here - I just got this error while updating a Craft 2 site to 3. I fixed it by running ./craft migrate/all. Looks like it works in the CLI but not the browser.


1

Craft's Project config is really made for updating changes from staging to production. When it comes to making changes across a fleet of (different) sites, you're somewhat on your own there. You might think of all of your sites as the same but Craft is thinking of each site independently because that's how it's designed. It sounds to me that one way to ...


1

Allright, after digging & debugging a bit further into this issue I found it out myself! $event->sender->addErrors([ 'expiryDate' => Template::raw('<a href='.$entry[0]->cpEditUrl.'>'.$entry[0]->title.'</a>') ]); PS: don't forget to add this to the top of your php file: use craft\helpers\Template;


0

I'd highly discourage this. We've seen large Craft sites in the half a million to million elements (users, entries, assets, tags, categories, etc.) range. But even those maxed out at 20-30 sites. Craft's multi-site was designed for sites that share a common information architecture and I'd say even 20-30 sites are pushing what the UI was designed for in the ...


1

It transpires that the problem actually relates to some seemingly undocumented behaviour of the {% exit %} call. When the ENVIRONMENT .env config is set to dev this appears to flush the buffer and terminate processing, but in staging or production mode, it appears to simply stop processing. (Even manually calling {% flush %} before {% exit %} doesn't appear ...


2

It looks like you're reinventing the wheel here: in Settings → General, you can toggle the site live/offline. When the site is offline, Craft serve the templates/503.twig templates, no matter which URL you hit. You can even configure users to have access to the site, when it's offline. To do so, go to the user edit page in the control panel and then to the ...


2

It looks like Craft is trying to delete a database field that has already been removed. I have no idea how you ended up in this situation but here's what I'd try to resolve the issue: first backup your database, in case something goes wrong! then execute the following command on your server, in the project directory. After each command, try removing you ...


2

Search via search() can be used only for text fields, if you want to search by categories or records you need to use the relatedTo() method, also do not forget to specify search keywords when creating the field. Links: https://craftcms.com/docs/3.x/relations.html#terminology, https://craftcms.com/docs/3.x/searching.html#supported-syntaxes. Practical example:...


2

You can't and it's a good thing. Your external JS file is meant to be static so it can be cached by the visitors' browser. One way to achieve what you want is to only define the addToMap() function in your external JS file and call this function from your template, passing it the locations to display. Here's how you can do this from your template: {% if ...


2

This was a bug and has now been fixed in Craft 3.5.12.1 https://github.com/craftcms/cms/issues/6923


2

Ok so with these the trick is to look for anything that might involve a request session, which is not available when you're running things via a console request. In this case there's at least one obvious suspect line: Craft::$app->session->setError('Lightspeed....); Indeed there's more than one of these. It's basically the same problem as previously - ...


1

I tried Fred Carsen's approach, but it didn't quite output what I expected. Here's my approach: // get categories $level1Categories = []; $level2Categories = []; $level3Categories = []; foreach ($product->productFamily->level(1)->all() as $category) { $level1Categories[] = $this->traverseCategory($category); } foreach ($product->...


2

You'll need to take: /config /modules (if there are any custom modules, but no harm in taking it anyway) /web /storage/rebrand (if you have rebranded the control panel) /templates /translations (if you have added any static translations) /vendor (unless you plan to run composer install on the new server) composer.json composer.lock craft (CLI) You can ...


1

Finally i got it. It was an issue with the .htaccess I had not a default installation .htaccess, but a special one. What helped in my case wa putting following into the .htaccess # Remove www from URL's RewriteCond %{HTTP_HOST} ^www\.(.+) RewriteRule ^ http%2://%3%{REQUEST_URI} [L,R=301] # Remove trailing slashes RewriteCond %{...


Top 50 recent answers are included