texts: How to skip fragments of code in Matrix?

texts:
I fell like I'm missing an obvious thing, how to end block before I will start the new one?

{% for block in entry.myMatrixField %}

{% if block.type == "heading" %}

{{ block.heading }}

I don't want this text to be part of heading block

{% elseif block.type == "text" %}

    {{ block.text|markdown }}

{% endif %}

{% endfor %}

edit: here is my real code:

{# "Check" section #}

{# "Check" block #}
            {% elseif block.type == "check" %}

{{ block.checkHeader }}

{{ block.checkText }}

{# In this place block "check" should end #}

{# end of "check" section#}

{#beginning of "gallery section" #}

Next look at this cool stuff

{# "gallery" block #}
            {% elseif block.type == "gallery" %}

{{ block.imageHeader }}

{{ block.imageText }}

{# In this place block "gallery" should end #}

See More


texts: How to store class variable inside a Craft controller

texts:
namespace Craft;

class Test_FormsController extends BaseController
{

   protected $allowAnonymous = true;
   public $session_id;

    public function actionApply(){
        $appl_template = "1";
        $this->session_id = 15558145;
        return $this->renderTemplate("apply/step".$appl_template.".html");
    }

    public function actionSaveDataStruct(){
        echo 'session:'.$this->session_id.'<br />';
        exit();
    }
}

Hi guys i'm newbie on Craft and my question is:

acctionApply loads form which will send to actionSaveDataStruct, I set a class variable $session_id on actionApply but whenever the form submitted and goes to actionSaveDataStruct, $this->session_id become null again, how do I set variable that will never reset whenever the page load?


texts: Advanced query/filter based on date and values

texts:
I have a channel of events with a field ‘eventDate’ for the date/time of the event. Within that there are ‘types’ of events ‘eventType’. What would be the most efficient way of outputting the NEXT (future date from now) that is of the ‘eventType’ equal to ‘Green’?

So far i’ve got

{% for event in craft.entries.section('events').order('eventDate asc') %}

Which will output the entries in the correct order based on the eventDate, but can i filter the query even further to include the conditionals to only output if the date is in the future like this conditional:

{% if event.eventDate|date("c") > now|date('c') %}

And also include the conditional to only output if the eventType == ‘green’ like so:

{% if event.eventType == ‘green’ %}

So that i can set the ‘limit’ to whatever i want and ONLY have the entries that meet the conditionals be included before that limit is applied?

I know that i can use the 'Search' like so:

{% for event in craft.entries.section('events').search('eventType:green').order('eventDate asc') %}

But A. Is that the most efficient and B. How do i also include only entries that are in the FUTURE from NOW based on the eventDate field?


texts: How to set CC or BCC emails to EmailModel?

texts:
Below is my code for sending mail and this is working fine but when i set cc or bcc mail is not sent them.

    $email = new EmailModel();
    $emailSettings = craft()->email->getSettings();

    $email->fromEmail = $emailSettings['emailAddress'];
    $email->replyTo   = $message->fromEmail;
    $email->sender    = $emailSettings['emailAddress'];
    $email->fromName  = $settings->prependSender . ($settings->prependSender && $message->fromName ? ' ' : '') . $message->fromName;
    $email->toEmail   = $toEmail;
    $email->cc   = explode(',', $message->fromEmail);
    $email->subject   = $settings->prependSubject . ($settings->prependSubject && $message->subject ? ' - ' : '') . $message->subject;
    $email->body      = $message->message;

    if ($message->attachment)
    {
        $email->addAttachment($message->attachment->getTempName(), $message->attachment->getName(), 'base64', $message->attachment->getType());
    }

    craft()->email->sendEmail($email);

please correct me where i wrong.

Thanks


texts:
On my development instance, I added a freeform form. Now I would like to deploy that form to the staging, or later, live site.

When committing my changes, I noticed that nothing was added to project.yaml. So I guess the changes are just saved in the DB and will not be synced at git-based deploy.

Is that by design? Can I enable useProjectConfigFile somewhere?

If not: how do I export the form definitions and deploy them to another instance? By MySQL?


texts: Iterate through all rows of specific page using Freeform?

texts:
Documentation (http://docs.solspace.com/craft/freeform/v2/template-objects/page.html#usage-in-templates) says you can iterate through all rows on CURRENT page or entire form.

I need all rows/fields at once but separated by page for an accordion.


texts: How to get an entry url from EVENT_AFTER_SAVE_ELEMENT callback?

texts:
In my plugin I am registering a callback for Elements::EVENT_AFTER_SAVE_ELEMENT event. Previously, in Craft2, I could access the URL of the saved entry from the $event parameter passed into the callback, like so: $event->params['entry']->getUrl().

However I can't figure out how to get a reference to the entry in the Event model in Craft 3. If I var_dump($event) I can see the data I want nested deep inside a private property which I cannot access.

How do I access the entry data from the event in Craft 3?


texts:
I'm looking to have a basic index page for my plugin, yet I can't seem to get index.html working for my plugin. But when I head to site.local/admin/plugin it displays 404 Template Not Found

I have the folders set up like so:
plugin/templates/index.html

I've read here that CP templates automatically get set up for this folder so there's no need to define routes for it.

  Plugins get a Control Panel template root added automatically, named
  after the plugin handle, which points to the templates/ folder within
  the plugin’s base source folder.

Am I missing something here?


texts: How to use different date format in front end form?

texts:
I have a date field on a front end form, currently with this HTML:
<input class=" date-picker startDate" type="text" id="startDate" name="fields[startDate]" value="">

I use a JQuery date-picker and have set its format to dd/mm/yyyy
The date displays in the field this format correct, but upon saving no date is saved. I guess its due to the format not being Crafts yyyy-mm-dd because if I set the date-picker format to this, it does save it OK. BUT I obviously dont want to display my dates like this.
How can I display dates in correct human date format in the fields, and save them to the DB correct? Do I need to process all dates in PHP in a plugin to the correct format first?
The field in Craft admin for the entry displays d/m/y OK and that saves.
Thanks


texts: Cannot connect to database with credentials provided in db.php

texts:
I'm trying to push a site live today and am running into a problem I'm having trouble solving. I have a staging site which is a subdomain on the live server and everything works fine there but when I try to load the live site I get the following error (strange characters and all):

  An exception has been thrown during the rendering of a template ("Craft can't connect to the database with the credentials in craft/config/db.php.") in "_includes/_main_nav" at line 19.

The only difference between the two config files is the database name in db.php and the siteUrl and fileSystemPath in general.php. I do have a multi-environment config based on the one at straughtupcraft.com but I don't see any other difference between my live and staging environments other then what is already noted above.

Anyone run across this problem yet? Solutions?

UPDATE:

index.php:

<?php

//die('hey');

// Path to your craft/ folder
$craftPath = '../craft';

// Do not edit below this line
$path = rtrim($craftPath, '/').'/app/index.php';

if (!is_file($path))
{
    exit('Could not find your craft/ folder. Please ensure that $craftPath is set correctly in '.__FILE__);
}

require_once $path;

// Check the SERVER_NAME variable ourselves
switch ($_SERVER['SERVER_NAME'])
{
    // If the SERVER_NAME variable matches our case,
    // assign the CRAFT_ENVIRONMENT variable a keyword
    // that identifies this environment that we can
    // use in our multi-environment config

    case 'site.com' :
        define('CRAFT_ENVIRONMENT', 'live');
        break;

    case 'staging.site.com' :
        define('CRAFT_ENVIRONMENT', 'staging');
        break;

    default :
        define('CRAFT_ENVIRONMENT', 'dev');
        break;
}

general.php

return array(
    '*' => array(
        'cpTrigger' => 'site_admin',
        'omitScriptNameInUrls' => true,
        'slugWordSeparator' => "_",
    ),
    'live' => array(
        'environmentVariables' => array(
            'siteUrl' => 'http://site.com',
            'fileSystemPath' => '/path/to/domains/site.com/html'
        )
    ),
    'staging' => array(
        'devMode' => true,
        'environmentVariables' => array(
            'siteUrl' => 'http://staging.site.com',
            'fileSystemPath' => '/path/to/domains/staging.site.com/html'
        )
    ),
    'dev' => array(
        'devMode' => true,
        'environmentVariables' => array(
            'siteUrl' => 'http://site.dev',
            'fileSystemPath' => '/users/stubear/sites/site/dev/html'
        )
    ),
);

db.php

return array(
    '*' => array(
        'tablePrefix' => 'craft',
    ),
    'live' => array(
        'server' => 'server',
        'user' => 'username',
        'password' => '********',
        'database' => 'craft_live_db',
    ),
    'staging' => array(
        'server' => 'server',
        'user' => 'username',
        'password' => '********',
        'database' => 'craft_staging_db',
    ),
    'dev' => array(
        'server' => 'localhost',
        'user' => 'root',
        'password' => 'root',
        'database' => 'site-dev',
    ),
);


texts:
I have a Craft CMS site set up that deploys through TeamCity and am trying to set up a build step to auto run "./craft project-config/sync".

I keep getting an error saying the file can't be found, I've changed the paths a dozen times to try and get it right but no luck.
Has anyone had experience with this or able to advise how to set this up?


texts: Is it possible to hide a custom field type plugin from the popup tab when double clicking an entry?

texts:
Is it possible to hide a custom field from the modal that appears when you double-click on a related entry inside a Entries field?

In other words, I don't want my custom field to be visible within the modal that comes from getEditorHtml.

===== Updated based on accepted answer below =====

Based on the accepted answer from @Tyler Willingham I used the following code in my plugin's main plugin file:

public function init()
{
    parent::init();
    if (craft()->request->isCpRequest()) {
        craft()->templates->includeJsResource('myPlugin/js/myJs.js');
    }
}


texts: Register front end member from admin area with password

texts:
I'm not certain if this is possible but what we want to do is the following:

Have an admin register a new user in the admin, including a password for them so that they can pass along these credentials along via offline channels - and then that user will log into a front end client area.

I don't think it's possible to add a password - which surprises me in terms of use-cases needing to manage new users subscriptions by someone else and wanting disseminate specific credentials.

Is this possible?

If not, is it possible to:

Register the new member in the admin (without a password)
Have a custom Activate Account email confirmation go to them to finish their account signup, prompting them to go to:
A page where they can complete this, adding their new password and then logging them into their client account area

Thanks!


texts: Joining sections (Channel) to query based on a related item attribute

texts:
I've been trying this for a while now, so might have read this before. Sorry about that, I'm struggling really hard to get this right. At first I tried (wrongly) with the eager load features.

I have two channels: events and shows. In the events you can select a show with an entry field. The shows items have a category attached. I need to filter the events, based on the category of the show

Like events with shows where show has category 1. They told me on the slack channel to join the tables I needed, but cannot manage to do it.


texts:
how do I able to track the visit number of entry?
Something like track view in Expression Engine.

I have try to find but don't have any source.


texts: Plugin RegisterUrlRulesEvent - cannot find Controller aciton -> 404

texts:
The error I'm getting:

HTTP 404 – Not Found – yii\web\NotFoundHttpException
Page not found.
↵
Caused by: Invalid Route – yii\base\InvalidRouteException
Unable to resolve the request "Expedweather/forecast-panel".

The plugin's base was made through https://pluginfactory.io, I've simply added to it.

Below are the relevant code excerpts which for some reason do not seem to work as intended.

// ./src/Expedweather.php::init
$map_page = 'data\/<range:\w+>\/<peak:\w+>\/<view:\w+>\/<parameter:\w+>';
$event->rules[$map_page] = 'expedweather/forecast-panel';
// ./src/controllers/DefaultController
protected $allowAnonymous = ['index', 'forecast-panel'];
public function actionForecastPanel() {...}

Any ideas and/or potential solutions?
The Regex routing seems to work fine, but it cannot find the DefaultController's Action.

This is on CraftCMS Version 3.3.0.1


texts:
I've a problem with this code. I get the error message:

  Impossible to invoke a method ("getUrl") on a null variable.

For this code:

{% if siteBgBlureFallback %}
    background-image: url({{ siteBgBlure.first().getUrl('bodyBg') }});
{% endif %}

Here is the full code:

{% if entry is defined %}
    {% set siteBg = entry.siteBg %}
    {% set siteBgBlure = entry.siteBgBlure %}
{% endif %}

{% set siteBgFallback = siteBgFallback.siteBg %}
{% set siteBgBlureFallback = siteBgFallback.siteBgBlure %}

.bg {
{% if siteBg is defined and siteBg is not empty %}
    {% if siteBg %}
        background-image: url({{ siteBg.first().getUrl('bodyBg') }});
    {% endif %}

{% else %}

    {% if siteBgFallback %}
        background-image: url({{ siteBgFallback.first().getUrl('bodyBg') }});
    {% endif %}
{% endif %}
}

.bgblure {
{% if siteBgBlure is defined and siteBgBlure is not empty %}
    {% if siteBgBlure %}
        background-image: url({{ siteBgBlure.first().getUrl('bodyBg') }});
    {% endif %}

{% else %}
    {% if siteBgBlureFallback %}
        background-image: url({{ siteBgBlureFallback.first().getUrl('bodyBg') }});
    {% endif %}
{% endif %}
}

I don't understand why the first three outputs work and the 4th won't work any more.

The backup fields have some pic in there.

Thx for your help :)


texts: Has anybody built a plugin or API integration with Xero or Cin7?

texts: Love hear thoughts on the complexity of this or if anyone has something off the shelf to offer. Thanks


texts: How to empty the Temporary Uploads folder and why can individual users not delete files within up this folder?

texts:
I am perhaps over looking something, but I cannot see anyway for an back-end user (not admin) to be able to remove/clean up their Temporary Uploads folder. As a full admin, I see the option to remove the assets.

However, when logged in as a user that has full rights for all assets but is not a 'admin' user there is no option to delete the temporary assets.

I have looked through the user permission settings and I cannot see anything relating to Temporary Uploads or any settings that can be enabled for this.
Is this an oversight/feature request or am I over looking something?
The other thing I think worth mentioning is that the list in the CMS is not reflecting what is actually in the Temporary Uploads folder on the server. So I don't think the asset indexing is quite working for Temporary Uploads but it is not a folder than can be re-index.

I would also like to know if there is an config setting or command that can be run periodically that would clean up all users Temporary Upload folders?
Thanks.


texts:
I'm trying to loop on locales to get the path to the current entry, but for the other locales (for a language switcher).

Here is my code:

{% set locales = craft.i18n.getSiteLocales() %}
{% for locale in locales %}

    {% set localeEntry = craft.entries.id(entry.id).locale(locale.id).first %}

        {{dump(localeEntry.locale)}}
        {{dump(localeEntry.getUrl()) }}

{% endfor %}

Results:

"en"
"http://website.dev/en/page"

"en_gb"
"http://website.dev/en/page"

"en_us"
"http://website.dev/en/page"

"de"
"http://website.dev/de/page"

The language only versions are fine en and de, though the language-location versions are incorrect. These are all set correctly in my config.

What am I doing wrong here?


texts:
This issue is occurring on Craft 2.9.2.
The assets are stored on Amazon AWS (S3).
When I try to uploaded a new asset (of any size, even very small), the progress bar moves to 100% position but remains on the screen, and the loader sprite in top right corner keeps going around. The same symptoms are described here. The post was of no help. There was an answer in that post, which links to here. Which was also of no help, as the suggested nginx.conf setting is already in place, and the php settings are more than adequate.
Nothing shows up in the craft error log.
Nothing shows up in the server (php) error log.
Can anyone suggest how I might go about troubleshooting this, or suggestions as to what the cause might be?


texts: Craft 3 - Programatically get all the values contained in a field of type category

texts:
I want to programmatically get all the values contained in a field of type category.

I am doing this on Elements::EVENT_AFTER_SAVE_ELEMENT.

If I dump $event->element->getFieldValue('productTheme') I get the field but I did't find how to go from there.

My final goal is to have the categories from the category field in an array (not all the categories in the category group, but only those selected in the field).


texts: How to create a custom query inside a plugin in Craft?

texts: Can you give an example of returning entries from a section in JSON format using a custom query?


texts: How can I use a where statement with grouped results?

texts:
I am grouping entries that have the same date together so that I only get a single date. Works great.

I would like to loop through each entry that has that date and I'm not having much luck. I want to show

Here is what I have so far:

{% for date, attempt in attempts|group('attemptDate') %}

        {{ date|date('M j, Y') }}
        {% if type == 'My Type' %}
            {# Get all entries where type = My Type & entry.attemptDate = date. #}
            {% set total = 0 %}
            {% count = 0 %}
            {% for ?? in ?? %} {#
                {% total = loop.index %}
                {% count = {# if value in myField is true #} %}
                {{ count }}/{{ total }}
            {% endfor %}
        {% endif %}

{% endfor %}

Thank you for any suggestions!


texts: Editing specific fields from a POSTed form in a plugin

texts:
I'm struggling to figure out how to do what I need to do, and I think it's more a lack of PHP skill than Craft/Commerce per-se.

I have a plugin that receives POSTed data such as this:

<input name="items[1][qty]" value="6" type="hidden">
<input name="items[1][note]" value="" type="hidden">
<input name="items[1][purchasableId]" value="164" type="hidden">
<input name="items[1][options][endDate]" value="2026-11-03" type="hidden">
<input name="items[1][options][friday]" value="2" type="hidden">
<input name="items[1][options][monday]" value="2" type="hidden">
<input name="items[1][options][startDate]" value="2016-11-05" type="hidden">
<input name="items[1][options][wednesday]" value="2" type="hidden">
<input name="items[1][options][uniqueCode]" value="1553135711" type="hidden">

<input name="items[2][qty]" value="6" type="hidden">
<input name="items[2][note]" value="" type="hidden">
<input name="items[2][purchasableId]" value="193" type="hidden">
<input name="items[2][options][endDate]" value="2026-11-03" type="hidden">
<input name="items[2][options][friday]" value="2" type="hidden">
<input name="items[2][options][monday]" value="2" type="hidden">
<input name="items[2][options][startDate]" value="2016-11-05" type="hidden">
<input name="items[2][options][wednesday]" value="2" type="hidden">
<input name="items[2][options][uniqueCode]" value="736114426" type="hidden">

I need to amend any and all inputs that represent a startDate (e.g., <input name="items[1][options][startDate]" value="2016-11-05" type="hidden"> ). Then hand over to the controller that's going to process the data.

In detail: this is a Commerce related thing using MultiAdd. I need to adjust those startDate values prior to handing off to MultiAdd to do it's thing. The pertinent bit of my plugin looks like this:

public function actionReorder() {
    ... a bunch of stuff relating to the cart ...

    // loop through all the inputs for line items and amend any startDate
        $items = craft()->request->getPost('items');

        ... magic happens here ? ...

    // ok now pass it all over to the multiAdd controller...
        craft()->runController('multiAdd/multiAdd');
}


texts: Route with unspecified number of segments

texts:
I have entry which has route like this:

category1/category2/.../entry-slug

There can be an unspecified number of categories - these are multilevel structure entries.

I want to add an entry edit page on the frontend. This page would have URL like this:

category1/category2/.../entry-slug/edit

How do I create route for this? In routes.php file, I need to put specific route segments into an array - how do I set "unspecified number of category segments"?

I fount on some Yii related forum information that it can be done using (.*) wildards, so i tried this:

(.*)/entry-slug/edit

But it didnt worked.


texts: Product Categories, Structures and Channels

texts:
We are currently updating a brochure website, separating a single list of products into a series of sub-categories. Currently, we have a "single" section to display all products, and then a "channel" which has two entry types (products & accessories). I am trying to work out how best to create the new site structure.

I would like to display a parent page which lists all products, but then 6 sub-pages which show only the products in that category. I use the word category without specifically meaning the Craft CMS category.

I have read other posts such as Structure(s) vs. Categories for product catalog and Difference between categories and structures but these don't seem to help. There seems to be a bit of confusion surrounding Craft categories, structures and using singles to divide the content.

How could we re-organise the existing content into this new structure?


texts: Craft CMS with local and flywheel setup?

texts: I have been using this blog https://medium.com/@madebyraygun/a-quick-and-easy-local-environment-for-craft-3-4fd7c7ff5815 as a reference but I cannot seem to connect to my database and get Craft working? The .dev connection gives me an error and when I click on start site I get a 503? Please help me.


texts: Using relatedTo, and/or and :empty/:notempty in queries

texts:
I got users that has 3 Entries fields in their profile: breadForMonday, breadForWednesday and breadForFriday.

I want to differentiate between users with 1, 2 or 3 selected entries. How would I use relatedTo together with and/or and :empty/:notempty?

Something like this:

{% set bread = craft.entries({ section: 'bread' }).limit(null) %}
{# Find users that have selected entries for two out of three fields #}
{% set users = craft.users({
    group: 'customers',
    relatedTo: [
        'and',
        { targetElement: bread, field: 'breadForMonday' },
        { targetElement: bread, field: 'breadForWednesday' }
    ]
}) %}


texts:
I'm using the plugin Redactor Extras https://github.com/elliotlewis/Redactor-Extras as I need be able to insert IDs to then anchor link to them.

However I'm finding the plugin adds the IDs as it should but on save they get stripped out. Oddly this plugin also allows you to add Classes which seems to be working but is still a bit temperamental.

Are there any settings I could try for Redactor to stop it doing this?


texts:
I've gotten locales up and running on a site, but would like it to automatically route to domain.com/no for norwegian visitors and domain.com/en for all other visitors. For the life of me, I seem incapable of finding a way using the built in functions.

Do I need to write a plugin to handle this or is there some clever trick I haven't thought of? Can't find anything on geolocation at all.


texts: Sprout Forms - Use Case - Retrieve/Store form data into a custom db table

texts:
We have a placement tool that is currently based on a proprietary PHP MVC framework.  We have a need to quickly build custom forms that contain various checkbox, radio and text fields.

We want to store/retrieve the entire form data in our database, outside of Craft, into a custom jsonb column, along with special key fields, etc.  We currently call our custom Craft plugins from our legacy framework via specified url/action and parameters (which displays the content in an iFrame).  We'd probably use the same method for forms as well, until we can migrate or go to a Vue.js/Headless Craft setup.

Other forms tools, I have reviewed, store the forms within Craft as 'submitted' forms.  We need to keep them in our own database.

Thanks!


texts:
I am building a site for a martial arts school. I want to add a repeating schedule to the site from Monday through Saturday so the user can edit classes and times when needed. What would be the best way to do this? Should I use a global, structure or something else?

Thanks.


texts: Forcing creation of all transformations for all assets

texts:
Regarding a similar question I only found the advice to delete a table in the database but because I don't like fiddling with the db very much I like to ask: Are there ways to force craft to generate all transformations for all assets/images?

There is such a function in ExpressionEngine in the CP and I try to replicate this behaviour. I also installed the ImageOptimize plugin for that reason but no luck with that also.

thank you very much!


texts:
I'm generating a PDF from a template using the Printmaker plugin.
My CSS is being picked up and rendered mostly correctly and
if the template is rendered to screen as HTML then the fonts work. However I can't get the fonts to work with the PDF generation.

Does anyone know what I need to do to get the font information embedded within the PDF?


texts: Importing Unix timestamp into date time field

texts:
I have a Unix timestamp in my feed (1457685095000) and I am trying to map it to the date created entry field and I have another that I am trying to map to a time input field.

The created date is setting the date to a wildly incorrect value and the time field isn't getting set at all.

Any help would be appreciated.


texts: DevMode Class 'Exception\RuntimeException' not found

texts:
We started getting this error inconsistently on our site, and now it's constant unless we turn devMode off. We have no idea what may be causing it, but it only happens on one page. With devMode turned off, this page loads as intended with no issues. Here's a stack trace of what's coming through:

Class 'Exception\RuntimeException' not found
/craft/app/framework/vendors/zend-escaper/Escaper.php(321)
/craft/app/framework/vendors/zend-escaper/Escaper.php(182): Escaper->toUtf8("[11:24:06.471][trace][system.db.CDbCommand] Executing SQL: UPDAT...")
/craft/app/framework/web/helpers/CJavaScript.php(35): Escaper->escapeJs("[11:24:06.471][trace][system.db.CDbCommand] Executing SQL: UPDAT...")
/craft/app/helpers/LoggingHelper.php(51): CJavaScript::quote("[11:24:06.471][trace][system.db.CDbCommand] Executing SQL: UPDAT...")
/craft/app/templates/logging/log-firebug.php(46): Craft\LoggingHelper::processFireBugLogEntry("trace", "11:24:06.471", "system.db.CDbCommand", "Executing SQL: UPDATE `craft_budhub_spend_analytics` SET `id`=:y...", ...)
/craft/app/framework/logging/CWebLogRoute.php(52): Craft\WebLogRoute->render("log", array(array("Loading "cache" application component in /var/www/thisisbud.dev/...", "trace", "system.CModule", 1499945046.3493, ...), array("Loading "path" application component in /var/www/thisisbud.dev/c...", "trace", "system.CModule", 1499945046.3495, ...), array("Loading "request" application component in /var/www/thisisbud.de...", "trace", "system.CModule", 1499945046.3497, ...), array("Serving "usePathInfo" from cache in /var/www/thisisbud.dev/craft...", "trace", "system.caching.Craft\FileCache", 1499945046.3501, ...), ...))
/craft/app/framework/logging/CLogRoute.php(104): CWebLogRoute->processLogs(array(array("$_COOKIE=array ( 'ccc7c40e11a9bcf94cb9cc672f7748a0username' =>...", "info", "application", 1499945046.3467), array("Loading "cache" application component in /var/www/thisisbud.dev/...", "trace", "system.CModule", 1499945046.3493, ...), array("Loading "path" application component in /var/www/thisisbud.dev/c...", "trace", "system.CModule", 1499945046.3495, ...), array("Loading "request" application component in /var/www/thisisbud.de...", "trace", "system.CModule", 1499945046.3497, ...), ...))

A few points that may help:

We are accessing and saving (encrypted) binary data to the DB, though we do this elsewhere on the site without issue.
The twig being loaded loads other pages too, which all run fine seperately
DevMode turned off, we can't see anything that's not working, but with devMode on, it's impossible to get past said error.

We've been wrestling with this for a while without any luck. Any help would be greatly appreciated!


texts: Search for Matrix Block by Date in plugin

texts:
I am trying to search for specific matrix blocks by date like so:

$criteria = craft()->elements->getCriteria(ElementType::MatrixBlock);

$criteria->ownerId = $entry->id;

$criteria->type = 'myMatrixBlockType';

$criteria->myMatrixBlockDateField = "2016-06-01 04:00:00";

$criteria->limit = 10;

$blocks = $criteria->find();

It seems that no matter what format the date is, all blocks from the matrix field in the entry are returned. Any help is appreciated!


texts: How can I use multi-environment configuration to set each root URL?

texts:
I'm building www.mynewcraftsite.com.au, but I also wanna create www.mynewcraftsite.dev which is a testing server to preview to my clients. I've heard that I can set this up with Craft without going through the drudgery of downloading/uploading databases and updating urls in the db, users ... etc.

I've been reading the Craft CMS documentation for "Multi-Environment Configs".  So far I've got this in my db.php file;

return array(
    //All environments
    '*' => array(
        'omitScriptNameInUrls' => true,
        'localhost' or '127.0.0.1'.
        'server' => 'localhost',
        'user' => 'dashing-print',
        'password' => 'f#$njEwFRn3&2',
        'database' => 'dashing-print',
        'tablePrefix' => 'craft'
    ),

    //Testing environment
    'www.mynewcraftsite.dev' => array(
        'siteUrl' => 'www.dashingprint.dev'
    ),

    //Live environment
    'www.mynewcraftsite.com.au' => array(
        'siteUrl' => 'www.dashingprint.com.au'
    )
);

It works EXCEPT when I go to www.mynewcraftsite.dev and then click on the links, I end up back on www.mynewcraftsite.com.au (eg. Instead of going to www.mynewcraftsite.dev/services, I go to www.mynewcraftsite.com.au/services. In order to get to the correct page I gotta write up the whole url www.mynewcraftsite.dev/service into the google chrome url bar.)

The siteURL property isn't doing anything, there's gotta be something else that I gotta stick in there in order to rewrite the urls.


texts: Count table field values in certain section

texts:
I would like to know, how many values are saved in the table field called "artikelnummer" with the field name "artikel". The section is called "bikes". I tried:

{% set entries = craft.entries.section('bikes') %}

{% for entry in entries %}
  {% for row in entry.artikelnummer %}
    {{ row.artikel|length }}
  {% endfor %}
{% endfor %}

Thanks!


texts: My site is down and I can't access the admin panel after attempting an automatic update

texts: I attempted to update my website by pressing the update button in the control panel. It failed and now site is down. How do I fix this? I don't have a backup to restore.


texts:
Medium has a feature (that's likely the groundwork for their paragraph commenting, among other things) that adds an id to every tag inside of an article. Like so

I'm interested in replicating the behavior with Craft, in such a way that I can then write queries like element = craft.entries.find(2).element.find(120)


texts:
I'm building a profile page for members on a site where members can change their password. I'm sending the request with ajax, and can successfully change password if I have the input name "password" correct with the users current password.

My problem is that I get a success-response, when I should have gotten an error-response. (Password isn't changed, but I have no way of telling the user there was en error).

My JS is something like this:

$.ajax({
    type: "POST",
    url: "",
    data: dataString,
    success: function(data) {
        console.log("Password successfully changed");
    },
    error: function(data) {
        console.log("Error. Password did not change");
    }
});


texts:
Quick preface - i'm a new to managing my own servers. I'm on Ubuntu 14.04 running Apache. I ran into some problems setting up Craft which i was hoping someone might be able to shed a bit of light on what i got wrong. I have a user with sudo privileges, lets say 'user1'.

I used a simple PHP script to find out what user PHP is running as:

<?php echo exec('whoami'); ?>

Which came out as 'www-data'. In terminal as 'user1' i created a new group 'craftpermissions' and added 'user1' and 'www-data' to this group. I then set the group 'craftpermissions' as the owner of the following directories:

/craft/app/
/craft/config/
/craft/storage/

I then set permissions on those three folders to 775 using:

sudo chmod -R 775 /var/www/myvirtualhostaddress/craft/app/

However when i visited mydomainname.com/index.php/admin/ i still got the error saying php could not write to the /config folder.

In the end i set permissions on the folder to 777 so i could crack on with installation and it worked fine, but i'd like to do it properly as i think 777 is a bit of a no-no? Or does it not matter too much if craft folder is one directory above my web root?

Any guidance much appreciated.

EDIT

for /craft/app everything is owned by craftpermissions except .. which is owned by the group created when i made user1:

drwxr-xr-x  7 user1 user1 4096 Aug 25 06:44 ..

does this refer to the directory above it? When i run on /craft/storage/ it appears as:

drwxrwxrwx 3 user1 craftpermissions 4096 Aug 25 09:18 .
drwxr-xr-x 7 user1 user1       4096 Aug 25 06:44 ..
drwxr-xr-x 6 www-data   www-data         4096 Aug 25 09:19 runtime.

/craft/config appears as

drwxrwxrwx 3 user1 craftpermissions 4096 Aug 25 09:19 .
drwxr-xr-x 7 user1 user1       4096 Aug 25 06:44 ..
-rwxrwxrwx 1 user1 craftpermissions  671 Aug 25 06:44 db.php
-rwxrwxrwx 1 user1 craftpermissions  220 Aug 25 06:44 general.php
-rw-r--r-- 1 www-data   www-data          255 Aug 25 09:19 license.key
drwxrwxrwx 2 user1 craftpermissions 4096 Aug 25 06:45 redactor
-rwxrwxrwx 1 user1 craftpermissions  844 Aug 25 06:44 routes.php


texts: Is there an available variable for the primary site URL in a multi-site CraftCMS setup? I need a variable that I can attach to my logo that will take the user back to the primary site. I could hard code this, however, the URL needs to be environment aware. For example, on my local environment, the link should be https://www.mysite.local and when on development, the link should be https://www.mysite.dev.


texts: Force default site for a specific page / entry

texts:
I have a site site.com that has a french and english version.
On one page / in one template I'm using a plugin that breaks when the site is switched to the french version site.com/fr/
To get around this, I want to force that template to always redirect to the default site. Something like this:
{% if currentSite.handle != 'default' %}
  **Force a reload using the default site**
{% endif %}

Any ideas? I'm using the great Siteswitcher plugin, but as far as I can tell that only let's you create links. I'd prefer not to have to do it by making a link and then using JS to trigger it.


texts: Does Craft have a discussion forum and ratings add-on?

texts:
I am thinking about switching to Craft from EE but need various add-ons such as a discussion forum and ratings function (with the ability to have sub-ratings), and advanced search. I did not see anything like that in the plugins page but wanted to be sure before making this decision.

Thanks,
Geoff


texts:
Doing my first site with Craft and UiKit framework I encountered a small problem with dropdown menu. Here is my code:

  {% set entries = craft.entries.section('spb') %}
  {% nav entry in entries %}

    {{ entry.title }}
    {% ifchildren %}

        {% children %}

    {% endifchildren %}

  {% endnav %}

The point is that my child element looks exactly like parent because it takes its structure. But I don't need neither "class" nor "data-uk-dropdown" element...

...

Is there any workaround? Thanks.


texts:
Hello!
I need a rating like Like/Dislike. That it would be possible to assign likes and sort posts by them. Are there any ready-made solutions?


texts: Pass Craft field object to JavaScript function

texts:
I need to pass an entire Craft object into a JavaScript function. I followed the instructions in this post, however this only covers passing in a string.

{% includeJsFile "/js/homepage.js" %}
{% set myJs %}
   playlistData('{{myObject}}');
{% endset %}
{% includeJs myJs %}

Any ideas?


texts: I have created a page for our website, but I do not know how to add it as a tab on the home page. How do I do that?


texts: How do I save a Matrix field with an asset block programmatically?

texts:
I'm trying to submit an Entry programmatically from the front end.  Everything works flawlessly, except, the asset fields never save.  I've dug and dug through the Entries, Elements, and Content Services.  Through similar Controllers; the Element Model.  I can't find any errors, and no matter what I do, nothing seems to happen with Assets.  Any ideas?

This is a simplified version of my html form:

<form method="post" action="" accept-charset="utf-8" enctype="multipart/form-data">
    <input type="hidden" name="action" value="plugin/save/saveEntry">

    <input type="hidden" name="title" value="Woo hoo">
    <input type="hidden" name="authorId" value="1">
    <input type="hidden" name="sectionId" value="10">
    <input type="hidden" name="locale" value="en_us">

    <input type="hidden" name="fields[matrixField]" value="">
    <input type="hidden" name="fields[matrixField][new1][type]" value="imageBlock">

Upload Your Photo

    <input type="hidden" name="fields[matrixField][new1][fields][image]" value="">
    <input type="file" name="fields[matrixField][new1][fields][image][]" />

    <button>Submit</button>

</form>

And here's a simplified version of my Controller/Service (all jammed in the Controller for the convenience of sharing)

<?php
namespace Craft;

class Plugin_SaveController extends BaseController
{
    public function actionSaveEntry()
    {
        $this->requirePostRequest();

        // Fields
        $entry = new EntryModel();
        $entry->sectionId  = 10;
        $entry->typeId     = 11;
        $entry->locale     = 'en_us';
        $entry->postDate   = date('Y-m-d');
        $entry->authorId   = 1;

        // Tell our content model where to look for custom fields
        $entry->setContentFromPost('fields');

        // Content
        $entry->getContent()->title = "Fancy Title";

        // Save the entry content
        craft()->entries->saveEntry($entry);

        $this->redirectToPostedUrl();

    }
}


texts:
A client is using Craft 2, which someone else set-up for them. We're not trying to change their set-up but would like to offer them a quick and easy way to archive their annual event.

I just assumed I could use anything to create a static archive, place it in an annual folder (2019, 2020, etc), then just point people to the files. The problem is is that we keep receiving Craft errors. When the files are on my computer either in using file:/// or localhost the archive works fine.

Placing the folder inside the craft folder or its subfolder' templates just generates an "An exception has been thrown during the rendering of a template" error". And placing it out of the Craft folder is forbidden (I figure they have the domain pointing directly to the CraftCMS folder rather than a public_html.

I'm just not certain how or if CraftCMS will just allow you to place self-contained static files o a server and allow them to be served when they are pointed to. Because it seems like no. Does this require a .htaccess change or did someone just really restrict what can be done with this set-up?

I should mention, my goal with the static archive, was so that they wouldn't have to change code, etc. The system wasn't designed to allow them to archive events. Technically, they are overwriting events each year, but a number of people are asking for historical data.


texts: Modify Craft locale inside Element API plugin?

texts:
I’m using the Element API plugin to retrieve my entries as JSON. It is available under the /api route. For getting entries in a different locale I pass a locale query param and use it inside the ElementQuery.

All works fine so far, BUT when I want to use Craft::t inside of a transformer, I get the translations from the main locale, because this is where my /api namespace lives.

Is it possible to modify the locale that Craft is set to, from inside the Element API plugin?


texts: Is Craft suitable for these specific document management goals?

texts:
I'm trying to get a good appreciation for Craft's current capabilities and maturity. I've seen the demo and the docs but there is definitely a learning curve and what appears to be a need for much more coding - some of which I'll certainly need to hire a developer to assist regardless of platform. I see sparse videos, don't see many third party addons either, and docs suggest creating object oriented code just to set up field attributes. Thank you for any guidance in advance.  I'll share a little about my goals.

Project: I'm creating a document management system that is the same as you've probably seen in many school libraries (doc title, a long abstract that summarizes the full doc, excerpt and several taxonomies that classify docs into doc type (research paper, proposed law, etc.), country of origin, organization creating the doc, etc. It also has some doc fields, e.g. document language, date published, etc. Some primary objectives:

(1) Create relationships between docs. For example, if a document has been translated into 3 other languages I'd like to be able to recognize all those related documents in the doc and display the translated documents in a list on the front end for easy access so a user can view the doc in their preferred language.

(2) Ajax based filtering system. This has me leaning toward ExpressionEngine / Wordpress because of the availability of a very well thought out ajax-based filtering system, e.g. Low Search. Wordpress has numerous plugins, including WP-Types (although overall EE seems a better document management solution). Quickly done, no need to program and reinvent the wheel. A filtering menu can appear in a sidebar and a user can gradually filter through the results, e.g. perform a search for "widget", see results, then refine by documents published between a certain date, then refine by country, language, etc. And you can add/remove these fields very easily.

(3) Document import/export. For example, export the document to Word, PDF, etc. What makes Craft intriguing is that fields are entered in discrete, identifiable elements. For example, what if I wanted to export just document headers for a long document, it seems Craft can theoretically accomplish this easily because every header is a discrete field. It takes more work on the back end for data entry (but there is no perfect system.)

(4) Document Version System. Another issue would be to track revisions of the document as it moves along, e.g. first proposal. First revision. Second revision. Submission for approval. Document approved. -- Each of these documents are different versions of the same document. I've seen some extra data types which leads me to believe that the ability to generate a list of these documents as being related might be better suited with Craft - although I'm not familiar enough to be sure. Don't see EE/WP having a better solution, just manual fields that would require each document to be updated or a macro which inserts data each time a new revision is added.

Thank you all for any comments or thoughts.


texts:
I have created an infinite loop by crossreferencing two includes to each other. On one page. My aim is to load pop up layers on a page (teachers and instruments) and have links to each other.

{#      include: _layer_instrument      #}

                        {{ teacher.title }}
{% include "includes/_layer_teacher" %}

{#     include: _layer_teacher         #}

                        {{ instrument.title }}
{% include "includes/_layer_instrument" %}

Is it possible to use ajax to not load the includes until they are needed?


texts:
I'd like to create a history section so logged in users can see which pages they have visited.

Is there a way to post an entry without using a form? So the user does not have to click to say he has visited a page, instead as soon as they visit the page it is logged into a history section (the user and the page slug)

I've thought about doing it with javascript but it seems a little messy. Is there a native neat way to do this? Or a simple way to achieve it with a plugin?

Thanks in advance :)


texts: How can I display fields from Field Layout Designer in the template?

texts:
I'm working on a plugin that lets you create multiple forms. For each form I have a Field Layout Designer that lets you add fields from the fields groups.

My question is how can I display those fields on the front end template..say a contact.html single page.

Basically the same way you add fields to entry types and they show up when you are adding an entry... but I would like this to render a form on user facing pages with all the fields.

Here is what I have so far: http://d.pr/f/1bHCX

EDIT:

So this is what I have so far, its getting somewhere, sort of.

In my front end index.html

{% set form = craft.formBuilder.getFormByHandle('testForm') %}

I get fieldLayout id with {{ form.fieldLayoutId}} = 69

And inside content block:

{% for item in form.getFieldLayout() %}
  {% include "_includes/fields" with {
    fields: item.getFields(),
    element: form
  } only %}
{% endfor %}

I get this error Impossible to invoke a method ("getField") on a string variable ("69")

So its great that I get fieldLayout id for specified form handle but now I need to figure how to get all the fields related to that fieldLayout. I understand the error message but maybe someone knows how to rewrite that for statement to get results I need?! :)

I guess I don't know how to query my db for the fields that belong to layoutId 69..

I need to get fieldId 15 and 16 to render on the front end.


texts: craft.users.admin boolean parameter... to quote or not to quote?

texts:
This may have been answered before but my searching has not come up with anything. I need clarification on when to quote and when not to quote the boolean in the admin criteria for craft.users in a Twig template.

I have a plugin that displays a table of users and the reason this came up is I needed to exclude the admins from the table. Easy you say, just use the admin parameter and set it to false. That's what I thought so I did this:

{% set users = craft.users.admin(false) %}

This however returned all the users. So I thought maybe it needs quoting and did this:

{% set users = craft.users.admin('false') %}

Hurray! This did exactly what I wanted. Then I thought what if I only wanted the admins and tried:

{% set users = craft.users.admin('true') %}

This however returned all users that are not admins, eh? Ok, what about:

{% set users = craft.users.admin(true) %}

Hurray again! Only admins.

So looking through the source I can see why the first unquoted false has no affect as it fails the if(criteria->admin){} and therefore does nothing. After that I got lost in parseParam() and arrayHelpers so if anyone could clarify to quote or not to quote (that is the question!) and if this is the expected behaviour. Seems a little strange you need to quote 'false' and not quote true to get the desired behaviour. I also tried passing the parameters as an object and the results were the same.


texts: When should I run queue/listen instead of queue/run?

texts:
Definitions from the documentation:

queue/run: runs all the queued-up jobs
queue/listen: listens to
the queue and runs new jobs

Example case:

The runQueueAutomatically config option is set to false, and a cron job is calling queue/run every minute: /1 * * * * /path/to/project/root/craft queue/run.

In this case:

Should I run queue/listen instead of queue/run?
Does calling a new
queue/run when a queue/run job is potentially still in process,
could caused queue issues?


texts: Craft 3: how can I set dynamic Base URL in sites setting?

texts:
Sites localized versions are setup using Base URL like this:

— http://{baseUrl}/en/
— http://{baseUrl}/fr/

But {baseUrl} variables are not transformed using craft.app.sites.getAllSites().

{% set sites = craft.app.sites.getAllSites() %}
{% for site in sites %}
    {{ site.baseUrl }}
    // → outputs http://{baseUrl}/locale/ instead of http://mywebsite.com/en/
{% endfor %}

Whereas baseUrl are set from general.php:

'aliases' => array(
    'basePath' => '/mywebsite.com/htdocs/',
    'baseUrl'  => 'http://www.mywebsite.com/'
),


texts: How to use LDAP for authentication in Craft CP (back end)

texts: Where only users in Active Directory can login to the Craft Control Panel.


texts: Freeform: Accessing form values to create subject

texts:
I'm trying to make specific subjects and submission titles so that it's easier to understand what kind of email we just received or what kind of submission it is in the Freeform Submissions page. I'm trying to access form values and entry variables to be used in these subjects and titles.

I've just tried to use form.fullName (fullName being a form field) into my auto-generated Submission Title (under Form Settings tab in composer), but received this error after hitting submit on the front-end:

  Neither the property "fullName" nor one of the methods "fullName()",
  "getfullName()"/"isfullName()" or "__call()" exist and have public
  access in class "Solspace\Freeform\Library\Composer\Components\Form"

While we're at it, is it also possible to get the entry title that the form has been injected into as a value to be used as well?

Ideally I'm looking for the naming convention: [form.name] entry.title - form.fullName

If perhaps an entry variable is not present, then it should gracefully degrade.


texts: Is defined conditional passing, yet causes a "do not have a method or closure named" error

texts:
Why is it that in the below, referencing stRow.caption causes an error despite being wrapped in an "if defined" check?

The error is:

  Craft\SuperTable_BlockModel and its behaviors do not have a method or
  closure named "caption".

I have to be doing something so catastrophically dumb that it's not sticking out yeah?

{% if stRow.caption is defined %}
    {% set caption = stRow.caption %} <<- This line causes the error
{% endif %}

Same with using a null coelescing operator or a ternary operand.

{{ stRow.caption ?? "" }} <<- This causes the error
-- or --
{{ stRow.caption is defined ? stRow.caption : "" }}  <<- This causes the error too!

All three of those should work.

Supertable: 1.0.4
Craft CMS: 2.6.2997


texts:
I want to point any domain.com/page to the www.domain.com/page without showing index.php in my urls.

I have a www and non-www A record pointing to an IP address.

How do I set up my .htaccess file to do this?


texts:
I'm trying to log in to the admin area of an local install but all that happens is the page refreshes and nothing happens. Digging deeper I found this in the log:

2016/03/09 09:16:38 [error] [exception.CException] exception
'CException' with message 'Property "Craft\SessionRecord.token" is not defined.'
in /craft/app/framework/base/CComponent.php:173

I've tried re-downloading the app folder from Craft (which updated the install to the latest version fine) and I've also disabled all plugins but the issue persists.

Has anyone else come across this error and know how to solve it? Thank you!

Stack trace:

2016/03/09 17:29:36 [error] [exception.CException] exception    'CException' with message 'Property "Craft\SessionRecord.token" is not  defined.' in /path/to/craft/app/framework/base/CComponent.php:173
Stack trace:
#0 /path/to/craft/app/framework/db/ar/CActiveRecord.php(162): CComponent->__set('token', 'ea2be7c4a632df0...')
#1 /path/to/craft/app/services/UserSessionService.php(728): CActiveRecord->__set('token', 'ea2be7c4a632df0...')
#2 /path/to/craft/app/services/UserSessionService.php(626): Craft\UserSessionService->storeSessionToken(Object(Craft\UserModel), 'ea2be7c4a632df0...')
#3 /path/to/craft/app/services/UserSessionService.php(549): Craft\UserSessionService->loginByUserId('1', false, true)
#4 /path/to/craft/app/controllers/UsersController.php(66): Craft\UserSessionService->login('impalondon', 'NewPassword', false)
#5 /path/to/craft/app/framework/web/actions/CInlineAction.php(49): Craft\UsersController->actionLogin()
#6 /path/to/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(Array)
#7 /path/to/craft/app/framework/web/CController.php(286): CController->runAction(Object(CInlineAction))
#8 /path/to/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#9 /path/to/craft/app/framework/web/CWebApplication.php(282): CController->run('login')
#10 /path/to/craft/app/etc/web/WebApp.php(815): CWebApplication->runController('users/login')
#11 /path/to/craft/app/etc/web/WebApp.php(285): Craft\WebApp-  >_processActionRequest()
#12 /path/to/craft/app/framework/base/CApplication.php(184): Craft\WebApp->processRequest()
#13 /path/to/craft/app/index.php(62): CApplication->run()
#14 /path/to/index.php(14): require_once('/Users/alecrits...')
#15 {main}
REQUEST_URI=/index.php/admin/actions/users/login
HTTP_REFERER=http://impalondon.dev/admin/login


texts: Efficient way to get all related entries assigned to matrix fields across a set of entries

texts:
I have a scenario where level 1 structure entries each have several to tens of level 2 child entries, and several to tens of entries in a different channel which are also allowed to be related to the level 1 structure entry.
'events' structure
  - event entry 'e'
    - child 1
    - child n
'articles' channel
  - article 1
  - article n:
      could be related to event 'e'
'people' channel
  - person 1
  - person n:
      could be related to a child of 'e' via a Matrix field
      and/or an article entry related to 'e' via a Matrix field

For each of the child entries and the article entries, there are Matrix fields in which one or more people entries can be related.
Other than looping through the set of children of 'e' and the set of related articles, and then through each of their Matrix rows to fetch their corresponding people entries, is there a cleverly more efficient way to get all the people entries used for event 'e'?

Update (revised)
Thanks, Ben, for pointing the way. Initially I couldn't get this to work but then I spotted my error. Here’s what now works a treat for the following specifics…
I have my child pages as sessions where:

Each child session has a Matrix field called eventProgramme

There are two Entries fields defined in this Matrix, one called speakers and one called chairs.

This works:
{% set people = craft.entries.section('people').relatedTo({
    sourceElement: sessions,
    field: 'eventProgramme'
})
.all() %}

It's cool that sourceElement can be an array such as sessions.
If I want to target a specific field I can just use something like field: 'eventProgramme.speakers'

One thing I don't understand is the distinction between targetElement and sourceElement. Only the latter works in this context.
Update 2
Doh! The difference between source and target element is clearly explained in the Docs but I had missed it:

"The source has the relational field where other elements are chosen."
"The target element is the one selected by the source"


texts:
I want to delete some of the tags that are entered in the system.

Since there is no way to do that in Control Panel, and there is not a valid plugin that can do this (know that from my previous question).

The only way to delete tags is in the database. So I found this comment. I think this is for CraftCMS 2, but is it still the same and for CraftCMS 3?


texts: assets.beforeSaveEntry to upload file to secondary location in addition to Amazon S3

texts:
Is it possible to grab file (mp3) that has been submitted as part of an entry and post it to a secondary location (Soundcloud via their API) before it gets stored to my asset source at Amazon S3?

To complicate things a bit, I am uploading multiple files per entry, each one having its own field. One is the produced file (field name mp3File) selection) and the others are the raw recordings (field name rawFiles).

It is produced file (mp3File) that I am wanting to push to SoundCloud with their API.

I have a handle on how the SoundCloud API works, what I need is to pass the file path to the SoundCloud API. I think it is probably better to do this while the file still resides on the server before it makes its way to Amazon. Or it could be that I don't understand the flow here at all.


texts:
I have two different sections that share the same category group that I want to display both on browser at the same time only if the category is the same. Doing that in Craft CMS is possible?

Thank you.


texts: Output postDate in a different language than CP

texts:
How to retrieve the postDate of an entry in a different language than the CP.
In the general config settings i have the following,

    'defaultCpLanguage' => 'en'

But i would like to display the dates in the frontend in a different language. As in translated month names. Is this possible?

I tried the following with no result:

    {{ entry.postDate | date("d/F/y", "Europe/Paris") }}
    {{entry.postDate.format("d F y")}} #}
    {{entry.postDate | date('d F Y')}}

The format works, but there is no translation.


texts:
From this incredibly helpful validation article(s), I found that:

  AttributeType::Mixed does not apply any validation rules

Ok cool. I am using two fields that are DateTime fields, but due to a known bug, a work-around is to make the field type Mixed.

Everything is working 100% - and I can't thank the community for their help.

However, in my settings page, I would (like) to have my start date (Mixed) and end date (Mixed) fields required.

This isn't a make-or-break deal, just curious if there is a way.

MyPlugin.php

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

EDIT

Hi Brad, they are attribute settings. I've updated to show the file(s) below. Thank you for your time!

_settings.html

....
{{
    forms.dateField({
        'label': "Start Date"|t,
        'instructions': "What week do we start?"|t,
        'required': true,
        'id': 'myStartDate',
        'name': 'myStartDate',
        'placeholder': 'mm/dd/yyyy',
        'value': settings.myStartDate,
        'errors': settings.getErrors('myStartDate')
    })
}}
....

MyPlugin.php

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

If I make the field type a DateTime, then the required works. Maybe it's all part of the same bug. If it is, that's cool. It's not a big deal I'm more curious if I'm doing something wrong for the field type since ::Mixed does not apply any validation rules.


texts: Is there a recommended way to handle address validation in Craft Commerce 3? I've searched around but haven't found a solution on this. Would this be better handled by a third-party service and/or javascript implementation?


texts: Trouble with "restricted" upload folders

texts:
I'm having some difficulty with "Restrict uploads to a single folder?" option on an Assets entry field. I find that when I upload an asset into the field, the asset folder gets created as expected, but the asset does not end up in the folder.

For example, if the author is SomeAuthor, a folder called 'SomeAuthor' gets created in the correct location in the Asset Source using the following dynamic path, set in the field setting as mentioned above:

{% if owner is defined %}{owner.author.username}{% elseif author is defined %}{author.username}{% endif %}

I'm using this to allow me to re-use the field on Matrix and non-Matrix sections, but the point is that the folder is created successfully. What isn't so successful is that the file does not end up inside that folder, but in the root of my Asset Source. I've tried combinations of logging in as the specified author, removing all the assets from the site. Re-indexing etc. etc. all to no avail.

Perhaps I'm looking in the wrong place.

Does anyone have any experience trying to achieve what I'm attempting?

The general context is I have separate users on the system, each responsible for a "project" page, along with permissions to create 'articles' and 'events' in the respective sections/channels. I want to have one asset folder per user, so that no matter where they upload assets, the assets end up in the same folder per user, so that user with username 'SomeAuthor's assets will end up in 'SomeAuthor' folder within my single site source. I am attempting to do this using this snippet above, which in theory should work considering the author.username is not changing...

EDIT

Since posting this, I have discovered that I had another assets field with a simpler "Restrict uploads to a single folder?" setting: {author.username|lower} that was creating the field, and not the field I was testing with the setting above! Doh...

I supposed the real question is, therefore, how can I get a dynamic path, like the one above, to work?


texts:
I have a list of forms which I want to sort by day:

{% set groupVerbund = 'datum.day' %}

{% set allSubmissions = craft.amForms.submissions({
   formHandle: 'reservation',
   limit: null}).find()
%}
{% set entriesByDay = allSubmissions | group(groupVerbund) %}

{% for entriesInDay in entriesByDay %}

    {% for entry in entriesInDay %}
      {% if loop.first %}
{{ entry.datum | date('d.m.Y') }}
{% endif %}

{{ entry.datum | date('d. M Y') }} | {{ entry.vorname }} {{ entry.nachname }}

    {% endfor %}

{% endfor %}

This works but there are two entries which just are at the wrong place:

Entries in: 22. Okt. 2016
------------------
22. Okt. 2016 | Name Surname
22. Okt. 2016 | Name Surname
22. Okt. 2016 | Name Surname
22. Okt. 2016 | Name Surname
22. Okt. 2016 | Name Surname
22. Okt. 2016 | Name Surname
22. Okt. 2016 | Name Surname
22. Okt. 2016 | Name Surname
22. Jan. 2017 | Name Surname // This one is wrong
22. Okt. 2016 | Name Surname
22. Okt. 2016 | Name Surname

Entries in: 13. Nov.2016
------------------
13. Nov. 2016 | Name Surname
13. Dez. 2016 | Name Surname // This one is wrong
13. Nov. 2016 | Name Surname

Everything else is at the right place except these two entries. {{ entry.datum}} is a custom date field so it's not possible to add a wrong date format.

How can this be?


texts: Duplicating shipping details from an Order into a Cart

texts:
Further from yesterday's Duplicate an existing Order as a new Cart in Commerce I need to step in front of MultiAdd to set up a couple of other things - such as to duplicate the Shipping details from the old order to the new cart.

I have been trying to do it as follows:

public function actionReorder()
{
    // basic security precautions
        $this->requirePostRequest();

    // get the current cart
        $cart = craft()->commerce_cart->getCart();

    // get the fields passed to us in the form
        $oldOrderNumber = craft()->request->getPost('oldOrderNumber');

    // get the 'old' order
        $oldOrder = craft()->commerce_orders->getOrderByNumber($oldOrderNumber);

    // set the shipping etc on the cart to the same as the old order
        $cart->shippingAddressId    = $oldOrder->shippingAddressId;
        $cart->shippingAddress      = $oldOrder->shippingAddress;
        $cart->shippingMethodHandle = $oldOrder->shippingMethodHandle;

    // ok now pass it all over to the multiAdd controller...
        craft()->runController('multiAdd/multiAdd');
}

This doesn't work because

  Property "Craft\Commerce_OrderModel.shippingMethodHandle" is read only.

I have also tried

if (!craft()->commerce_cart->setShippingMethod($cart, $oldOrder->shippingMethod, $error)) {
    $cart->addError('shippingMethod', $error);
    LogicPlugin::log("error adding shipping method to cart: " . $error, LogLevel::Error);
}

instead of $cart->shippingMethodHandle = $oldOrder->shippingMethodHandle;

But that doesn't appear to work either. It tells me that the Shipping method not available.

How should I go about doing this?

It's particularly problematic for me because my Commerce set up required the Shipping address to be set in order for the Product Options to work (the options are based on the address the cart will ship to).


texts: How to recreate symlinks to path-based plugins after moving to live server?

texts:
I have a couple of custom plugins for a site, which I successfully added by using path repositories in my composer.json file. However, when I upload the site to my staging server (via FTP - no SSH access or Git on this server), the symlinks in craft/vendor/myvendorname (which are automatically created during any composer update) won't upload. Thus, my site breaks, trying to load plugins which it cannot find.

I can manually upload the actual folders to that location (which is my fix for now), but that's not sustainable on an ongoing basis really.

Is there some way I can force Craft (or really Composer I suppose) to recreate those symlinks on the remote server? Or is this a case where I simply need SSH access so I can do it manually?


texts: What is the correct way to update a production site with composer?

texts:
I disable admin updates on production sites, and update Craft and its plugins by updating in the development environment, and then deploying to production using Git.
My basic process starts like this:

Update Craft/Plugins in the development environment
Commit updated composer.json and composer.lock
On production, pull changes from Git
Run composer install

What additional steps are necessary to ensure that the production site is updated correctly?
I'm aware that we still have to run:

./craft project-config/apply
./craft migrate/up

Should we also run these commands?

./craft clear-caches/all
./craft queue/run

Are there any other commands that should be run to help ensure a smooth update? Also, what is the correct order to run them in?
Thanks!


texts: Link to Category Index in Rich Text Field

texts:
I have a Category group set up with URLs enabled. I'm just wondering if it's possible to link to a Category Index from the Link feature within a Rich Text Field. I realize I can manually create my own link (i.e. /path/to/category) via "Insert Link"  but was looking for a dynamic link along the lines of the "Link to Entry" or "Link to an Asset" methods.

Craft 2.4 Support added!

http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/8126490-add-a-link-to-a-category-option-to-rich-text-fie


texts: Is there a way to override the template caching system?

texts:
We're in the process of building a restfull backend in craft. We had sluggish response times due to the amount of queries done by craft on a an entry listing. Each entry had about 3 levels of nesting and a list of 9 entries tool 10-13 seconds to render.

I've worked around this by outputting the json using twig and its cache. Now I've noticed that craft uses mysql to cache its data. Due to the amount of queries to this backend we will probably run out of its auto incremental key space. This platform has over 2 million unique visitors a day. (I've seen it before and it will happen)

Now my question is can I override the twig cache subsystem? For example use Redis so I can proactively notify middleware and/or frontend that caches have been cleared, so these tiers can regenerate the cache while still serving stale cache? And/or is there an event available inside the cache system so I can trigger on that?

Thanks in advance


texts: Remove br tags at start and end of parent tag, + remove whole instances of parent tag and br tags if no text

texts:
Anyone know regex when using "replace" to remove all br tags at start and end of tags:
So <foo>
Foo
</foo> or <foo>
Foo</foo> etc. becomes <foo>Foo</foo>
And entire instances of:
<foo>
</foo> or <foo>

</foo> etc. is all removed completely
^ Any number of
s, plus ignoring whitespace, plus accounting for
 and
?!


texts:
I have an entry with one asset field and i need to determine if the 'kind' of asset is either 'json' file or 'video' file. Basically I swap my HTML based on the return 'kind'.

Any help is greatly appreciated. Craft CMS beginner.

{% set videoEntries =  craft.entries({ section: 'mediaRoomVideos' }).find %}
{% if videoEntries is not empty %}

    {% for entry in videoEntries %}
        {% set asset = entry.mediaVideo.first() %}

        {% if asset %}

            {% set json = asset.kind('json') %}
                {% if json %}
                    Do Embedded Video
                {% else %}

                    <video width="320" height="240" controls>
                        <source src="{{ entry.mediaVideo.first.getUrl() }}">
                    </video>

                {% endif %}
        {% endif %}
    {% endfor %}
{% endif %}


texts:
Is it possible to route to a nice "Site is currently offline" error page if there is an issue connecting to the database?

Currently you'll see something like the message below which isn't very customer friendly.

An exception has been thrown during the rendering of a template ("Craft canâ€™t connect to the database with the credentials in craft/config/db.php.")


texts: Does Craft ActiveRecord require any special table column (dateUpdated, dateCreated,...)?

texts:
I have a custom data table PA in the Craft database. I create a craft\db\ActiveRecord model and I want load() and save() data to it. The result will be custom GridView table with CRUD in front end combined with cms pages.

When I call $model->save() it throws Exception:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'dateUpdated' in 'field list'

The SQL being executed was: UPDATE `PA` SET `background`='#ffff00', `dateUpdated`='2018-10-03 11:50:26'
WHERE `idPA`=17
Error Info: Array
(
[0] => 42S22
[1] => 1054
[2] => Unknown column 'dateUpdated' in 'field list'
)

Caused by: PDOException
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'dateUpdated' in 'field list'

What is the difference between craft\db\ActiveRecord and yii\db\ActiveRecord? Is there any recommendation how to use it?

Thanks.


texts: Why is my custom console command throwing Calling unknown method: ...getAcceptsJson?

texts:
I have a module with a console controller (ScriptsController):

namespace modules\vetscripts\console\controllers;

use yii\console\Controller;
use yii\console\ExitCode;
use modules\vetscripts\VetScripts;

class ScriptsController extends Controller
{
    public function actionExpiring()
    {
        VetScripts::$instance->scripts->expiringScripts();

        return ExitCode::OK;
    }
}

When I run it using $ ./craft vetscripts/scripts/expiring I get the following error and stack trace:

2019-08-05 11:35:24 [-][-][-][error][yii\base\UnknownMethodException] yii\base\UnknownMethodException: Calling unknown method: craft\console\Request::getAcceptsJson() in /Users/steven/Code/vetscripts/vendor/yiisoft/yii2/base/Component.php:300
Stack trace:
#0 /Users/steven/Code/vetscripts/vendor/craftcms/cms/src/web/Controller.php(189): yii\base\Component->__call('getAcceptsJson', Array)
#1 /Users/steven/Code/vetscripts/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('expiring', Array)
#2 /Users/steven/Code/vetscripts/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('vetscripts/scri...', Array)
#3 /Users/steven/Code/vetscripts/vendor/craftcms/cms/src/console/Application.php(93): yii\console\Application->runAction('vetscripts/scri...', Array)
#4 /Users/steven/Code/vetscripts/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('vetscripts/scri...', Array)
#5 /Users/steven/Code/vetscripts/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#6 /Users/steven/Code/vetscripts/craft(22): yii\base\Application->run()
#7 {main}

This is my first time attempting a custom console command, which I need to get a cron job up and running. Is there something I'm missing here?

Thanks!


texts:
I would like to get user query in my custom PHP plugin.

According to this document, the code would be like this.
https://docs.craftcms.com/v3/dev/element-queries/user-queries.html#example

$queryAllUsers_email = User::find()->email($new_email);
if (count($queryAllUsers_email) > 0) {
    // ...
}

User means Craft\Elements\User class.

However, the count is 0.

It would be grateful for me if you tell me what is wrong.


texts: What is the difference between dateModified, dateCreated and dateUpdated?

texts: Can someone explain exactly what each of the above refers to when talking about assets? In particular, the difference between dateModified and dateUpdated.


texts: Matrix with an entries field and need to grab category title

texts:
Any help would be greatly appreciated! I hope I explained my situation in enough detail to get the help that is needed.

Currently I have two channels that need to share information. This is going from one channel to an other.

Channel One is called Resellers
This information needs to be feed into my other channel called Products.
Reseller contains info about various resellers, places to purchase a product.
In this channel I have a field for Category. The category is actually a Country name. The rest of the fields are plain text.

Channel 2 is called Products
Products has various fields but I am interested in doing is pulling in info from Resellers and displaying it. I am able to pull in everything from Resellers except for the Category name.

In Products I have a matrix field that contains an entry field and a plain text field.
The entry field pulls in the information about each reseller.
The plain text field allows me to override a field from Reseller to display per product information. I got this part working without an issue.

What I am trying to create is the following structure:
Country name then under the country list out each reseller alphabetically.
You will see Country Name A, A means nothing it just shows alphabetical listing.

Country Name A

Reseller A
Reseller T

Country Name C

Reseller D
Reseller H
Reseller R
Reseller T

Below I have listed out my field handle names that are relevant to this issue.

From Resellers

rdCountry - field where category is selected from

I am able to pull in all other fields easily that are part of Resellers.

From Products

Matrix field - chooseResellers

Entries field - chooseReseller
Plain text field - customProductLink

Again I am able to display each reseller just fine. What I am having issues with is pulling in the Category/Country name. Once I pull in the country name I might need help with setting up my loop to display everything.

Thanks for your time and help, it is greatly appreciated!

EDIT:
So the below code seems to solve my issue listed above. Now I just gotta loop through everything correctly.

{% for entry in craft.entries.slug(entrySlug).find() %}
    {% for block in entry.chooseResellers %}
        {% for reseller in block.chooseReseller %}
            <h3>{{ reseller.rdCountry.first() }}</h3>
        {% endfor %}
    {% endfor %}{# /matrix #}
{% endfor %}{# /for product #}

EDIT TWO - the code solves part of the problem but I do not think will allow me to loop through everything as I was expecting. Help is appreciated!


texts: Mandrill integration not sending email for front-end registration form

texts:
Update Emails only send out when you're not logged in as admin from the registration form.

No errors received in dev mode, user created, but no activation email sent. Definitely not getting passed to Mandrill as Little Snitch checks outgoing connections.

The weird thing is, user activation from the admin does send an activation email.
Verify email addresses? in system > users is selected.

It should send an activation email out, right? Or are you supposed to activate every new user via admin?


texts: Is there a good way to eager load Craft's Element Relations through a plugin?

texts:
For a specific entry in a specific section I would like to eager load all associated data from the related elements.

Say that I know the related elements are from the following field types:

An assets field
An entries field

And I know the field handles or IDs. This isn't supposed to be a "catch all" solution, it can be on a case by case basis.

I want to eagerly load all of these elements (including their relationships should they have some, i.e., the related entries have related images).

How would I go about this in a plugin?

I know I can write a hook or a custom controller action, I'm more curious about how I'd setup the calls themselves. I can't use Yii's with for Active Record because that isn't setup in the entry record itself.

Note, this is similar to the following question, but more direct:
"Eager loading" of relations like Yii's "with" function


texts: How do I check what type my variable of (string, integer, boolean, array, dictionary,  etc)?


texts: How to write query with startdate = now?

texts:
I'm trying to make a query which has 2 conditions who has to be true both. In PHP I should use && to get this. startdate <= now && enddate >= now. How do I write this in Craft twig?
Tnx in advance!

{% set current = craft.entries.find({
    section:'exhibitions',
    startdate : "<= " ~ now.w3c(),
    enddate : ">= " ~ now.w3c(),
    order:'startdate'})
%}

{% if current|length %}
    Current exhibitions
    {% for exhibition in current %}
        {{ exhibition.title }}
    {% endfor %}
{% endif %}


texts:
On the cart page, I currently display items that have been added to the cart with:

{{ lineItem.description }}

What I want to do, rather than displaying the product name and variant title as one, is to split them. So that I can display the variant title separately from the product name.

What is the correct model for this?


texts: How can I interact with Users via the ElementAPI?

texts:
I am attempting to use the ElementAPI to check if a user is logged in or not. I've used the ElementAPI before to check/get entries for a given section, but never for user-based entries.

Here is my elementapi.php file:

<?php
namespace Craft;

return [
    'endpoints' => [
        'user/current.json' => [
            'elementType' => 'User',
            'criteria' => [
                'foo' => 'bar', // Not sure what to do here.
            ],
            'transformer' => function (EntryModel $user) {
                // Not sure about this either...
                if ($user->isCurrent) {
                    return [
                        'status' => true
                    ];
                } else {
                    return [
                        'status' => false
                    ];
                }
            },
        ]
    ]
];

I'm getting to the plugin, but It really is not happy with what I'm giving it:

Argument 1 passed to Craft\ConfigService::Craft\{closure}() must be an instance of Craft\EntryModel, instance of Craft\UserModel given

Pretty sure it has something to do with the criteria?


texts:
I've read all posts about localization and translation here and at Craft's documentation, but I still haven't found the answer.

What I want achieve here is having let's say UK instead of British English.

I found paragraph in documentation:

{{ "Welcome, {name}"|t({ name: user.friendlyName }) }}

that says: If your text contains dynamic variables, add tokens to the string where they should go, and pass an object to the t filter that contains their values

Could anything like that work by passing object to _locale.php in /translations folder and set other value? Tried, without effect.
Theoretically it could work, craft would pass the object of an active locale to our translation's file.

Any advice, so I don't waste time on something that can't be done.


texts:
I have a headline global.

I am trying to see if headline is editable by using this code block, but it is not working.

Can I use isEditable() with my headline global?

{% if headline.isEditable() %}

        Edit Headline

{% endif %}


texts: When accessing a Category url is there direct access to the Category's fields?

texts: I have setup a category group to use Url's. When navigating to that url does the template have direct access to that category's inputs like you would with and entry? Or do you have to use the segment and get the data that way?


texts: Getting Service Unavailable when setting up domain name

texts:
Currently I'm trying to push my deployed website to the actual domain name it needs to be under using DigitalOcean. The website works perfectly when accessing it directly from the droplets ip address.

I've set the name servers on GoDaddy to be Digital Ocean's, but when trying to access the Craft site at the domain name URL it throws a craft error saying

  "Service Unavailable,Our site is temporarily unavailable. Please try
  again later."

Is there something I need to do in Craft to make sure it knows about the domain name change?


texts: Craft 3 plugins - Logging in a separate *.log file

texts:
In Craft 2, it was possible to have your plugin log to a separate file. For example, it would record items to a myplugin.log file. You would simply be able to do it like this...

MyPlugin::log('Lorem ipsum');

However, I can't seem to figure out how this would be done in Craft 3. I've seen this answer, which demonstrates how to log items in Craft 3 in general. But that just dumps items into the shared web.log file.

How can I log items to myplugin.log in Craft 3?


texts:
Is it possible to move users along with their passwords? I can see the mapping option, but how do I output password in a template (I'm moving data between craft installations).

The below code does not work.

{% for user in craft.users().status(null).all() %}
    <password>{{user.password}}</password>
{% endfor %}


texts: Changing assets location in entries after moving them to a different volume

texts:
I've moved all the assets from a local volume to a DigitalOcean space (S3 compatible) and all new entries are using that volume. I've updated all assets fields to use that new location.
My problem is that all the old entries, previous to this change, are still referencing the local volume, even though the same assets are already in the cloud storage.
Is there a way to force Craft to update all assets entries to the new location? When looking at the database, all the older assets are associated with the local volume. I've tried reindexing everything but that didn't solve it. Can someone please point me in the right direction?
Thank you.


texts:
Some of the changes in craft 3 have been killing me. I know Yii does validation using the public rules function. Here is a rules function I grabbed from the MatrixBlockType model.

function rules()
{
    return [
        [['id', 'fieldId', 'sortOrder'], 'number', 'integerOnly' => true],
    ];
}

My question is simple. I for the life of me can't find where the validator number is defined. I'm assuming it validates using Yii's NumberValidator.php function but can't verify that. Any ideas on where I can find the number validator?


texts:
I have upgraded to Oauth (0.9.65) and Videos (1.0.23) but i'm getting an 'Recoverable error' when trying to edit a piece of content;

Argument 1 passed to Composer\Autoload\ClassLoader::addClassMap() must be an array, integer given, called in /craft/plugins/videos/vendor/composer/autoload_real.php on line 38 and defined

/craft/app/vendor/composer/ClassLoader.php(88)

public function addClassMap(array $classMap)

I wondered if anyone else has had this issue? I have tried re-uploading both plugins but the only way around at the moment is to disable the Videos plugin.


texts: Where is the documentation for creating templates/themes?

texts: How do I find documentation explaining how to build a theme in Craft CMS? Where do I put my theme's assets, like my CSS and JS files, and how do I reference those assets in my Twig templates?


texts:
I'm trying to run a check within my _layout.html' to remove the navigation bar if the user is on the homepage. I've tried with the following code below, but browsing to a page which is theindex.html` of a Channel breaks the code with the following error:

  Variable "entry" does not exist.

This is the code within my _layout.html

{% set handle = entry.section.handle %}
{% if handle == 'homepage' %}
{% else %}
  {% if not craft.app.user.isGuest %}
      {% set users = craft.users %}
      {% include '_navigation'%}
    {% else %}
  {% endif %}
{% endif %}


texts:
Hi I am using Craft CMS with the project config file to keep various environments in sync. This generally works fine but I have run into an issue with plugin settings.

I am using the Contact Forms Extension and want to use the reCaptcha on my production site but I want it disabled locally. If I enable it on my production site, it gets disabled every time I deploy as I have it disabled locally.

Is there anyway I can create a plugin settings config to override the project config file?


texts:
I'm getting a lot of noise in the logs from requests that are auto generated from browsers and spiders (like favico.ico, robots.txt, /home /news etc) that doesn't actually have any endpoints.

These get caught by index.php and throws

[yii\web\HttpException:404] yii\web\NotFoundHttpException: Template not found: new in /app/vendor/craftcms/cms/src/controllers/TemplatesController.php:93"

Which is causing a tremendous amount of noise. I would never consider a 404 a real error, so I would like to not log this at all in Craft (I can use access log aggregation for this).

However, I'm not sure how to go about it. I have already created a custom log component, to remove the logging of all server variables on error, and send outputs to stderr (because of docker), with yii2-streamlog.

My log config is as follows:

    'components' => [
        'log' => function() {
            return Craft::createObject([
                'class' => yii\log\Dispatcher::class,
                'targets' => [
                    [
                        'class' => codemix\streamlog\Target::class,
                        'url' => 'php://stderr',
                        'levels' => Logger::LEVEL_ERROR | Logger::LEVEL_WARNING,
                        'logVars' => []
                    ],

                ]
            ]);
        }
    ],


texts:
I've had a weird problem come up lately.

I'll be working in the admin site of my site, click on a link to an entry or field or whatever, and get redirected to /admin/install and I get a "Page Not Found" error. From that point on, I can't get to that page anymore. I can still go back and navigate to other pages. I've even tried logging out and logging back in, but that doesn't fix it.

I am, however, able to fix it by clearing all browser data (I'm using Chrome). This leads me to believe that it's some sort of local storage issue. However, I can't seem to narrow it down more than that. I've tried clearing out the cookies for just my site and that doesn't do the trick.

I'm not really sure what to look at next. I know this is pretty open-ended, but what else can I do to troubleshoot this issue? I'm more than happy to provide whatever additional information might be helpful.


texts: Commerce: How to update an order status via the frontend

texts: Is there a way to edit an orders status via a frontend template?


texts: Get entries based on multiple fields in controller

texts:
I am trying to get the entries based on multiple fields.
Fields can be of type tags, checkbox, radio box, and number.

In my controller currently what I tried is.

$extrafilter will be like

Array
(
    [0] => Array // other field
        (
            [handle] => amenities
            [value] => laundry
        )

    [1] => Array // tag field
        (
            [handle] => technologies
            [value] => 45
        )

)

Code to narrow down the result.

use Craft;
use craft\elements\Entry;
use craft\elements\db\ElementQuery;

$entryQuery = Entry::find();
$entryQuery->section($sectionName);

if ($extrafilter && !empty($extrafilter[0])) {
  $relatedTo = [];
  $fieldList = [];

  foreach ($extrafilter as $key => $value) {
     $relatedTo[] = $value['value'];
     $fieldList[] = $value['handle'];
  }

  $entryQuery->relatedTo = array(
        'targetElement' => array_merge(['and'], $relatedTo),
        'field' => $fieldList,
  );
}
$entries = $entryQuery->all();

This works for Tags but for other fields it dont give any result.

I checked these Questions

Display entries that meet multiple tag params


texts: Best method to update Craft on a live site to avoid losing data

texts:
What is the best way to update Craft on a live website? Preferably without losing any data?

There are a few ways to do this, and, can often be situational.
Essentially the main problem is potentially losing out on data that’s POSTed during the site being updated.

If a site is small: I often crawl the site before hand, making sure everything is cached with varnish, do a DB backup, then do the update locally (sync’d with the live DB), and then push & deploy the files. (Varnish holds the site up despite it being unusable behind the scenes). Even if the DB is a local, there is still downtime involved in updating it.

If a site is bigger, or the Craft versions differ dramatically: Though more time consuming, I would setup another directory on the same server (with an independent updated database), make sure it’s working on a test link, then switch the nginx config to point to the new directory for that site.

In any situation I think that all situations could be detrimental to a user. If a user has written out a long form which could potentially be submitted during an update, or, a client could be logged in to Craft, working on a big edit to a page and hit “save" (I know you can disable their access), but the same issue exists, when you use that feature too.


texts: Solution for Matrix-within-Matrix (or More Robust Table Fields)

texts:
I was wondering if anyone has stumbled on a good solution for including matrix-like fields within a matrix block. I’m working on a site where each page's is constructed in one big matrix with several block types (each representing a “row" in the page) like…

Introduction
Stats
Quotes
Bios
etc.

Blocks like Stats, Quotes, etc. can hold either just one, or several of these items, so right now the subfields look something like this:

Block Title
Stat 1: Number
Stat 1: Text
Stat 2: Number
Stat 2: Text …etc. up to Stat 6

Rather than having all these fields in view by default, it would (obviously) be best if the user were just adding Stats as rows in an inner table or Matrix. Initially I thought that using Table fields would be the fix, but in several cases I need to include fields that aren’t natively supported in in Tables (like Assets, Rich Text, etc.).

At the very least it would be nice to collapse some of the fields that are likely not going to be needed so they are out of the way (so in the example above, maybe show fields for the first 2 stats, hide field for the next 4).

Has anybody stumbled on a good solution (maybe a Plugin) for either allowing more field types within Tables, adding a Matrix to a Matrix block, or collapsing fields by default?

Also open to other suggestions … seems like a lot of sites take this “stacked rows” approach, so guessing I’m not alone here. Thanks!


texts:
After uploading the app-new folder to my server, renaming it and logging in to the admin area. The website responds with a 'System not available message' (in Dutch) for both front and admin end.

Resetting the app-old as the default app folder again does not solve the error message. I've cleared the storage/runtime/cache and storage/runtime/compiled_templates folder.

What actions are needed to restore the site to working order first, before going into the update again?


texts:
I upgraded Craft 2 to Craft 3.3. Sometimes I am getting an error in admin like below when saving entries or taking some URL.

  PHP Core Warning – yii\base\ErrorException Module 'newrelic' already loaded craft 3

Please help.


texts: Converting existing content to a different locale

texts:
I am in the process of building my first multilingual Craft site.

The site will have two languages:

English (default)
Spanish

When setting up the site, I chose U.S. English and Spanish - United States as the respective locales.

I am now thinking it might be better to keep the languages less specific to the United States and would like to switch the two to English and Spanish.

My question is if it is possible to do this without losing any content that has already been entered under both U.S. English and Spanish - United States.

Thanks!


texts: Assets upload and Update Asset Indexes issues

texts:
There seem to be some issues with asset uploading, and i can't figure out what the problem is. Here's a summary:

After uploading an asset it doesn't show up in the Assets listing
If i do a 'Update Assets Indexes' it says this about files 'The following files could not be found. Should they be deleted from the index?'
If i run 'Update Assets Indexes' again, a couple (but not all) of the uploaded files appear in the Assets listing?

The assets file path seems to be in order. The log files says:

'[error] [application] Could not delete the file' ... 'because the file does not exist.'

Pointing to a file in 'craft/storage/runtime/assets/sources/'

I tried loads of stuff already, including uploading all craft files again in a new folder, but no dice.. Does anyone have a clue?

Thanks, Bob


texts: Order entries, exclude 'the' from order criteria

texts:
I know this is partly a Twig question, but I've poked around quite a bit here, in Twig docs, Craft docs, and cannot find the right syntax.

I have a bunch of entries with titles like:

Hotel A
Grand Hotel B
Zither Hotel Grand Plaza
The Top Hotel

I want to order by title, alphabetical, but I need to exclude leading 'The ' from the order. I've tried this, but it barfs.

 {% for entry in craft.entries.section('hotels').order('(CASE when title LIKE
'%The ' THEN LTRIM(title, 4) ELSE title END )') %}


texts: New Installation on Windows 10 IIS, cannot get to admin control panel, getting "Template not found: unavailable"

texts:
I am in process of doing a new installation of CraftCMS, and I have the site up and configured. When I select the "Go to your control panel" link I am getting a Craft 404 error: "HTTP 404 – Not Found – yii\web\NotFoundHttpException
Template not found: unavailable", trying to take me too "https:///admin". When I manually enter: "https:///index.php?p=admin/login", I can get to the admin login page.

When I log in from there it goes back to the same 404 error. I am thinking it could be the rewrite rule is not working properly because at the bottom of the error page I do see "p=unavailable".

I have tested the rewrite rule in IIS and it does not seem correct to me:

Any help would be greatly appreciated, I have been fighting with this installation for a couple of days now and late nights it seems I am getting close and I think if I could get around this last issues I will be good, but I thought that with the last one.
Amazingly enough, after I logged in and went to the 404 page, I was able to manually type in: https:///index.php?p=admin/dashboard and was able to see the dashboard, but as soon as you click on anything it goes back to the 404.


texts:
What permissions do users need in order to access the "edit image" menu in assets?

Some users can't access this, but I can't see a specific permission for this listed under:

Settings > Users > User Groups


texts: Enforce search match multiple parameters

texts:
I actually found this code on here Search Form with Craft Commerce. I had a problem with this code pulling up products that didn't match, and then after creating a new product it worked for a bit and then broke and continued to only pull up the same ones, even if I got rid the values inside with[].

So two questions, how do I enforce that the product has to match BOTH criteria in the with[] and does anyone have any clue about why it would stop refreshing products? I've tried clearing cache in both browser and craftcms.

I apologize if this has been asked before, I've been through multiple previously asked questions with little luck.

{% set spec = craft.request.getParam('a') %}
{% set spec2 = craft.request.getParam('b') %}
{% set category = craft.categories.group('productSpecs') %}
{% set products = craft.commerce.products({
            relatedTo: category,
             with: [
                spec,
                spec2,
            ],
            order: "title asc",
        }) %}
{% for product in products %}
    {{ product.title }}
{% endfor %}