texts: CP not loading on Forge Server with PHP 7

texts:
I uploaded a working install of Craft Pro 2.5.2754 to a brand new Laravel Forge server and I'm having issues with the control panel. More precisely, it returns an error 500 when I try to access it.

The PHP version is PHP 7.0.0-4+deb.sury.org~trusty+1 and it's the default config of Forge.

I have a config array in craft/config/general.php that looks like this :

$data['dev.domain.com']  =   [
    'appId'                 => 'choiStage',
    //'cacheMethod'           => 'memcache',
    'devMode'               => true,
    'phpMaxMemoryLimit'     => '512M',
    'cpTrigger'             => 'craft',

    'backupDbOnUpdate'      => true,
    'usePathInfo'           => true,
    'omitScriptNameInUrls'  => true,
    'enableCsrfProtection'  => false,
];
return $data;

When I access the control panel located at /craft I get an error 500.

When I have a look at craft/storage/runtime/log/craft.log there is this message :

    ******************************************************************************************************
2015/12/09 15:42:38 [error] [exception.Error] Error: Class 'Twig_Cache_Filesystem' not found in /home/forge/staging.domain.com/releases/20151209154140/craft/app/vendor/twig/twig/lib/Twig/Environment.php:263
Stack trace:
#0 /home/forge/staging.domain.com/releases/20151209154140/craft/app/vendor/twig/twig/lib/Twig/Environment.php(115): Twig_Environment->setCache('/home/forge/cho...')
#1 /home/forge/staging.domain.com/releases/20151209154140/craft/app/services/TemplatesService.php(147): Twig_Environment->__construct(Object(Craft\TemplateLoader), Array)
#2 /home/forge/staging.domain.com/releases/20151209154140/craft/app/services/TemplatesService.php(221): Craft\TemplatesService->getTwig()
#3 /home/forge/staging.domain.com/releases/20151209154140/craft/app/controllers/BaseController.php(74): Craft\TemplatesService->render('login', Array)
#4 /home/forge/staging.domain.com/releases/20151209154140/craft/app/controllers/TemplatesController.php(55): Craft\BaseController->renderTemplate('login', Array)
#5 [internal function]: Craft\TemplatesController->actionRender('login', Array)
#6 /home/forge/staging.domain.com/releases/20151209154140/craft/app/framework/web/actions/CAction.php(109): ReflectionMethod->invokeArgs(Object(Craft\TemplatesController), Array)
#7 /home/forge/staging.domain.com/releases/20151209154140/craft/app/framework/web/actions/CInlineAction.php(47): CAction->runWithParamsInternal(Object(Craft\TemplatesController), Object(ReflectionMethod), Array)
#8 /home/forge/staging.domain.com/releases/20151209154140/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(Array)
#9 /home/forge/staging.domain.com/releases/20151209154140/craft/app/framework/web/CController.php(286): CController->runAction(Object(CInlineAction))
#10 /home/forge/staging.domain.com/releases/20151209154140/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#11 /home/forge/staging.domain.com/releases/20151209154140/craft/app/framework/web/CWebApplication.php(282): CController->run('render')
#12 /home/forge/staging.domain.com/releases/20151209154140/craft/app/framework/web/CWebApplication.php(141): CWebApplication->runController('templates/rende...')
#13 /home/forge/staging.domain.com/releases/20151209154140/craft/app/etc/web/WebApp.php(284): CWebApplication->processRequest()
#14 /home/forge/staging.domain.com/releases/20151209154140/craft/app/framework/base/CApplication.php(184): Craft\WebApp->processRequest()
#15 /home/forge/staging.domain.com/releases/20151209154140/craft/app/index.php(62): CApplication->run()
#16 /home/forge/staging.domain.com/releases/20151209154140/public/index.php(19): require_once('/home/forge/cho...')
#17 {main}
REQUEST_URI=/craft/login
---

I tried various cacheMethod without any luck and now I'm kinda stuck.


texts:
I have 4 main template folders, under the /craft folder (each template folder works for another subdomain).

Now, I do have per template folder, a few variables that I like to have shared amongst all templates underneath it.

Such as:

{% set projectsGroup = "projectsWeather" %}
{% set sliderGroup = "sliderWeather" %}
{% set faqGroup = "faqWeather" %}

Which are different, per template folder.

Now, when I put these variables at the top of my master _layout file, this gets shared nicely amongst all templates -- that is, for those that use this _layout file.

I do however also have a few json generation template files, that can not use the _layout file.

My question now is how to elegantly assign these variables, and do this only once.

I can not stick them in a separate file and just use "include" or "extend", because then _layout either ignores or complains.

Any ideas?


texts: What is the best way to generate email messages with attachments from Twig files?

texts:
I am coming from a .net/C# background and we have recently moved to a Craft/Twig platform.  What is the best way to do this: Have a visitor come to a Craft webpage (Twig file), enter their email address in a text box, hit a button, and have an email message sent to them containing a PDF attachment that they selected from that page?

Is this functionality built-in to Craft or do I need a plugin?


texts:
Not sure whether I should be posting this here or as a Github issue, but when trying to install NY Studio's Transcoder plugin, I get:

Composer output: Package "craftcms/vue-asset" listed for update is not installed. Ignoring.
Package "yiisoft/yii2-shell" listed for update is not installed. Ignoring.
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
The requested package nystudio107/craft-seomatic (locked at 3.3.17, required as ^3.3.18) is satisfiable by nystudio107/craft-seomatic[3.3.17] but these conflict with your requirements or minimum-stability.
Running update with --no-dev does not mean require-dev is ignored, it
just means the packages will not be installed. If dev requirements are
blocking the update you have to resolve those problems.

composer.json looks like this:
{
  "require": {
    "barrelstrength/sprout-fields": "^3.8.3",
    "craftcms/cms": "^3.4.24",
    "craftcms/redactor": "^2.6.1",
    "dukt/analytics": "^4.0",
    "nystudio107/craft-seomatic": "3.3.18",
    "nystudio107/craft-typogrify": "^1.1",
    "ostark/craft-async-queue": "^1.3.3",
    "putyourlightson/craft-blitz": "^3.6.5",
    "topshelfcraft/wordsmith": "^3.2.0",
    "verbb/cp-nav": "^3.0.13.1",
    "verbb/field-manager": "^2.1.8",
    "vlucas/phpdotenv": "^2.4.0"
  },
  "autoload": {
    "psr-4": {
      "modules\\": "modules/",
      "modules\\exifReturn\\": "modules/"
    }
  },
  "config": {
    "sort-packages": true,
    "optimize-autoloader": true,
    "platform": {
      "php": "7.0"
    }
  },
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ]
  },
  "repositories": [
    { "type": "composer", "url": "https://packagist.phpcomposer.com"}
  ]
}

Has anyone else had this problem and how did you resolve it?


texts: we are a small team in Berlin, Germany, developing editorial websites based on craft cms. A major publishing house is interested in our services. A condition to get contracted is us to provide a certain (t.b.d.) level of tech support – a requirement that we can´t match since we are just a small company. Now my question: does anybody know a tech support-provider in germany to whom we could "outsource" this service?


texts: How to run function after plugin installed?

texts: How can I run a function when my plugin is installed? I tried SafeUp in migrations but it doesn't work.


texts:
I have a client who uses Office 365 for email.  Using the basic phpMail config in Craft fails when I try to direct an email to any of the clients email addresses, including user registration and, more importantly, when sending a message from the Contact Form plugin.

I have tried in vain to change the Craft email settings to SMTP, using credentials that have been tested with a desktop email client.  I am sure there is something I am missing, e.g. some server config thing.

Any advice would be greatly appreciated!

Roi


texts: How to add Redactor Image resizing and positioning to the Rich Text field in Craft?

texts:
Can anyone provide details on how to add Redactor (II) Image resizing and positioning to the Rich Text field in Craft?

Many thanks!


texts: PayPal Currency - Item bag total price does not equal the orders totalPrice, some payment gateways will complain

texts:
We are using PayPal standard as an option for payments which works in the main currency (GBP) but not in any of the others eg (CAD). We're seeing in the plugin logs for craft commerce:

[Forced] Item bag total price does not equal the orders totalPrice, some payment gateways will complain.

Any ideas on what could be wrong? It seems that this is a problem with PayPal adding up the totals and seeing they are wrong? but this is all done on craft side so not too sure.


texts: multi-select OR values to filter entries

texts:
preface: i'm new to craft so may get terminology incorrect

basic idea: i would like to show entries of a particular channel which have multi-select field values which intersect with another set of values. e.g. given set ['a','c','e'] it would show entries with values such as ['a','b',c'] and ['e'] but not ['b','d'].

what i have done so far:

my basic ElementCriteriaModel for entries in the past is defined:

{% set results = craft.entries({
    section: ['mysection'],
    when: ' <= ' ~ now,
    order: 'when desc',
}) %}

{% for entry in results %}
.... blah blah do stuff

and what i would like to do is add another criteria on there for the multi-select field. however, from what i am reading and have tried it doesn't seem like that kind of filtering is available. please stop now and prove me wrong if this is not the case!

i was able to filter matching a single option of the multi-select by using:

{% for entry in results if entry.myMultiSelect.contains('a') %}

but was unable to determine syntax to "OR" the results with another contains(). really not much documentation that i could find on that method.

alternately i possibly could use a search, but sounds like that relies on indexes that may get out of date which i would like to avoid. wouldn't be a huge deal, but looking for the "right" answer before i settle on brute forcing it by just looping through the multi-select values inside the loop to check for a match.


texts:
I've been getting annoyed at one small problem I can't solve with the Craft Shortlist Plugin. It seems that I have got everything to work but no matter what I do, the {{ item.title }} just won't display the entry title that was added the list the default list.
All the functionality seems to be working no problem but I just simply can't get the item title to appear.

Code Used to display my list

{% set lists = craft.shortlist.lists %}

{% if lists is empty %}

You have no lists at the moment.

{% else %}

{% for list in lists %}

{{ list.title }}

    {% if list.items is empty %}

This list is empty

    {% else %}

            {% for item in list.items %}

{{ item.title }}

                remove
                {{ item.id }} {{ item.title }}

            {% endfor %}

    {% endif %}

{% endfor %}

{% endif %}

Code used to give my entries add and remove buttons

{% for entry in craft.entries.section('locations') %}
  {% set item = craft.shortlist.item(entry.id) %}

{{ entry.title }}

  {% if item.inList %}
      Remove from Favourites
  {% else %}
      Add to Favourites
  {% endif %}
{% endfor %}

Would really appreaciate the help on this one so let me know if more detail is needed.


texts: Best practice on importing Craft db backups?

texts:
Our team's typical workflow is pull from repo, delete craft tables, import latest db backup, work locally.

We don't want everyone working on the dev server db for early development, because we'll be breaking the site too much for everyone else.

Which brings me to my question, should I be deleting tables before importing? If I don't delete the tables Craft has to do some cleanup magic on the backend (I don't know what it does). I do know that Craft creates tables for matrix types. Would not deleting tables potentially leave orphaned db tables? Obviously there could other side effects as well.

Opinions? Clarification?


texts: Serve remote files instead of local ones (with a nitro setup)

texts:
I'm new to CraftCMS and slowly learning how to use it. I'm creating a site. The local setup was done with Nitro. I have read about the ways to synchronize data and assets across environments. But I have a special situation:
The client has thousands of images (over 9GB), as we do our development, they are continuously adding new media. We don't want to download all those images, and going through refreshes every time they add new images or edit existing ones. With the previous CMS I used to work with, I could modify a local .htaccess file so that when there is a local image request it would be served from the remote server instead.
Does anyone know how to achieve this with a Nitro setup?
Thank you so much.


texts: Problem installing plugin via path repository

texts:
I am starting to play with writing a plugin in Craft 3.0. I have followed the following page. I used Plugin Factory to create my plugin structure (very nice). My folder structure is as follows:

/craft
/craft/vendor/recoveryfinder/nav

I uploaded the files and folders created bt the pluginfactury to /craft/vendor/recoveryfinder/nav folder. My additions to the craft project composer.json look like this:

After:

{
  "name": "craftcms/craft",
  "description": "Craft CMS",

I added:

  "minimum-stability": "dev",
  "prefer-stable": true,

After:

  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "@composer dump-autoload -o",
      "@php craft setup/welcome"
    ]
  },

I added:

  "repositories": [
    {
      "type": "path",
      "url": "./vendor/recoveryfinder/nav"
    }
  ]

I went to the terminal logged in as the user that owns the files and change location to:

  /craft

I then ran:

  composer require recoveryfinder/nav

The output I am getting is:

Using version ^0.9.0 for recoveryfinder/nav
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals

  [RuntimeException]
  Package recoveryfinder/nav cannot install to "/home/recoveryfinder/craft/vendor/recoveryfinder/nav" inside its source at "/home/recoveryfinder/craft/
  vendor/recoveryfinder/nav"

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...

I have not modified in any way the files created by pluginfactory.io.

Any pointers as to what I did wrong?


texts: How to modify element's data during import?

texts:
I'm trying to modify the element's data during the import. I'm using EVENT_STEP_BEFORE_ELEMENT_SAVE to modify the $contentData. I added some logging at each step and I can see that the $contentData is being changed to " - blah - " for each element in the feed but the original value for 'productDescription' is still being saved for the element.

Event::on(Process::class, Process::EVENT_STEP_BEFORE_ELEMENT_SAVE, function(FeedProcessEvent $event) {
 $event->contentData['productDescription'] = " - blah - ";
});

Here's the logging (irrelevant data omitted):

{before modifying ($contentData) ==== "productDescription":"Freestanding Spring Horses"}
{after modifying ($contentData) ::::: "productDescription":" - blah - "}
{Data ready to import ($contentData) -> "productDescription":" - blah - "}
{After saving ($contentData) ---- "productDescription":" - blah - "}

When I look at the productDescription field for the element that was just imported I see: "Freestanding Spring Horses"

So how can I modify the data that gets saved for each element?


texts: Trimming lastSegment from a URI trims that PLUS the last number of the previous segment

texts:
I am fairly new to twig and templating with Craft (and I have inherited this code, so that makes it even more fun).

I have a calendar page that lets you filter the events in the calendar based on a venti group (using the Venti Calendar plugin to create those groups).

How it currently works is that whatever group filter is selected, the url updates to have that group ID as the last segment.

Filter Names and their IDs: Cinema = 1, Theatre = 2, Events = 3, Education = 4

If a user is looking at the events for the month of December 2017 with no filters, the url looks like this:

example.com/month/2017/12

If a user is looking at the events for the same date, but has a filter applied (in this case, the "Cinema" filter), the url looks like this:

example.com/month/2017/12/1 Cinema has group ID of 1 so 1 is the last segment.

In order to change the applied filter without resetting the date, I want to trim the last segment from the url, and replace with the new ID as the last segment. Doing this works completely as expected unless the last segment and the last character of the previous segment are the same number (e.g., example.com/month/2017/12/2).

In this case, if I am currently on this URL, and I want to change to a different filter (in this example we change to use Cinema Filter = 1), the following happens.

example.com/month/2017/1/1 where it should actually be example.com/month/2017/12/1

So what is happening is that it is trimming the 2 from the last segment and the segment before the last segment.

Here's the code for the filter buttons:

    {% set groups = craft.venti.groups() %}
    {% for group in groups %}
        <a class="button" href="
            {% spaceless %}
            {% if craft.request.getLastSegment() in ['1','2','3','4'] %}
                {{url(craft.request.path)|trim('/' ~
                craft.request.getLastSegment())}}/{{group.id}}
            {% else %}
                {{url(craft.request.path)}}/{{group.id}}
            {% endif %}
            {% endspaceless %}">
            {{ group }}
        </a>
    {% endfor %}

If I remove '/' ~ from this:
{{url(craft.request.path)|trim('/' ~ craft.request.getLastSegment())}}/{{group.id}}

It actually works perfectly, save for the fact that the new url looks like this: example.com/month/2017/12//1 With the addition of that second backslash.

Can anyone see what I am doing wrong here, or provide any help? If you need more of my code, please let me know.

Thank you!


texts:
I’m trying to cut down the amount of database queries on the homepage of a site I’m working on, and am attempting to do some eager loading of an asset set in a supertable field. However, although the queries drop, the focus point no longer works when I do, so I think it’s not setup right. Can anyone explain what I’m doing wrong please?

{% set mainCarousel = entry.mainCarousel.find({
 with: [
 'carouselImage'
 ]
}) %}
{% for row in mainCarousel %}
{% set image = row.carouselImage[0] ?? null %}
{% set transformedImages = craft.imager.transformImage(image,
  [
      { width: 1920, ratio: 3/1, jpegQuality: 60 },
      { width: 1440, ratio: 3/1 },
      { width: 1024, ratio: 3/1 },
      { width: 750, ratio: 4/3, jpegQuality: 60 },
  ],
  {
      format: 'jpg',
      allowUpscale: false,
      mode: 'crop',
      jpegQuality: 80,
      position: image.focusPctX ~ '% ' ~ image.focusPctY ~ '%',
      interlace: true
  }
) %}

 {% if image | length %}
 <picture>
   <source srcset="{{ craft.imager.srcset(transformedImages) }}">

 </picture>
 {% endif %}

{{ row.heading }}

{{ row.text }}

   {% set button = row.button %}
   {% if button|length %}View Project{% endif %}

{% endfor %}


texts: Simple Product Listing Pages by Category Slug

texts:
I'm new to Craft and I'm trying to create very basic product listing pages based on Categories and I'm not sure where to start.
First, it doesn't look to me like you can create separate templates for each category, only the Category group, correct?
If that's true, then I need that template to be dynamic and list the products in a category that may be nested. The idea being that I will have navigation that will resolve to each category page.
I've gone through the page on Querying Categories and I think querying by Slug is what I want. I altered the code on that page based on this post in order to get whatever the last segment is:
{# Get the requested category slug from the URL #}
{% set requestedSlug = craft.app.request.segments|last %}

{# Fetch the category with that slug #}
{% set category = craft.categories()
    .slug(requestedSlug|literal)
    .one() %}

{% set entry = category %}

{% for entry in entries %}
    {{entry.title}}
    {{entry.url}}
    {{entry.image}}
{% endfor %}

For clarity I didn't put the entry items in HTML.
I feel like my problem is the second bit, setting the entry to category (which I cobbled together from posts here and in the docs) but I can't figure out how to get at the entry details from items in a category.
I also need to paginate the listings if that makes a difference.
Thanks in advance for any advice or pointers to good tutorials on using Categories to generate product listings.


texts: Sprout Forms or Craft not sending email to Craft user email addresses

texts:
Is there anything in Sprout Forms or Craft that prevents an email being sent to any registered Craft user email address but not other email addresses not in the Craft user list?

I have a really simple one field form that sends a notification to two email addresses: the one in the submitted form field, as well as the one in the CP Sprout Forms notifications field.

A weird thing is happening. If I use an email address that is not belonging to a Craft user (either as the typed in notification address or the {email} one) the email is sent (according the server logs) and received. If I use an email address belonging to a  Craft user the email is not sent from Craft (doesn't even register in the server logs).

(The simple form is trying to distil the problem down - it is occurring on all my forms, and was working before but has stopped, possibly the same time as a server change. The PHP mail() function works to said email addresses. I am using latest versions of Craft and Sprout Forms on PHP 7.)

Edit: I can swap email addresses in and out of the user list so when they belong to a user no email is sent, and when they are removed from the user list, the email is sent. This suggests there is nothing wrong with the email address per se or the route through the system, but purely the fact that it is a Craft user email address.

Edit2: When sending to a craft user email address the following craft.log error is made:
Email error: Could not execute: /bin/mini_sendmail (etc)
This doesn't happen when a non-craft user email is used. So suggests to me Sendmail is not properly set up (but why then do other emails get through fine).


texts: Is it possible to remove commerce customers? I removed users, but customers stay and I don't see any options to remove them in the control panel.


texts: I am getting the following error when installing craft .. do you have any clue of what I might be doing wrong or missing out?


texts: Auto login user after password reset via a plugin in Craft3

texts:
Unlike in Craft2, there doesn't seem to be a way in Craft3 for a plugin to automatically login a user after a password reset.

In Craft2, a plugin could listen for users.onSetPassword to determine when a user had reset their password, and then log the user in.

However, Craft3 doesn't seem to raise any suitable event -- presumably if it did, it would be done in UsersController->actionSetPassword.

The documentation does state:

  The setPasswordSuccessPath config setting designates where the user should be redirected to after they finish resetting their password (and get automatically logged-in).

However, this bit about getting automatically logged in doesn't seem to apply when setPasswordSuccessPath is set.

Is there something that I'm missing here?


texts:
I'm trying to call the addBlock function from the Matrix fieldtype. Whenever a block is added i need to run some basic javascript.
Does anyone have an idea how to go about this?
thanks!


texts: How can I loop through all entries that are enabled in at least one locale (not necessarily my current locale)?

texts:
I am trying to build a sitemap and need to loop through all entries in Craft in order to do this.

However, I am building a multi language site which has entries that can be enabled in a single locale but not in others. Because my default language (English) doesn't have a language code in it's site url (i.e. mysite.com is the English index and mysite.com/ja is the Japanese index), the sitemap template I am using automatically assumes the current locale to be English and any entry that is not enabled in English (but is enabled in another locale) does not get included in the sitemap loop.

Is there any way I can still include entries that are not enabled in the current locale (English) but are enabled in an alternate locale? Or is there some better way I should be doing this?


texts: How to display the last 4 digits of the credit card used for a Craft Commerce purchase

texts:
I'd like to display the last 4 digits of the credit card used for a purchase in a front-end template. It appears the data is in the db in the craft_commerce_transactions table reference column in JSON format.

{
    "approvalCode":"PNRABL",
    "transId":"60007205645",
    "card": {
        "number":"1234",
        "expiry":"112318"
    }
}

Is there a method supported by Craft Commerce to display this data in a users account area?


texts:
I'm trying to translate the labels for a global checkbox field in my front-end templates like in this post: Is there a way to have checkbox field labels translatable?.
This looked promising but I can't seem to get it working (maybe it's Craft2 and things have changed in 3)

Basically it's using namespacing in the translations file e.g for a French translation file

return [
  'field.fruits.option.apple.label' => 'pomme',
  'field.fruits.option.lemon.label' => 'citron',
];

But no translations showing in the template when I try

{% for fruit in myGlobalSet.fruits %}
    {{ fruit.label|t }}
{% endfor %}

Any ideas? I'm sure it must be syntax related or wrong namespacing but I'm not getting any errors.


texts: Need help with plugin for SAML authentication

texts:
I'm trying to put together a plugin that allows for SAML authentication with Craft. We're working on a site that will be locked down but employees will be able to authenticate to the site using SAML. I came across a SAML toolkit from Onelogin that does the job and was able to get it configured and working outside of craft. With SAML you are not sending a username and password. It authenticates by redirecting the user to the Identity Provider(in this case the client's Proxy Server) and they enter user and password information there, and then the Provider issues a token that gets sent to the Service Provider(Our Craft Site) to allow them in. So far it's working pretty well and I'd like to get it integrated with Craft.

There are a few things I'm getting stuck on being new to Craft and also Yii.

Since we're not dealing with conventional users, is there a hook that I can use to establish a session that Craft understands but base it on the SAML attributes? Is extending userSessionService the way to go with that or should I be looking at creating a custom session?

I'd like to lock every page down on the front end and only show it if the user has authenticated. I've seen a few other plugins using the init function and if(craft()->request->isSiteRequest()). I've tried that and it works pretty well. Is this the way to go or should I be looking at something else?

If I do keep the authorization code in init, should I be offloading the heavy lifting to a Service? I'm already thinking about creating some controller actions for login and logoff along with registering some routes in the CP. That way I could include links on the front end for that.

Again, new to Craft. Any guidance would be appreciated.


texts: Admin panel not working without language code

texts:
I've migrated a website with CraftCms 2 from local to a pre-production server. Everything is working fine but, I don't know why, I only can go to the admin panel with locale code before /admin. I mean, if I write domain.com/admin, it doesn't work. But if I write domain.com/es/admin it works. And this don't happen in local server, only in pre-production.
I get message "Not Found. The requested URL /admin was not found on this server." Instead of a 404 from my webpage.
It works fine in others projects under craft with the same structure and, as I said, in local server works fine too. In root I have:

assets/
craft/
en/
va/
es/
index.php

Any idea? Thanks.


texts: How can I validate/make a matrix field required on the front-end?

texts:
I am displaying inputs on the front-end of my form that are populating a matrix within the CP.

Overall everything is working fine. The problem I am having is validation. I've got the field marked as required, but it seems leaving the fields empty still passes validation.

    ....

    <input type="hidden" name="fields[myMatrix][new1][type]" value="myField">
    <input type="hidden" name="fields[myMatrix][new1][enabled]" value="1">

    ...

    {{ account is defined and account ? errorList(account.getErrors('myMatrix')) }}

Whenever I comment these fields out, I get the validation message that the field is required. I believe it has something to do with those hidden input(s) a value. But, if I take those out, the fields do not populate the input in the CP.

How can I show the fields on the front-end and still show the error message?


texts:
I seem to be missing the users panel in the CMS. Any idea where it could have gone? For adding new users, groups etc.

Am a bit confused, and new to craft. So, sorry if this is painfully obvious.

Thank-you


texts: localhost and root directory for multiple site installs

texts: So I usually have multiple sites inside of my MAMP htdocs folder which I then access through localhost:8888/sitefolder. How would this work for a Craft set up? The only way I got my initial Craft site to work was to point MAMPs document root to the public folder of the Craft site I was working on. But this seems pretty messy if I was to be working on multiple Craft sites at once. Surely I wouldn't need to keep changing my MAMP settings every time I wanted to look at another dev site?


texts:
We are building a restaurant site that has a banner image and some introductory text on each page.  For pages that include content from a Channel, e.g. the wine list, we are using a Global to define the header image and the intro text, and then a "for loop" for the wine entries.

Are there any performance benefits to using a global versus a single?  Any other pros and cons related to those choices?


texts: Is it possible to set a hashed password programatically for a user?

texts:
Related to this question - with one difference.

Is it possible to set a hashed password for a user? I'm able to save the user just fine - but when I pass the already hashed password like $user->password it doesn't set the password. I'm not seeing anything within $user->getErrors(), it's just a blank array. Any ideas?


texts:
DevMode is awesome, but I wanted to post this as a bit of a heads up.

I'll preface to say yes, you shouldn't be developing live and yes, the docs do include a warning(yet very small and not really explaining why).

But I am assuming alot of you have it turned on right now.

It reveals the craft path, file system paths, plugins installed, field handles and a whole lot of other juicy stuff.

To everyone.

Couldn't we have, or is there a way to have, this wonderful feature only available if logged in and/or admin?


texts: UX issue with new email verification link

texts:
I'm working on a profile management form for a site with public registration enabled. I'd like users to be able to change their email address. I've got it working as Craft intended -- they enter their email + current password, a "Verify new email address" email is triggered, and following the verification link updates their email.

The UX wall I'm hitting is that a) the user is logged out when click the verification link and b) they get no messaging around whether or not the email was actually changed.

I've reviewed the code and don't see any way to improve this experience. I found https://github.com/craftcms/cms/issues/1421 but the workaround in there seems heavy handed.

Has anyone come up with an elegant solution for this?


texts:
I have a page in Craft (2.x) that displays several links and I was able to find which twig file had those links by searching the code base of twigs.  Those links point to some Angular code with links like this:

/support/give?source=

By trial and error, I discovered that the Angular code is invoked as part of a twig file in craft/templates/_views/  The original conundrum was there were two "give" files:  give.twig and give-new.twig and I didn't know which one was the actual twig invoked.  By trail and error again, I determined it was using the give-new.twig by changing the template.  But for the life of me, I cannot figure out how THAT twig is being invoked.  I scanned for "give-new" in the code, both craft and Angular and I searched in Settings, Routes and Web Content for any reference to it but I cannot figure out how a URL like /support/give maps to the give-new.twig file.

So the question is: How do I know which twig is invoked by a URL?  I am pretty sure that there isn't any Angular code doing this, the Angular code bundle references are in the twig file, but how that twig is invoked is a mystery.  Where do I start in finding the reference?


texts: Allowing duplicate slugs in category paths

texts:
Again, I've had a look online but couldn't figure out what I had to do.

Say I've got a category structure like the below:

Category 1

Saturday
Sunday

Category 2

Saturday
Sunday

How can I allow duplicate category slugs so that they can be like:

/category-1/saturday/*
/category-2/saturday/*

Instead of:

/category-1/saturday/*
/category-2/saturday-1/*

What I have found online talks about Entries and Routes and then setting it up do serve from specific template but I'm not really sure where to start with that as still trying to learn how to work with Craft.

For example, this answer mentions how it should be possible if the Entry URI Format has been set up correctly for Sections but I haven't set up sections for creating categories so I'm not sure how my case relates (if it's of any use, I embed a screenshot of what I am referring to and category structure below):

Is there not a simple way to just achieve duplicate slugs for categories as per my above example?

If I try changing the slug to say 'saturday', it just re-appends the -1 to the end again.


texts: Craft Commerce WorldPay integration callback failure

texts:
WorldPay looks to be a terrible Payment Gateway, but it's supported by Craft Commerce so we've gone ahead. Right now, I'm having a problem with the callback's failing with a 302 error.

Our site is updating the order following payment, but the user gets stuck on WorldPay's default thank you page.

Has anyone used Craft Commerce with WorldPay yet?


texts: User Registration Form Redirect not working Craft 2.5

texts:
I'm using the following code but the redirect is not working. After the user registers it takes them back to the home page and not to volunteer/identity. I put a message on the homepage to display if the user is logged in and it appears that they are logged it at that point. This used to work before 2.5 on a different site that I haven't upgraded to 2.5. But now on this new install of 2.5 I can't get it to work.

Has anyone else experienced the same issues?

{% extends "_layout" %}

{% block content %}

<form method="post" accept-charset="UTF-8">
    {{ getCsrfInput() }}
    <input type="hidden" name="action" value="users/saveUser">
    <input type="hidden" name="redirect" value="volunteer/identity">

    {% macro errorList(errors) %}
        {% if errors %}

                {% for error in errors %}

{{ error }}

                {% endfor %}

        {% endif %}
    {% endmacro %}

    {% from _self import errorList %}

    First Name
    <input id="firstName" type="text" name="firstName" {% if account is defined %} value="{{ account.firstName }}"{% endif %}>

    {% if entry is defined %}
        {{ errorList(account.getErrors('firstName')) }}
    {% endif %}

    Last Name
    <input id="lastName" type="text" name="lastName" required {% if account is defined %} value="{{ account.lastName }}{% endif %}">

    {% if entry is defined %}
        {{ errorList(account.getErrors('lastName')) }}
    {% endif %}

    Email
    <input id="email" type="text" name="email"
        {% if account is defined %} value="{{ account.email }}"{% endif %}>

    {% if account is defined %}
        {{ errorList(account.getErrors('email')) }}
    {% endif %}

    Password
    <input id="password" type="password" name="password">

    {% if account is defined %}
        {{ errorList(account.getErrors('password')) }}
    {% endif %}

    <button type="submit" class="button">Save and continue</button>

</form>

{% endblock %}

My config file looks like this:

return array(
    'devMode' => true,
    'useEmailAsUsername' => true,
    'autoLoginAfterAccountActivation' => true,
    'omitScriptNameInUrls' => true,
    'setPasswordPath' => array(
        'en' => 'account/setpassword'
    ),
);


texts: How do I filter by multiple Smart Map addresses?

texts:
I have profiles (Users) that can have multiple addresses (currently two Smart Map fields called profileAddress1 and profileAddress2).

I know how to filter by a single address:

{% set results = craft.users({
    group: 'profiles',
    profileAddress1: {
        target: 'Cologne',
        range: 20
    }
}) %}

How would I search across both fields? So if a profile had two addresses – one in Cologne and one in Munich – it should show up in the results in both search cases (Cologne and Munich).

Is that even possible?


texts:
My Craft CMS installation has public and craft in the root of the directory, with the domain pointing to the public folder. Where could I put custom PHP scripts that I can run in the browser?

I've tried it in the craft/templates folder (/craft/templates/m53ford). In this folder I can see the HTML or XML files by visiting http://feeds.rhinodigital.co.uk/m53ford/index.xml for example, but a PHP script doesn't run in the same place.

I've also tried in folders at the same root level (alongside the public and craft folders), and also within the public folder itself. Where in the directory tree could I place a PHP file that I can visit in the browser?


texts: Error when submitting Date Field from the front-end: cannot be blank

texts:
Am using the Pikaday datepicker to add a Date field to the front-end of a Craft site: https://github.com/dbushell/Pikaday

This is for integration with the Formerly add-on and the date is set to required.

When I try to submit the form I get the following error:

2016/02/03 12:23:54 [warning] [application] Craft\ContentModel->dateTest_testDate failed validation: Test Date cannot be blank.

Are date inputs submitted via the front-end required in a particular format?

also experiencing same problem with Sprout Forms


texts: using Freeform Pro, set mailchimp key, how do I target a specific list on mailchimp to send and config with please?


texts:
I am having some trouble when trying to create a new Entry in Craft3 via PHP. In Craft 2, I was able to do something like this:

  $entry = new EntryModel();
  $entry->getContent()->title = $name;
  $entry->getContent()->answer = $answer;
  $handle = "nameOfTheSectionIWantToSaveIn";
  $entry->sectionId = craft()->sections->getSectionByHandle($handle)->id;
  $save = craft()->entries->saveEntry($entry);

Before asking, I took some time to read through the Craft3 Class Reference and came across the namespace:

craft\elements

I have come to the conclusion(could be wrong) that I need to use something like the following:

use craft\elements\Entry;
$entry = new Entry();

However, I am a little confused as to where I go from here. I checked the available Craft Entry Public Methods and could not find a method like getContent(), which was used in Craft2. I did see a getContentTable(), but not sure if thats what I am looking for.


texts: What is the correct method for getting a client to purchase a Craft license?

texts:
What is the recommended way from P&T to get a client to purchase a license for Craft CMS? It doesn't actually say how on the website.

If you give a user literally all the permissions Craft has, when they log in to an unlicensed Craft Pro install, they'll see this warning at the top:

If they click Resolve, they get taken to /admin/plugin-store/upgrade-craft and see this error:

The only way I can see for a client to purchase a license is to make them a full Admin, which goes against everything the permissions are set up for. I don't ever want to make a client a full site administrator because they can easily break stuff.

Context: I'm working on behalf of a larger design agency, and the end client is liable for purchasing their own licenses. The design agency is not buying it on their behalf.


texts:
I'm trying to display three different sets of data in search results. The first two, News and Services I can easily concatenate by the following:

{% set searchSections =  craft.entries.section(['service', 'newsOpinion']) %}
{% for entry in searchSections.search(query).order('score').limit(52).find()  %}

This way the results display both sections limited and ordered via score no matter what section they are in.

Ideally I want to add a third array to searchSections of users.

{% set allStaff = craft.users.group('staff') %}
{% for user in allStaff.search(query).order('score').limit(52).find() %}

However users aren't a section and merging the three arrays doesn't work. Any ideas how i can do this?


texts: How to check for an non empty element field?

texts:
Which one of the following is the correct of way of checking if an element field like images, entries or category is not empty?

{% if entry.fieldHandle.one() %}
{% if entry.fieldHandle.all() %}
{% if entry.fieldHandle.count() %}
{% if entry.fieldHandle | length %}
{% if entry.fieldHandle.exists() %}
{% if entry.fieldHandle %}


texts: Is it possible to tell Craft to ignore requests to under a certain path?

texts:
Unfortunately, I'm in a position where I need to run a Craft and WordPress installation out of the same directory. The WordPress install is under the sub-directory /blog.

When I visit http://mysite.dev/blog/ the WordPress blog loads as expected, but attempts to visit any routes within that result in Craft's 404 page. For instance, http://mysite.dev/blog/my-post.

Is it possible to convince Craft to ignore any requests under /blog?


texts:
I have a structure people that I need to grab entries from. However, I need to exclude certain entries as some are already displayed on the page in a different manner.

I know that you can exclude a single entry by doing something like this

{% for councilMember in craft.entries.section('people').id('not ' ~ entry.id)

But how do you exclude multiple entries by their IDs?


texts:
Currently I'm having an issue deploying to Digital Ocean and would love some advice, i've followed numerous tutorials but they seem to just drop off half way through the process so just need some clarity on this. I've broke down what I've done below:

Developed my CraftCMS site in localhost using MAMP.
Committed everything to Github apart from db.php
Created a droplet with LAMP
Setup my database names so it corresponds with my localhost
Setup my database user
Created a deploybot setup which contains my     db.php file
Deployed the application using deploy bot which deploys my latest
push in the git repo.

Am I supposed to be reinstalling CraftCMS on the droplet and upload my localhost database after these steps?


texts: Migrate Craft CMS installation from PgSQL to MySQL - any hints?

texts:
We need to migrate a Craft installation with a pgsql dump to MySQL.

Any hints on the procedure?

Thanks,
Matthias


texts: Image transform with focal point - in Element API

texts:
I can call predefined image transforms no problem -

$image->getUrl('small')

but cropped mobile transforms need to use the image asset's set focal point (from the Image Editor). I can't find any example of how to use this feature in code?

I assume the only way to use this focal point is setting a new transform array in PHP? (i.e. the preset values are ignored).

Be good if there was an option to use the Image Focal point in the Transform setup (UI).


texts: Trouble updating Craft when allowAdminChanges is false

texts:
I've just updated a multi-environment site from Craft 3.3.5 to 3.4.5. Here's our config/general.php (irrelevant bits removed):

return [
    '*' => [
        'allowAdminChanges' => false,
        'allowUpdates' => false,
        'devMode' => false,
        'useProjectConfigFile' => true,
    ],
    'dev' => [
        'allowAdminChanges' => true,
        'allowUpdates' => true,
        'devMode' => true,
    ],
    'production' => [],
];

The update succeeded in the development environment (localhost) but the production deployment failed*. Here's the post-deployment command:

/path/to/composer install --no-interaction --prefer-dist --optimize-autoloader && ~/user/craft project-config/sync

When the deployment failed, I went to /admin and received the "Finish Up" button. I clicked it. I then received the "Sync" button and clicked it as well. I then received an error. Unfortunately I can't remember what the error said and didn't take a screenshot. It was a nicely-formatted error (not just a PHP dump) and there was a Troubleshoot link under it.*

Anyway, I SSH'd into the server and ran project-config/sync manually. Here's what was returned:

Applying changes from project.yaml ... error: Changes to the project config are not possible while in read-only mode.

I then edited config/general.php and made allowAdminChanges true on production. Reloading /admin worked and I was able to log into Craft.

At long last, here's my question:

We're following the advice per the allowAdminChanges docs. Does this advice only apply to non-update changes? In other words, is it a known thing that allowAdminChanges must be true when pushing a change to project.yaml that will update Craft?

--

*FWIW, we do have a staging deployment but it doesn't apply to this question.

--

EDIT: I ran another test, here's the error:

A fatal error has occurred:

Status: Internal Server Error
Response: {"error":"A server error occurred."}


texts: How do I get a URL link to open in a new window once clicked

texts:
I have a URL to an external website within one my site's pages.  I want this to open in a new window.  I don't want the viewer to move off our website but will want them to click on the link to our third party.
How do I get the link to open in a new window?
thanks


texts: When I flip the "Featured Entry" switch, disable it on other entries

texts:
Assuming I'm using a lightswitch to denote an entry as "Featured," how can I then disable that lightswitch on every other entry, so that no matter how many times I flip these switches only one entry can be "Featured?"

Thanks!

Edit: There are some plugin options, and that might be the only way to go but I'm hoping that someone can find a better way through Twig filters or something.


texts:
There seems to be a default limit to for loops in craft of 100.

I have a channel with quite a few entries.

How can I disable this without writing nasty things like .limit(100000000)


texts: Disable or hide an entry field in the CMS

texts: Is there a way to hide or disable an entry field in the CMS so that the field still exists in the database but can not be edited by a user. The field will only ever be altered dynamically from a plugin?


texts: How do you get all the categories in a category group in a controller?

texts: I want to get all the categories in a specific category group inside my controller. How do you do that?


texts: Creating environment variable from JSON file

texts:
Brand new to Craft here. I'm trying to port across my gulp workflow to Craft and basically everything has gone super smooth. Just one last obstacle due to my lack of knowledge of the Twig templating engine and some of the internal workings of Craft.

Basically, for production, I run gulp with a --production flag. This appends a string of numbers and letters to the asset's file name (as well as removing source maps etc.), such as main-5449f384.css, to help with caching. A list of the resulting asset filenames is stored in a JSON file at public/dist/assets.json. The contents of the file is akin to:

{
  "main.css": "main-5449f384.css",
  "modernizr.js": "modernizr-45f0e1f4.js",
  "jquery.js": "jquery-e735354d.js",
  "main.js": "main-b7e504b0.js"
}

Separately, in my general.php config file, I've set up environment variables so I can use local asset paths in local and dev environments and a CDN based path in production:

return array(
    '*' => array(
        'appId' => 'example',
        'omitScriptNameInUrls' => true,
    ),

    'example.com' => array(
        'devMode' => false,
        'assetUrl' => 'https://cdn.example.com/',
    ),

    'craft' => array(
        'devMode' => true,
        'local' => true,
        'assetUrl' => 'http://craft:8888/',
    )
);

I had figured that to finalise the whole workflow, my head section within craft/templates/_layout.html would look something like (using a if statement to get the current environment):

Local

<script src="{{ craft.config.assetUrl }}dist/scripts/main.js"></script>

Live (pseudocode)

<script src="{{ craft.config.assetUrl }}dist/scripts/{{ assets.json.main.js }}"></script>

Is there a way to either set an environment variable based on the contents of the JSON file or to access to JSON file contents directly from within the template file? Or perhaps there's a much better way of doing this altogether (I'd quite like to keep the currently gulp workflow as is if possible)!


texts: With Craft Commerce, how can I call getAllStates from my own plugin via ajax?

texts:
I am trying to call $states = craft()->commerce_states->getAllStates(); from within my own plugin, via an ajax request.

MyPlugin.php

if (craft()->request->isAjaxRequest()) {
    return $this->returnJson(['states' => craft()->commerce_states->getAllStates()]);
}

The above will return this:

Object {states: Array[72]}

However, as I'm walking myself through it, I can see that the original call:

var states = {{ craft.commerce.statesArray|json_encode|raw }};

Gives me these objects:

Object {13: Object, 38: Object, 233: Object}
Object {13: Object, 38: Object, 233: Object}

So it's pretty obvious i'm not calling the correct method. I am using requirejs within my project and having the javascript right in the template is returning errors - it can't access jquery.

Thank you for any suggestions!


texts: How do you display a file asset (PDF) in the template?

texts:
I have an asset field (dataCard) which I use to upload a single PDF file tied to an entry. I'm trying, unsuccessfully, to display the asset tied to the entry on a page listing multiple entries. How would I do this? This is what I have so far:

{% set asset = entry.dataCard.first() %}

{% if asset %}
    {{category.title}}
{% endif %}


texts: How to check if entry field value is already outputted, and prevent it again?

texts:
For an event page I have the option to filter on cities and countries. Each event has entry fields in which the city and country, of which the values are outputted in a drop down list on the front end.

As some events happen in the same country and city I have multipe values that are the same. Is there any chance to filter these values in Craft and output it only ones?

{% for entry in craft.entries.section('events') %}
    <option value="{{entry.stad}}" name="{{ entry.stad }}">{{ entry.stad }}</option>
{% endfor %}


texts: What is $source and $sources in BaseRelationField?

texts:
I see the following in BaseRelationField:

public function settingsAttributes(): array
{
    $attributes = parent::settingsAttributes();
    $attributes[] = 'sources';
    $attributes[] = 'source';
    $attributes[] = 'targetSiteId';
    $attributes[] = 'viewMode';
    $attributes[] = 'limit';
    $attributes[] = 'selectionLabel';
    $attributes[] = 'localizeRelations';

    return $attributes;
}

The comments for the properties say:

   /**
     * @var string|string[]|null The source keys that this field can relate elements from (used if [[allowMultipleSources]] is set to true)
     */
    public $sources = '*';

    /**
     * @var string|null The source key that this field can relate elements from (used if [[allowMultipleSources]] is set to false)
     */
    public $source;

In the case of the single source. What would that string look like? What is that string referring to? A table name? In ID in a particular table?

Looks like the BaseRelationField is extended by Entries field and Users field and the sources are Entry structures and Administration groups respectively. If I wanted to set one as s static value what would that be?


texts: How to get Structure parent title and ancestors on search results page

texts:
I'm having trouble getting the Structure parent title on a search results page.

I followed these instructions but I'm getting a "Impossible to access an attribute ("title") on a null variable" error.

In the following code the all ancestors do print except the first level Structure title.

{% set query = craft.request.getParam('q') %}
{# {% set entries = craft.entries.search(query).order('score') %} #}
{% set entries = craft.entries.section().search(query).order('score') %}

  {% for entry in entries %}

  {{ entry.title }}
  {% set parent1 = entry.getAncestors().level(1) %}
  {% for item in parent1 %}
      / {{ item.title }}
    {% endfor %}
  {% set parent2 = entry.getAncestors().level(2) %}
  {% for item in parent2 %}
      / {{ item.title }}
    {% endfor %}
  {% set parent3 = entry.getAncestors().level(3) %}
  {% for item in parent3 %}
    / {{ item.title }}
  {% endfor %}

  {% endfor %}


texts: What would cause a user's activation link to fail?

texts:
I've just rolled out some changes to a site that's now seeing a big increase in (front end) user sign ups.

I have activation by email on and I'm tracking in analytics the number of hits to the activation success and activation failed pages.

If I look at yesterday as an example, 168 Success and 15 Failed.

I'd like to start working on bringing this down, but it would be useful to know the scenarios that would cause a user to hit the failed page. I believe they'll get this if they, for example, click the activation email twice.

Is there any other obvious causes that I use as a starting point?

Thanks!


texts:
I would like to create a link to another page in my plugin and send a specific ID with it but I don't really know how to do it in craft and twig.. I spend too much time on that little task and searched in the internet but could not really find something.

In my template I have

//loop through all database entries
{% for val in entries %}
    .....
    Edit
    .....
{% endfor %}

But it does not really work. How can I pass a specific id in my url and how can I receive this parameter in my php backend?
I didn't find something like craft()->request->getGetVar()and my $_GET is always empty. Of course I could just take the URL and use subtring and explode to get the correct value but I'm not sure if this is the intended way


texts: Error after Freeform Pro update to 3.5.10

texts:
I am posting this here because the Freeform support form is currently not working.

I get an error when viewing /admin/freeform/dashboard and /admin/freeform/submissions, however /admin/freeform/forms is working. It shows all forms and I can click on them to see the form detail page BUT there seems to be a faulty form - the one with the most submissions. When I click on it the detail page shows up with nothing in it but the title. This request doesn't seem to throw an error in the logs like the others did.

Versions with error

Craft: 3.3.16.3 and 3.4.1
Freeform: 3.5.10

Versions sans error (current production versions)

Craft: 3.3.16.3
Freeform: 3.5.4

It is still working in production right now. The error occurred after doing an update. This is the stack trace for /admin/freeform/dashboard and /admin/freeform/submissions:

2020-01-30 17:56:11 [-][5571][osi4gj30cngblrtejvdpq77h60][error][Error] Error: Call to a member function getForm() on null in /var/www/KLR3/vendor/solspace/craft-freeform/src/Elements/Submission.php:498
Stack trace:
#0 /var/www/KLR3/vendor/solspace/craft-freeform/src/Elements/Submission.php(474): Solspace\Freeform\Elements\Submission->getForm()
#1 /var/www/KLR3/vendor/solspace/craft-freeform/src/Elements/Submission.php(737): Solspace\Freeform\Elements\Submission->getFieldMetadata()
#2 /var/www/KLR3/vendor/solspace/craft-freeform/src/Elements/Submission.php(539): Solspace\Freeform\Elements\Submission->getFieldByIdentifier('enabledForSite')
#3 /var/www/KLR3/vendor/yiisoft/yii2/BaseYii.php(558): Solspace\Freeform\Elements\Submission->__set('enabledForSite', '1')
#4 /var/www/KLR3/vendor/yiisoft/yii2/base/BaseObject.php(107): yii\BaseYii::configure(Object(Solspace\Freeform\Elements\Submission), Array)
#5 /var/www/KLR3/vendor/solspace/craft-freeform/src/Elements/Submission.php(156): yii\base\BaseObject->__construct(Array)
#6 /var/www/KLR3/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1801): Solspace\Freeform\Elements\Submission->__construct(Array)
#7 /var/www/KLR3/vendor/craftcms/cms/src/elements/db/ElementQuery.php(2809): craft\elements\db\ElementQuery->createElement(Array)
#8 /var/www/KLR3/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1453): craft\elements\db\ElementQuery->_createElements(Array)
#9 /var/www/KLR3/vendor/yiisoft/yii2/db/Query.php(238): craft\elements\db\ElementQuery->populate(Array)
#10 /var/www/KLR3/vendor/craftcms/cms/src/db/Query.php(152): yii\db\Query->all(NULL)
#11 /var/www/KLR3/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1482): craft\db\Query->all(NULL)
#12 /var/www/KLR3/vendor/solspace/craft-freeform/src/Controllers/DashboardController.php(23): craft\elements\db\ElementQuery->all()
#13 [internal function]: Solspace\Freeform\Controllers\DashboardController->actionIndex()
#14 /var/www/KLR3/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#15 /var/www/KLR3/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#16 /var/www/KLR3/vendor/craftcms/cms/src/web/Controller.php(178): yii\base\Controller->runAction('index', Array)
#17 /var/www/KLR3/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('index', Array)
#18 /var/www/KLR3/vendor/craftcms/cms/src/web/Application.php(290): yii\base\Module->runAction('freeform/dashbo...', Array)
#19 /var/www/KLR3/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('freeform/dashbo...', Array)
#20 /var/www/KLR3/vendor/craftcms/cms/src/web/Application.php(275): yii\web\Application->handleRequest(Object(craft\web\Request))
#21 /var/www/KLR3/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#22 /var/www/KLR3/public/index.php(21): yii\base\Application->run()
#23 {main}


texts: How to make plugin developer name available in templates?

texts:
I'm constructing a plug-in and I'm new to it.

I want to print to the screen in my template the name of the developer, by accessing the getDeveloper() method in my Plugin.php. The problem is instead of showing the name of the developer, it throws an error saying Class Craft\CrmPortalVariable not found.


texts:
I have a structure which is  basically categories of Downloads.
In each Entry there is an "Files" field where multiple assets can be selected.

On a Summary page I want to display the latest assets added.
How can I pull these?


texts: What should my controller return in a Craft.postActionRequest

texts:
Simple question: I made a button in my plugin settings that creates a Craft.postActionRequest but what should the controller return?

It does not need to return anything else than true (successful) or string (action was not successful ->  errormessage) but if I return a true or a false or anything else than a template to render I get an error...

Little example:
my template is just

{{ response }}

And my controller

//correct -> no error, this template is just empty
public function actionDeleteAccessToken(){
    return $this->renderTemplate('srgoogleanalytics/tools/empty', array(response => true));
}

but if I make something like this

public function actionDeleteAccessToken(){
    return true;
}

I receive a PHP error file not found.
What do I wrong?


texts:
How can I exclude the current entry when I've structured my syntax like this?

{% set entries = craft.entries({
  section:        'blog',
  order:          'postDate',
  limit:          5,
}) %}


texts: Is it possible to remove an entry's Expiration Date?

texts: Once I have given an entry an expiration date, is there any way to delete that date so that it never expires?


texts:
I want to change the max_execution_time in the .htaccess file. I tried it in this way: <IfModule mod_php5.c> php_value max_execution_time 300 </IfModule> but then I got a 500 internal server error.
My .htaccess file also includes this:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Send would-be 404 requests to Craft
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
    RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>

Any idea why I got this error? Or how I can change the max_execution_time in an other way?

(I sadly do not have the possibility to change the php.ini)


texts: Fatal error in StringHelper.php when using cache block around loop

texts:
I'm getting a fatal error when wrapping a loop with {% cache %}{% endcache %} tags. The full error is:

  Fatal error: Allowed memory size of 134217728 bytes exhausted (tried
  to allocate 32 bytes) in /craft/app/helpers/StringHelper.php on line
  473

Here's a small code sample of what I'm doing

{!--
  `craft.locationAPI.fetchAllLocations` grabs ~200 entries with related data via custom SQL queries.
  Doing this because craft.entries was throwing memory limit errors.
--}

{% cache %}
  {% for entry in craft.locationAPI.fetchAllLocations() %}
    ...
  {% endfor %}
{% endcache %}

I'm guessing this is because the amount of data getting returned (~13300 lines in "View Source") is too large for the encodeMb4 function in StringHelper.php.

Anything I can do to avoid this?


texts: dateTime values in settings page are always a day behind

texts:
I've used this thread to successfully get my dateTime input fields to repopulate.

The problem I'm seeing now is that while values in the DB are correct, the field input values are always a day behind.

For example, the data in my DB looks like:

....
"startDate":{"date":"5\/4\/2015"}
....

But, the value that is getting rendered in the filed (from my settings page) is this:

5/3/2015

If I save the settings (no errors). The values in the DB will be 5/3/2015 - but then the field on my settings page will show: 5/2/2015

EDIT

Thank you @carlcs, I am sure you are right - I'm just not doing it...right.

Here is what I have tried:

MyPlugin.php

// this returns nothing when logged in error_log
$settings['myStartDate'] = DateTime::createFromString($settings['seasonStartDate']['date'] );

// this returns the date, but one day in the past
$settings['myStartDate'] = new DateTime( $settings['myStartDate']['date'] );

In my defineSettings() method, I am setting myStartDate to a Mixed type as there is a bug with dateTime.

  ....
  'myStartDate' => array(
       AttributeType::Mixed
   ),
   ....

I'm not exactly sure where prepSettings() should live. Here is the whole file:

MyPlugin.php

public function defineSettings()
    {
        return array(
            'myOpenings' => array(
                AttributeType::Number,
                'required' => true
            ),
            'myStartDate' => array(
                AttributeType::Mixed
            ),
            'myEndDate' => array(
                AttributeType::Mixed
            )
        );
    }

    public function getSettingsHtml()
    {
        $settings = $this->getSettings();

        if ( isset( $settings['myStartDate']['date'] ) )
        {
            $settings['myStartDate'] = DateTime::createFromString( $settings['myStartDate']['date'] );
         // $settings['myStartDate'] = new DateTime( $settings['myStartDate']['date'] );

            error_log($settings['myStartDate']);
        }

        if ( isset( $settings['myEndDate']['date'] ) )
        {
            $settings['myEndDate'] = new DateTime( $settings['myEndDate']['date'] );
        }

        return craft()->templates->render( 'plugin/_settings', array(
                    'settings' => $settings,
                ) );
    }

EDIT/SOLUTION

@carlcs and @Mats Mikkel Rummelhoff for their help.
For anyone coming to this post, here is what my "final" main plugin class file looks like hope it helps.

MyPlugin.php

....
public function defineSettings() {
    return array(
        'myOpenings' => array(AttributeType::Number, 'required'=>true),
        'myStartDate' => array(AttributeType::Mixed, 'required'=>true),
        'myEndDate' => array(AttributeType::Mixed, 'required'=>true)
    );
}

public function getSettingsHtml() {
    $settings = $this->getSettings();

    if(isset($settings['myStartDate']['date']))
    {
        $settings['myStartDate'] = DateTime::CreateFromString($settings['myStartDate']);
    }

    if(isset($settings['myEndDate']['date']))
    {
        $settings['myEndDate'] = DateTime::CreateFromString($settings['myEndDate']);
    }

    return craft()->templates->render('myplugin/_settings', array(
        'settings' => $settings
    ));
}


texts: Getting Craft's storage folder to work on Heroku

texts:
I'm using Heroku to host a Craft 3 site, and it's working fine, apart from the fact that Craft isn't able to write to the /storage folder (or anywhere else, for that matter). Consequently, the Database Backup utility doesn't work and nor is Craft able to write logs. I'm keen to fix both these issues.

Has anyone managed to solve this problem on Heroku? If so, how?


texts: Creating a guest entry, with a Matrix field, using Ajax

texts:
I'm trying to submit a guest entry by building a javascript array of objects to mimic a form submission and submit using ajax. I've managed to successfully submit the entry with just a title but when trying to add Matrix/Super Table rows I'm having no luck.

I've looked here https://github.com/engram-design/SuperTable/wiki/Updating-a-Super-Table-field-from-a-front-end-form to get ideas for how this should work.

Super table block handle is answers and the Super Table field I'm trying to submit is a plain text field with the handle question.

My current code is:

$('#submitQuiz').on('click', function (e) {
  e.preventDefault();

  var testEntrySubmission = [
    {
      name: 'action',
      value: 'guestEntries/saveEntry'
    },
    {
      name: 'sectionId',
      value: '5'
    },
    {
      name: 'enabled',
      value: '1'
    },
    {
      name: 'redirect',
      value: '/'
    },
    {
      name: 'title',
      value: 'user name'
    },
    {
      name: 'answers[new1][fields][question]',
      value: 'fingers crossed'
    }
  ];

  $.post('http://mywebsite.dev/', testEntrySubmission, function(response) {
    if (response.success) {
      console.log('success')
    } else {
      // response.error will be an object containing any validation errors that occurred, indexed by field name
      // e.g. response.error.fromName => ['From Name is required']
      alert('An error occurred. Please try again.');
    }
  });
});


texts: Element API Endpoint returns data but has 404 header

texts:
The url: https://www.fira.co.uk/fullmembers.json

is an endpoint for Craft's element API plugin.

It has been working fine until recently I did a few things:

I changed the site to https
There have been some tweaks to the server config (nginx caching etc)

The problem I am having is that the URL returns a 404 header but still displays the JSON response in the browser. This 404 is affecting my wget script that systematically saves the response to a static file, as to improve performance.

Any ideas why the endpoint would be behaving like this?

I haven't altered the elementapi.php recently but here it is:

<?php
namespace Craft;

return [
    'endpoints' => [
        'fullmembers.json' => [
            'elementType' => 'User',
            'criteria' => ['group' => 'fullMembership', 'limit' => null, 'order' => 'companyName'],
            'paginate' => false,
            'transformer' => function(UserModel $member) {
                // var_dump($member->memberAddress);
                $businessCategories = [];
                foreach ($member->businessTypeMarketSectorsProducts as $block) {
                    switch ($block->type->handle) {
                        case 'businessCategory':

                        $productValues = [];
                        foreach ($block->product as $prod) {
                            if ($prod->selected) {
                                $productValues[] = $prod->value;
                            }
                        }

                        $businessCategories[] = [
                            'businessType' => $block->businessType->value,
                            'marketSector' => $block->marketSector->value,
                            'product' => $productValues
                        ];

                        break;
                    }
                }
                // $urlslug = strtolower(implode('-',explode(" ", $member->membersCompanyName)));
                $urlslug = StringHelper::toKebabCase($member->membersCompanyName);

                return [
                    'id' => $member->id,
                    'companyName' => $member->membersCompanyName,
                    // 'memberAddress' => $member->memberAddress->attributes,
                    'lat' => $member->memberAddress->lat,
                    'lng' => $member->memberAddress->lng,
                    'city' => $member->memberAddress->city,
                    'street1' => $member->memberAddress->street1,
                    'street2' => $member->memberAddress->street2,
                    'street3' => $member->membersAddressLine3,
                    'zip' => $member->memberAddress->zip,
                    'country' => $member->memberAddress->country,
                    'email' => $member->email,
                    'phone' => $member->membersPhoneNumber,
                    'profile' => UrlHelper::getUrl("directory/company/{$member->id}/{$urlslug}"),
                    'businessCategories' => $businessCategories
                ];
            },
        ]
    ]
];


texts: _includes/forms documentation on field types

texts:
I'm trying to find any documentation on the usable forms from  {% import "_includes/forms" as forms %}
so for example I have no idea what the difference is between elementSelect and select or how I get the options in there

Thanks for your help


texts: How to add HTML, CSS, JavaScript on the front-end using a template hook in a plugin?

texts:
I'm trying to render my HTML, CSS, JavaScript with the use of template hooks from a plugin.

{% hook 'video.slider' %}

Is it possible? If it is, can you give some snippet?


texts: How can I setup sub domains on a single domain to allow development of multiple Craft client sites. I tried dev1.domain.com and dev2.domain.com and it tells me I need to upgrade license since I need the pro features. Sites are still on development. What is best naming convention?


texts:
Is there any way to change the default configuration for the Dashboard globally, or per user group?

I don't mind Sysadmins seeing the Blog & Tonic feed, but I don't want Members (who access the CP only to add calendar events) to see Blog & Tonic. It will just cause confusion for those users.


texts: Craft 3 auto-creates sub-folders in assets. How can I prevent this?

texts:
I use Google storage for photos. The Google storage volume is mapped to a bucket's subfolder.

Unfortunately these appear as subfolders in assets, along with a set of repeated folder structure. I did not create these.

Any way to prevent CraftCMS from creating them? What is the cause they get created?

P.S. Is it possible that they are the remainder of subfolders which I created on the filesystem before setting up the assets to use google storage? I did delete the local storage assets volume between creating the google storage one. But, the local storage did have the ahtletes/photos in the local assets folder.

At this time, the local assets folder does not have the athletes/photos subfolder.

I am trying to understand what action or process creates these folders?


texts: For loop that can accept array and element query without throwing .all deprecation error

texts:
I have a component that accepts both hardcoded objects and entry queries. This allows us to have components that can be used independent of the database.

Hardcode include:

{% include '_components/callToAction' with {
    headline: 'Hardcode call to CTA Headline',
    body: 'Hardcode call to CTA',
    items: [
      { name: 'item1'},
      { name: 'item2'}
    ]
} %}

db include:

{% include '_components/callToAction' with {
    entry: entry.callToAction
} %}

Component:

{% set component = {
  headline: headline ?? entry.headline ?? null,
  body: body ?? entry.body ?? null,
  items: items ?? entry.items ?? null
} %}

{{ component.headline }}

{{ component.body }}

{% for item in component.items %}
  {{ item.name }}
{% endfor %}

Both those work fine, but with Craft 3 we're getting deprecation errors for not using .all() when it is an element query which is drastically increasing our db queries on the pages that use several of these components.


texts:
I know it's possible, using modifyEntrySortableAttributes, to sort the CP entries table by a custom field, when that field is a number, string, date/time, or bool. Would it be possible to sort a CP table by category? If not, is there another hook, or some other way I could implement this functionality?

Sorting by number, string, date/time, bool:
In Craft 2.5, how can you sort the entry index page by a custom field?


texts:
I have installed Craft with Composer and have run the set up command.

When I type in my database name I always get the error:

Testing database credentials... failed: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

I have tried with a Mamp Pro server set up (restarted as per another post) and with a different username (I can't seem to set a password in terminal during the setup?).  Any ideas how I can get past this final hurdle?


texts:
I’m creating an archive of news article entries. For that purpose, I’m trying to get a value from a dropdown (user-selected year and month) and then assign it to a pagination procedure that calls up all articles of that particular year and month.

However, from what I’ve read so far, you cannot pass a Javascript variable to Twig. Is there any other possibility of passing on user selection to Twig?

Thanks! :)

<button class="btn btn-default dropdown-toggle text-sans" type="button" id="selectYear" data-toggle="dropdown">Year </button>

2015

2014

<button class="btn btn-default dropdown-toggle text-sans" type="button" id="selectMonth" data-toggle="dropdown">Month </button>

January

February

    ...

December

{% set firstDayOfMonth = JSYEAR ~ "-" ~ JSMONTH ~ "-01" %}
{% set daysInThisMonth = firstDayOfMonth|date('t') %}
{% set lastDayOfMonth  = JSYEAR ~ "-" ~ JSMONTH ~ "-" ~ daysInThisMonth %}
{% set thisMonthsEntries = craft.entries.section(category).postDate('and', '>= ' ~ firstDayOfMonth, '<= ' ~ lastDayOfMonth) %}
{% paginate thisMonthsEntries as pageEntries %}
   {% for date, articles in pageEntries | group("postDate|date('F Y')") %}
       ...


texts:
I'm trying to find a way to get tag data from a Model. Currently, I have a template that makes use of tags in an entry like this:

Codes: {% for tag in entry.codes %} {{ tag.title }}; {% endfor %}

When I create this template, I also need to send some of the data (specifically this data) to an API. Assuming I have an $entry object, how do I iterate through the tags that I need, or get an array with all the tags associated with an entry?


texts:
I've not managed to find any complete example of a custom mapping plugin for Search Plus—I'm wondering if anyone could steer me in the right direction?

In a nutshell what I'm wanting to do is to modify the standard Search Plus mapping to include the section handle. I think this is the function I need:

public function searchPlus_alterBasicItemMapping($mappedData, $orginalElement)
{
    $mappedData["sectionHandle"] = $section->handle;
    return $mappedData;
}

But I have no idea where to put it and how to get it to talk to the plugin...


texts: I've just updated to 2.5 and am now not able to see or find the text styling option in a text box. We use the formatting option across our site for different headers, quotes, etc. Am I missing something or is the feature gone?


texts:
I'm trying to display the postDate of Sprout Forms entries. The docs state that you can use standard Craft CMS tags. I tried:

{% for formEntry in craft.sproutForms.entries.formHandle('contact').order(asc) %}
   {{ formEntry.postDate|date('d F Y') }}
{% endfor %}

And all kind of variations but the system states no method or closure with the name "postDate". All other fields output fine.


texts: Sprout reports timing out on thousands of records

texts:
I have sprout reports (twig template) exporting tens of thousands of records. Problem is that its timing out. I appreciate that this is expected and my only likely option is to up the server spec.
Is there anything i can do to optimise the report itself? e.g, through tasks where it exports the report over a period of time rather than all in one go?


texts:
I am trying to use a variable, based on an entry field, to load a form with a Twig include. The code is pretty straightforward:

{% set theForm = entry.formSelect %}
{% include theForm %}

Doing this throws this error:

  Undefined property: Craft\SingleOptionFieldData::$cacheKey

If I print the variable, it looks exactly as you would expect, e.g. forms/_basic

Any suggestions would be appreciated!


texts: Having issues looping through variants for Commerce 2 Products using Element API

texts:
I'm currently able to return the first variant using the following:

<?php
use craft\commerce\elements\Product;
use craft\helpers\UrlHelper;

return [
  'endpoints' => [
    'products.json' => function () {
      return [
        'elementType' => Product::class,
        'paginate' => false,
        'pretty' => true,
        'criteria' => [
          // 'id' => $productId,
        ],
        'transformer' => function (Product $product) {
          foreach ( $product->getVariants() as $variant ) {
            $variants = [
              'type'          => $product->type->name,
              'title'         => $variant->title,
              'sku'           => $variant->sku,
              'price'         => $variant->price,
              'stock'         => $variant->stock,
              'intro'         => $variant->intro,
              'purchasableId' => (int) $variant->purchasableId,
              'status'        => $variant->status,
              'url'           => $variant->url,
              // 'productPhoto'  => $variant->productPhoto
            ];
          }

          return $variants;
        }
      ];
    }
  ]
]
?>

Which returns:

{
  data: [
    {
      type: "Shakes",
      title: "3 Month Supply",
      sku: "mvn-a03m",
      price: "100.0000",
      stock: "0",
      intro: "
This is another 3M variant
",
      purchasableId: 37,
      status: "enabled",
      url: "https://testing.kamicrafted.com/shop/products/mavenshake?variant=37"
    }
  ]
}

The issue is that I currently have 3 variants set for this product yet the json response only shows the last variant within the set.

I'm completely stumped at this point and was hoping someone had a similar experience with a solution to this issue.


texts: How can I pass a variable defined in a Controller to my variables?

texts: In my Craft 3 plugin I would like to pass a variable defined in my Controller to my PluginVariable.php file. Is this possible?


texts: Element type vs. Field type - or: Element type without database storage?

texts:
I have already searched for information on this topic but I did not find much. I hope I did not overlook something.

My problem is the following: I want to try to write a plugin that lists entries from an external service via API calls. I have already done this in Craft2 with a custom field type (a dropdown-field) that listed all available elements.

Now for Craft3, I want to go one step further and implement a Modal like the AssetPicker where the user can list elements in a table or thumbnail view or even search for one.

Making the API-calls is easy. Nothing to fancy there. However, I struggle with how to integrate it into craft and how to do the templating.

I started with a custom FieldType like I did the last time. However, I am not sure whether it would be better to use an Element Type? As far as I understand, Element Types store their entries in the database, which I do not plan to do, since I access a remote database via an API. I only want to store the item-id in my custom field. On the other hand, I have the feeling that there are already available functions like  Craft.createElementSelectorModal() that implement many functions I need and work great with custom Element Types.

I do not yet totally understand the concepts of element types and field types and how they differ. If you have good sources of documentation, I am also thankful for that, especially information on how to use the ElementSelectorModal. I did not find much information about this.

In summary:

Would you suggest using a custom field type or custom element type?
Is it possible to use custom element types without storing everything in a database?
Do you have any good resources of information on these topics?
Do you have good resources of information about the ElemetSelectorModal?

Thank you so much for your help.

If I did overlook an answer to my question, already available on this platform, please feel free to refer to it.

Update

I have read a lot now about modals, for example:

Is it possible to use the ElementType Modal UI for a custom Field Type Plugin?
How can my plugin generate a generic modal window in the Control Panel?
Possible to override Garnish.Modal? [Plugin]

And I found this post, which almost exactly describes my problem: Use Entries fieldtype functionality in plugin populated by REST api data, however, some of the linked entries are not accessible to me and it referred to Craft 2.0, not version 3.

I understand that I can build my own modal using the Garnish-code. However, I would love to use the already existing functionality of the element type-modal. Therefore my question is:

Is it possible to define a custom element type without a database storage connected to it?

I considered copying all API-results into the database and update it regularly by a cronjob. However, this duplicated the content from the external source which is unnecessary in my eyes. I would rather love to "populate" a custom field type "on the go" by a API-call, without writing it to the database. Is there any way to do this?


texts: How to get the previous or next two entries with images and

texts:
To expand upon How to get the previous or next two entries I was wondering how I can also add the image and an input from each entry.

I have simplified the html-structure in this example but essentially what I want to add is:
entry.portfolioImage.one and row.kundenavn from row in entry.kunde.

The links and entry title is working.

{# Set parameters for prev/next elements list #}
{% set params = craft.entries.section('portfolio').order('title desc') %}

{# Get the prev/next elements #}
{% set prevEntry = entry.getPrev(params) %}
{% set nextEntry = entry.getNext(params) %}

{# And make sure to only output the links if the element exists #}
{% if prevEntry %}

{{ prevEntry.title }}

      {% for row in entry.kunde %}
          {{ row.kundenavn }}
      {% endfor %}

{% endif %}
{% if nextEntry %}

{{ nextEntry.title }}

      {% for row in entry.kunde %}
          {{ row.kundenavn }}
      {% endfor %}

{% endif %}


texts: Use a UUID for an entry ID in a URL path

texts: When setting an "Entry URI Format" for a section, the values currently available to me are {slug} which is the title of the entry, or {id} which is usually a small number. I'd like to have an obfuscated hash/uuid for this path, eg c54be165-fc95-4583-bef8-2e2abd2a4f37. Is this possible without writing any custom code?


texts: Prevent Rich Text editor from removing code tags?

texts:
In one of the Rich Text Fields I'm entering little snippets like this:

  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility !important;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, .004);

However, each time i edit again it removes the value although when i save it the first time its ok. I think its converting at edit time.

Is there anyway to prevent redactor from doing this?


texts:
Is there a way/workaround for using "duplicate" slugs?

Example:

shop.com/candy (category page with listing of candy's)
shop.com/about-us/candy (plain page with info about the production process etc)

Normally Craft will automatically generate for the second slug "candy-1".


texts:
Is there a way to change the email address stored in the craft_systemsettings table?

I guess this was originally setup when installing Craft but now I need to change it. I've changed the email address in the user account but this is not modifying the craft_systemsettings table. I could go into the phpMyAdmin and modify the MySQL but this feels like quite a clunky process.

Is there a better way?


texts: Enable client to add users to user group but not set permissions

texts:
I need my client (typical editor account in CMS) to be able to add/modify/delete users in the CP. I don't want him to have access to groups/permissions for users, but I need to put every user he creates into the same group (Site Users).

The existing plugin - https://github.com/lindseydiloreto/craft-autoassignusergroup - doesn't work if the client doesn't have the "Assign user groups and permissions" checked.

Is there a way to force every new user created in the CP by the client into a default group? Or a way to give him "Assign user groups" but not "and permissions"?


texts: Is there documentation on Craft.AdminTable?

texts:
My plugin has a many-to-many relationship and I would like to build a "associate" form with search/sort, and an icon to save selected record in the assoication table.   It would be great to leverage the Craft AdminTable feature, but I need to extend the 'deleteIcon' action.

Any suggestions?


texts: Errors with Craft 2.3, Imagine and Imagick

texts:
Does anyone else have the same issue?

Post the recent Craft 2.3 update all image transforms on my server (about 6 craft sites now) are throwing errors on new transforms.

Specifically write errors from the Imagine library's Imagick classes.

My directories are writable and these sites have been working for some time. No new updates on the server, standard Debian lamp stack.


texts: Replacing content a specific URL/page already reserved in Structured Data Entries

texts:
I have a site that I've created a 'Generic Page' type for that is a Structured type with URL Format of {slug}.

This is great for the client as they can create an entry for 'toplevelpage' and then children e.g. 'toplevelpage/firstchild' and the URL structure works as desired.

In a few places, they have custom pages that are not Structured type 'Generic Page' entries but need to sit in that same site URL structure. For example, toplevelpage/fistchild is a 'Generic Page' but they need a toplevelpage/customchild but the parent URL is now owned by the Structured type.

Can I get Craft or Twig to look for Singles or even Twig magic at that level and then just have a stub structured Generic Page that has is content overwritten?


texts: Gitignore pattern to remove image transforms

texts: Not sure on the gitignore pattern I need to add to ignore craft's image transforms it automatically generates. Any ideas?


texts: How can I iterate through an array of field handles for an entry?

texts:
Background:

One of my templates has up to 6 fields that should each go into the same markup. Here's an example with a courseDesign field:

{% if entry.courseDesign|length %}

Course Design

    {{ entry.courseDesign }}

{% endif %}

This worked fine when I wrote each section out like this. However, once I also added a table of contents/nav, I decided to refactor.

I now have a courseFields array, and I'm adding each field to it if it exists:

{% set courseFields = {} %}
{% if entry.courseDesign %}
  {% set courseFields = courseFields|merge({ "courseDesign": { handle: "courseDesign", title: "Course Design" } }) %}
{% endif %}

My navigation macro works perfectly, because it's only interacting with the objects in the courseFields array.

My problem:

I can't figure out how to iterate through my fields and get the actual content from them using a macro.

If I use {{ entry.handle }} in my macro, even when handle is a valid field handle, I get the runtime error Variable "entry" does not exist.

I also tried:

{% set courseField = "entry." ~handle %}
{{ courseField }}

but that produces a string: "entry.courseDesign".

How do I access entry from my macro? Should I be going about this a different way?


texts:
Just Playing around with Craft and get this kind of error:

If I create a new locale and go to add it to a previously made section I get

  Internal Server Error -> Undefined offset: 0

I noticed that if I create a section after adding the locale I can then edit/remove/re-add locales without errors

(I'm on osx MAMP PRO - php 5.3.28 a module)


texts: Match to Existing Category on FeedMe Entry Import JSON

texts:
I've successfully exported product entries out of an ancient version of ExpressionEngine (1.7.1) into a JSON file and for the most part I've successfully imported that JSON using FeedMe—except for two things: Categories and a field that is a Dropdown menu in Craft.
The most important thing is the Categories (I can live without the dropdown field if I have to), but I thought I'd mention it because I thought the solutions might be related.
In Craft I have a Category Group with Existing Categories. What I want to do is have the entries I import match into those existing categories; the Craft Categories are an exact copy of the old ExpressionEngine categories so they are exactly the same.
I can't figure out what FeedMe/Craft is looking for to "match" the JSON category field to the corresponding existing category. I've tried the cat name and the cat slug. I've also tried Cat Id but I'm not sure I had the right Id value (I couldn't find an obvious place where the Cat Id is listed in Craft so I did an export on the Categories page and tried what I found in there).
Here is a simplified version of the JSON I'm importing:
[
  {
    "title": "Product: A type of Chair",
    "dropdown": "Chair",
    "category": "Wing Chair",
    "description": "Text here"
  }
]

I actully have many more fields, which all import fine, but the category and dropdown won't no matter what I try.
In the FeedMe Content Fields when I choose the Feed Element for the Category field (which I'm able to select) but under it there is a drop down with instructions that say:
Data provided for this category is:
And the drop down is a listing of all the possible Craft fields, EXCEPT for the Craft Category field; so I'm completely confused by this.
I'm sure this is something basic that I'm just missing, but I'm new to Craft/FeedMe and none of the other quesions on here that I could find were matching existing categories.


texts:
I am located in Austria using Pixel & Tonic's Store Hours Plugin. The Timezone in Craft's settings is set to UTC+1 (CET) - Europe/Vienna.

When I type in that it's opened from 3 - 6pm it outputs that it's opened from 2 - 5pm.

I guess that it is outputting the UTC but I can't really figure out why and how to fix it.
Is that possibly a bug in the plugin or is it meant to be adjusted in the template anyway?

Any help will be appreciated.


texts: Image Transform of Transparent Images results with Black Background

texts:
As the title suggests, I am receiving a black background on my transparent PNGs. I'd prefer them to be white. I have enabled imagemagick in the config file but still no dice. I noticed GD library applies a similar black background so I'm thinking it's the process of conversion in Craft. Any suggestions?

See here:

CRAFT
http://staging.munacosealing.com/products/cut-gaskets-custom-gasekts-oem-gaskets-prototype-gaskets-asme-gaskets


texts: Element API: return a related entry's asset data with entry data

texts:
I'm producing a list of entries that each use an image asset from a related entry.  I see in this ticket how to get an asset's data, and I've combined that with how I learned to output an object's data from a Mijingo video (via the array_map function).

This approach works, but seeing how there are about 130 entries in the section, the load time is a whopping 2.31s versus when I take out the related entry's asset code, which then results in a much smaller 500ms load time.  Is there a better way to access this data?

Here's the code I'm using:

return [
    'endpoints' => [
        'api/pressEntries.json' => [
            'elementType' => 'Entry',
            'criteria' => ['section' => 'pressEntries'],
            'transformer' => function(EntryModel $entry) {
                return [
                    'id'                => $entry->id,
                    'title'             => $entry->title,
                    'slug'              => $entry->slug,
                    'postDate'          => $entry->postDate,
                    'type'              => $entry->type->name,
                    'url'               => $entry->url,
                    'jsonUrl'           => UrlHelper::getUrl("api/press/{$entry->id}.json"),
                    'relatedRecording'  => array_map(function(EntryModel $album) {
                        $data = [
                            'id'    => $album->id,
                            'title' => $album->title,
                        ];

                        $artwork = $album->recordingArtwork->first();
                        if ($artwork) {
                            $data['artwork'] = $artwork->url;
                        }
                        return $data;

                    }, $entry->relatedRecording->find()),
                ];
            },
        ]
    ]
];


texts: Craft Commerce - Advanced Product Options & Pricing

texts:
What are the options for creating advanced product options with pricing.
I see there are way to create variants ok - but can this be linked to advanced pricing, e.g. for printing products.
the abaility to select different sizes, material, finish etc all which affect the price and then the quantity which also affects the price.

Similar options which you can see here - https://www.gogetprint.com/business-cards.


texts: Freeform 3.X Can you post form from JamStack (full VueJS, React) websites?

texts:
I can't find any documentation concerning the use of the plugin Freeform from external websites made using VueJS/React etc..
Is it possible ?
Also, can you retrieve a form's Modeling (with fields, field's type etc)
If not, are there any alternatives not to have to use PHP Templates ?


texts: I want to have the option to have social media icons that will link to different URLs. I currently have it set up so the user can click which icons will display on the page, but how would I have it so they can change the link to what URL they want?


texts: JS tag is adding semicolons to my content

texts:
I'm trying to output matrix content to create a javascript for my gallery. When I wrap the output with the {% js %}tag each line has an extra semicolon at the end like this:
{ "src": "/assets/uploads/_wsHigh/cp_slideshow_lg_img1.jpg", "width":"1440", "height":"810" },;
{ "src": "/assets/uploads/_wsHigh/cp_slideshow_lg_img2.jpg", "width":"1440", "height":"810" },;

If I output as text its not there. How would I get rid of it?
 {% js %}

{% if image %}
{%- if loop.first -%}
window.addEventListener('DOMContentLoaded', function() {
    (function($) {
$('.slider-pop').on('click', function() {
         $(this).lightGallery({
             dynamic: true,
             download: false,
             zoom: false,
             hash: false,
             dynamicEl: [{% endif %}{%- if not loop.last -%}{ "src": "{{ image.getUrl('wsHigh') }}", "width":"{{ img.getWidth('wsHigh') }}", "height":"{{ img.getHeight('wsHigh') }}" },{% endif %}
             {%- if loop.last -%}{ "src": "{{ image.getUrl('wsHigh') }}", "width":"{{ img.getWidth('wsHigh') }}", "height":"{{ img.getHeight('wsHigh') }}" }]
         })
     });
     })(jQuery);
     });
 {% endif %}{% endif %}{% endjs %}


texts: Does Freeform Pro save partially completed entries or "drafts"?

texts: I'm building an 8-page registration form or application and was hoping to use Solspace's Freeform Pro. I have some experience with it, but not in all of the capacities I'm hoping to use it for on this project. I know that this plugin allows you to "Create" new users, which is one of my major requirements. The other is that the user can come back and edit their application if they need to before reaching the last page and pressing the final "submit" button. I read through the documentation and it said something about data being saved for 3 hours, which would not be enough. Is this possible to do with Freeform? If not, does anyone know of a way to accomplish this?