texts: Recoverable error Object of class Craft\ElementCriteriaModel could not be converted to string after Update

texts:
After running Craft update I'm getting error on the meta author, meta description and meta keywords fields. Any idea how to resolve issue?

  Recoverable error
  Object of class Craft\ElementCriteriaModel could not be converted to string

Error Output:

Template Code:

{% set site_title = 'site title here' %}

{#
    ENTRY FALLBACK
    Not all pages have entries associated with them, e.g. search results, login page, etc.
#}
{% if entry.id is not defined %}
    {% set entry = craft.entries.id(2) %}
{% endif %}

{#
   HOMEPAGE DATA
   Used as a fallback for when meta values don't exist in this entry
#}
{% set homepage_entry = craft.entries.id(2) %}

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>{{ entry.id == '2' ? site_title : entry.title ~ ' > ' ~ site_title }}</title>
    <meta name="author" content="{{ entry.metaAuthor ? entry.metaAuthor : homepage_entry.metaAuthor }}" />
    <meta name="description" content="{{ entry.metaDescription ? entry.metaDescription : homepage_entry.metaDescription }}" />
    <meta name="keywords" content="{{ entry.metaKeywords ? entry.metaKeywords|join(',') : homepage_entry.metaKeywords|join(',') }}" />
    <link rel="shortcut icon" href="images/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="/css/all.css">
    <link rel="stylesheet" type="text/css" href="/css/nav.css">
</head>

Any idea what issue is, how to resolve and why this broke?


texts:
I am adding new users in Craft Pro, I don't get a chance to specify password, seems its is auto generated but I don't get any email sent to the user I just created. Is there any setting I have missed?

I have setup Gmail in settings >> Email >> Protocol and tested and received test email but doesn't send email when a new user is added.

Any help will be appreciated.

Cheers.


texts:
I've Googled & searched on here, but have not been able to find the answer I need.

I come from using Advanced Custom Fields in the WP environment, and one feature that was great about ACF was being able to define the templates a field grouping would/can show on.

Take Craft for example. I have a grouping of fields that when combined form the banner "field layout" for a section. However, that "field layout" can be used on multiple other sections and even single pages. Without me having to re-create it on every single or section, is there a way that's much more efficient?

I am also using the Reasons plugin https://github.com/mmikkel/Reasons-Craft which enables me conditional fields. And I believe this is where the efficiency concerns are coming from. Because I am having to set the conditionals on each field layout. And if I decide to change something, I will need to change it across all other field layouts.


texts: External liblary class inside plugin controller

texts:
I have external library handling connection to mail delivery system. Its just php class. How do i include and use this class inside craft plugin controller?

library.php:

class mail_delivery{
    //code
}

plugin/controllers/controller.php:

namespace Craft;

class controller extends BaseController
{

    public function init()
    {
        require_once 'library.php';
    }

    public function method(){
        $object = $rest = new mail_delivery();
    }

I get PHP error:

  ( ! ) Fatal error: Class 'Craft\FmRestAPI' not found in
  C:\xampp\htdocs\mmimport\craft\plugins\freshmailintegration\controllers\FreshmailIntegration_EmailController.php
  on line 27

Is this some kind of namespace issue?


texts: Populating tables and matrix fields using GuestEntries

texts:
Is it possible to populate a Matrix Field, Table and Lightbox using the GuestEntries plugin from an HTML form?

I'm trying to build an RSVP form, and am not having a lot of luck with different field types.

Using the syntax from Brad's answer is working to create rows in the table on new entries, but it's not populating them. The below code creates two rows in the table, but they're empty.

<input type="text" name="fields[guests][0][name]" placeholder="Name" />
<input type="text" name="fields[guests][1][name]" placeholder="Name" />


texts: Override a wildcard dynamic route template

texts:
I have a dynamic route for individual user /profiles. I expected it would be possible to override this route for /profiles/all but apparently not.

This can be achieved in the template I expect, with a conditional statement on the url .segment(2), but it would save a little time if it was possible to override a wildcard route.


texts: Export database from control panel or Sequel Pro? What's the difference?

texts:
Since I am involved in a multi-developer, version-controlled setup, I do a lot of database importing and exporting from environments.

I notice today that when I export a database from one of our sites using the control panel "Backup Database" function, it comes out at about 3.6MB and takes about 5 minutes to import.

When I export from Sequel Pro, the database dump comes out at about 1.6MB and imports within 30 seconds.

Note, I always dump the existing tables before import.

Just wondering what the difference is here that there is such a difference in file size and import time and which way is best?

Thanks!


texts: Recommended hosting company for a Craft site?

texts:
Looking through the Google Plus community and Slack chat history, there have been many suggestions regarding hosting for Craft websites. It may not be possible to get a single conclusive answer, but I still want to know...

What hosting company do you recommend for a Craft website?


texts: Comparing matrix blocks by type and field value

texts:
I’m trying to do something, the answer to which should be as simple as searching a Matrix field value but that’s not working for reasons I can’t fathom.
Setup

I have a Matrix field called programme.
It includes a block type called item.
That block type has a field with a handle of od.
I have a test case entry that has 4 item blocks in it.
All 4 of these blocks have a value in their od field but I need to check for scenarios where some or all of those blocks have that field empty.

So, I’m querying:
{% set talks   = entry.programme.type('item').all() %}
{% set odTalks = entry.programme.type('item').od(':notempty:').all() %}

…and then checking that works with:
<pre>
    talks: {{ talks|length }}
    odTalks: {{ odTalks|length }}
</pre>

…and the result I’m getting is:
talks: 4
odTalks: 0

I’ve tried other search values I know should work with the specific entry’s values, including regex strings. I've tried searching other fields in the block, and nothing works.
What could I be doing wrong?

Would be a shame to have to do something like this just to compare the lengths of talks and odTalks and act accordingly…
{% set odTalks = 0 %}

{% for talk in talks %}
    {% if talk.od is not empty %}
        {% set odTalks = odTalks + 1 %}
    {% endif %}
{% endfor %}

…even though that works and produces the expected:
talks: 4
odTalks: 4


texts: How to delete old content in a Craft CMS database?

texts:
I've create 20+ websites in Craft and each time I've always started with the use of another site's database. (time saving to not have to create all fields, sections and more)
On my latest site's database I see I have content from a very old website, build 2016.
What is the best way to delete old content from the database in a safe way?
craft_elements = 52mb
craft_content = 34mb
craft_element_sites = 34mb


texts: What's the difference between using single and double quotes in strings?

texts: Is there a difference between using single-quoted and double-quoted strings?


texts:
I know that others have had issues with transforms and GIFs, but I wanted to post a question as I am running pretty up-to-date versions of everything, which to my understand should mean transforming GIFs should work.

The server is running on PHP 7.0.7 and this is the ImageMagick set up:

Within the control panel, there is no preview for GIFs:

And when trying to transform the image on the template, it is being changed into a static image with only the first frame showing.

Is there another setting I need to look at changing?


texts:
I discovered search engines found duplicate content on my domain due to URLs being output with index.php?p= and index.php in ADDITION to the clean URLs.

For example, I have:

domain.com/index.php?p=about
domain.com/index.php/about
domain.com/about

And the first two requests with index.php?p= and index.php shouldn't exist. Only the last request with domain.com/about should exist.

While I found help removing index.php, some URLs continue to include ?p=.

So, now I still have:

domain.com/?p=about
domain.com/about

While all I want is:

domain.com/about

Note: This is happening to several pages and blog entries throughout the site. Not only URLs directed to about.

How may I remove ?p= permanently from the remaining URLs?

Within .htaccess, I have:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Remove index.php
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !^/index\.php/admin\b [NC] # Don't mess with admin requests
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

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

Within craft/config/general.php, I have:

return array(
    '*' => array(

        'omitScriptNameInUrls' => true,
    ),
);


texts:
I've just changed a rich text field to a number field and am now unable to bring up either the front-end or the dashboard because of multiple CDbException errors. When trying to access /admin, here's the first line of the error message:

CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'content.field_sqFt' in 'field list'

I changed a rich text field named projectDescription to a number field named sqFt. I understand that the new column can't be found.

When updating a field type, I know that there's a chance for data loss. Data loss would be ok for the entries that this change would affect. But I've made other changes since my last backup that I'd like to retain if possible.

I'm running the latest Craft Pro.


texts: FreeForm - Limit number of fields/columns in Form Builder

texts: Is there a way to limit how many columns/fields a user is allowed to drag/add into the form builder. Currently, they are allowed to line up 4 in a row. I would like to limit that to 2. But I would specifically like to restrict the Form Builder so unfortunately fixing this via templates/CSS won't work.


texts:
So I'm trying to loop through some entries and order them by in a specific way. For an example let's say I have the following entires:

Example01
Example02
Example03
Example04

I now want to loop through these entries and order them in an order such as: Example03, Example01, Example04 and Example2. The order has to be custom where I can change it.

Is this possible and if so how can I achieve this? Thanks


texts: Sprout Import Doesn't Recognize Asset folderPath Property

texts:
I'm trying to import entries with an Asset inside a subfolder. Since I don't know what the new Craft subfolder ID will be for each Asset I tried to use the folderPath property from Craft's Asset element class:

[
{
    "@model": "barrelstrength\\sproutimport\\importers\\elements\\Entry",
    "attributes": {
        "sectionId": 2,
        "typeId": 2,
        "authorId": 1,
        "slug": "my-sample-document",
        "postDate": "2017-11-09 13:06:00",
        "expiryDate": null,
        "enabled": true
    },
    "content": {
        "title": "My Sample Document",
        "fields": {
            "description": "
Nulla sit amet est. In hac habitasse platea dictumst. Pellentesque ut neque.
"
        },
        "related": {
            "documentFile": {
                "@model": "barrelstrength\\sproutimport\\importers\\elements\\Asset",
                "params": {
                    "filename": ["my-sample-document.pdf"],
                    "volumeId": 9,
                    "folderPath": "documents/pdfs/"
                }
            }
        }
    }
}
]

However the import fails with this error:

  [error][sprout-import] Setting unknown property: craft\elements\db\AssetQuery::folderPath

I don't get an error when I use the folderId property. Can I only use properties that correspond with database columns? Is there any way to do this if I don't know the subfolder ID for every asset I'm importing?

Craft 3.0.26.1
Sprout Import 1.0.0-beta.14


texts: Easiest way to make a table in the Control Panel sortable?

texts:
I know that if i have created a new ElementType for my plugin that I can use the same template that Entries uses:

{% extends "_layouts/elementindex" %}
{% set title = "Entries"|t %}
{% set elementType = 'Entry' %}

and that will give me the standard layout with a sortable table.

However is there anyway to tap into the sortable stuff for my own custom table in my plugin.

Or is it simply a case of having to work the sortable stuff myself (which is fine)? I just thought I would ask as I would prefer to use the native stuff if it is easy to hook into.


texts:
I'm working on a website for a school and need to create a system where students can login, check assignments and upload homework that the teacher can then view easily and give feedback on. I am only a front and programmer so I am hoping there is some form of pre-built plugin for Craft that I can use and then modify to suit our needs.

Currently we use Blogger and it does an alright job for what we need. But we would prefer to have all the interactions for students to be done through own website and not a third party.

Because it's a complicated question here is a very basic outline of what I am trying to achieve:


texts: Can you extend "_layouts/cp" in a plugin settings page?

texts:
I'm aware that I could enable the plugin to have it's own CP section, but I don't feel that this would be the right place for it to live due to its nature, when you view the settings page it wouldn't be a list of inputs, it would be a table view.

Ideally the plugin page would reside in settings > plugins > myPlugin but have the same template as a plugin with a CP section, just like the sections settings page.

This is my template in pluginHandle/settings.html

{% extends "_layouts/cp" %}
{% import "_includes/forms" as forms %}

{% set title = "My Plugin" %}

{% set content %}
  Some content should appear here maybe?
{% endset %}

I don't get any errors when I view the page it just looks like this:

As you can see the title variable gets ignored and has taken the plugin name, but if I remove the {% set title = '' %} part it throws an error of Variable "title" does not exist.

I tried to match the basics of what the sections settings template that craft has. Am I just trying to do something that was never an intended purpose or is just bad practice ?

Any clearance would be great, thanks!


texts: Control Panel freezes due to Access Control Checks?

texts:
Basically, I have no clue what this means?  But, I am unable to edit any entries in Control Panel -- everything times out after I try to save and/or return to the main entries page.

[Error] XMLHttpRequest cannot load http://www.mysite.com/index.php/nc3/actions/users/getAuthTimeout?dontExtendSession=1 due to access control checks.
    send (jquery-2.2.4.min.js:4:15971)
    ajax (jquery-2.2.4.min.js:4:11523)
    checkAuthTimeout (craft.js:3:22301)
    f (jquery-2.2.4.min.js:2:3704)

I don't know for sure, but the error seems to be connected to adding siteURL to general.php.

But, (and I am a noob) it was set to http://www.mysite.com.   which is exactly what appears in CP.   I assume I do not need to list it in both places?


texts:
I'm trying to get the content of a single using a slug from the url.
I'm using the following code:

{% set item = craft.entries.slug(craft.request.getSegment(1)).first() %}

This doesn't work, returns null, if there is a dash in segment 1.

For example if I have the following url: http://craft.dev/this-is-a-segment/segment2
And in craftcms I have a single with title "This is a segment" and url "this-is-a-segment"
I can't get the content of that single.

If I change the slug to camelcase it does work, but I was under the impression that slug and section handle were two different things...

Is this a bug or am I doing something wrong?


texts: Updating Craft 3 from RC3 to RC4 through Composer

texts:
I have a problem when updating with Composer.

My installation command line was this one:

php composer.phar create-project -s RC craftcms/craft $HOME/craft

As such, I tried to update, as per Ryan from Mijingo instructions:

php composer.phar update craftcms/craft

But I ended up with the following error:

Composer could not find a composer.json file in /home/me
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section

I checked, composer.json and composer.lock are in the craft directory, as expected.

After looking through Composer man page and web docs, I am still clueless, as I haven't found what -s RC are used for in the installation command. I believe understanding these (this?) switches is probably the key, but I rather ask here than making a mistake and blowing the otherwise perfectly working install. ^^

As for the CP, it doesn't work either, but that is not a surprise given the command line didn't and that I am using the php composer.phar method rather than the sole composer one.


texts: How do I properly access plugin controllers from the front-end?

texts:
I'm building a plugin, and it all worked just fine until I decided to change the front-end form submission to use AJAX instead of submitting directly. I have a form on the front-end with this action:

<form class="gtPoll__form" method="post" accept-charset="UTF-8" action="">
      <input type="hidden" name="action" value="gtPoll/poll/incrementAnswer">

and a controller at /craft/plugins/controllers/GtPoll_PollController.php with the method actionIncrementAnswer(). I also have the line

protected $allowAnonymous = array('actionIncrementAnswer');

in this controller class.

When I submit that form via AJAX on the front-end (to the URL in the action value), I get a 404 and the rest of my JavaScript breaks, but the controller action DOES complete and the answer count is incremented properly.

If I add this code to my main plugin file:

public function registerSiteRoutes()
    {
        return array(
            'gtPoll/poll/incrementAnswer' => array( 'action' => 'gtPoll/poll/incrementAnswer')
        );
    }

Then I don't get the 404 and my JavaScript all works, but the controller action occurs twice each time the AJAX call is made, so my answer count is doubly incremented.

I'm not really sure what's going on. I also tried using

{{ actionUrl('gtPoll/poll/incrementAnswer') }}

in the hidden action field, but that doesn't work at all.

What's the correct way to access this controller action from the front-end?

Thanks in advance!


texts: Protect mutliple pages in a template folder

texts:
I made a member area with multiple pages in a member-area template folder.
I d like to protecte all pages in this folder.

I know the isLoggedIn function to protect a page in a twig template.
http://buildwithcraft.com/docs/templating/craft.session

{% if craft.session.isLoggedIn %}
    Logout
{% endif %}

But what would be the best way to protect multiple pages ?

Put the control on _layouts/base or _layouts/site templates?
Note: And above that problem I got an ajax login form (I can make a dedicated login page if it is more simple and no choice)


texts: Freeform Element Connections to Update Existing Entries

texts:
I have a Freeform 3 form and I have mapped it to an existing channel. The connection works, and filling out a form creates a new entry, but it only create new entries. The form is on an entry page. The channel has an autogenerated Title and I am pulling that into the form template via a hidden field.
I was hoping to be able to "update" existing entries and not just create new ones. Do I need to also pull in the entry.slug or entry.id? Or do the element connections not have this functionality?
What I am getting is only new entries: entry-01, entry-02, etc.


texts: Checkbox profile fields front end show labels in cp

texts:
I have some custom profile fields saved on registration in the front end.
They are checkboxes and only submit on front end reg when they are set as an array. eg:

<div class="checkbox">
    <label>
        <input type="hidden" name="fields[phoneOptIn]" value="">

        {% set chbox = craft.fields.getFieldByHandle('phoneOptIn').getFieldType.options %}

        {% for option in chbox %}
            <input type="checkbox" name="fields[phoneOptIn][]" value="{{ option.value }}"  tabindex="29">
            {{ option.label }}
        {% endfor %}
    </label>
</div>

"fields[phoneOptIn][]" only works to save with "[]" in name.

The problem in the CP user display is that when configuring to show the check box fields in the CP, the values of the checkboxes are not shown. What is displayed instead is the labels. eg:

Is this a bug? Really want to see values in backend not labels.


texts: Craft as an API provider & authenticaton

texts: I'm building an API provider using Craft and need to implement some kind of client authentication. I don't need to worry about individual users, but I'd like to require that clients authenticate in some way. My current thinking is the client can pass an authorization header header of some kind, or just use basic authentication to access the content on the Craft CMS site, I'm just not sure how to consume the header on the Craft side & validate it before serving the content. Can anyone offer up some tips on how to implement something like this using Craft?


texts: Manipulating the map in JS - [GM] Unable to find map

texts:
I love the new Google Maps plugin, it seems really promising.
I am really struggling to manipuluate the map in JS in the new Google Maps plugin.
I have a dynamic map that filters fatal and serious injury crashes (by mode of transportation, outcome, and year) and adds KML layers.
I'm successfully loading the map in Twig — Now I am working through manipulating it in JS but can't seem to get past the first step.

Console: [GM] Unable to find map "mapAlpha"

  {% set fatalities = craft.entries.section('crashes').outcome('fatal').all() %}
  {% set injuries = craft.entries.section('crashes').outcome('injury').all() %}

  {% set options = {
    'id' : 'mapAlpha'
  } %}

  {% set map = googleMaps.map([], options)
    .zoom(12)
    %}

  {% do map.markers(fatalities, {
    'icon': '/assets/images/ui/red-dot.png',
    'infoWindowTemplate' : '/modules/info-bubble.twig'
  }) %}
  {% do map.markers(injuries, {
    'icon': '/assets/images/ui/blue-dot.png',
    'infoWindowTemplate' : '/modules/info-bubble.twig'
  }) %}

  {{ map.tag() }}

  <script>
  {% js %}
    var map = googleMaps.getMap('mapAlpha');

  {% endjs %}
  </script>


texts: Tasks either don't start or don't run as background processes

texts:
I'm using Laravel Valet for my Craft development environment (which is awesome, btw) except for an issue with Tasks not kicking off. I initially stumbled upon the problem while using the Import plugin. The task created by the plugin would never start. Instead, it would sit in a "Pending" state.

I figured this was a bug with the plugin, because other tasks seemed to start and run just fine. I then also discovered another task-related problem with P&T's example task plugin, "Power Nap", where running the task would cause the whole site to hang.

What gives?

Both of these issues aren't present when running the site with MAMP. I've narrowed it down to something to do with Valet (which is using Caddy to serve PHP sites).


texts: Allow user to set timezone from within Craft when entering a time in a date/time field

texts:
We are creating a small site to manage meetings that take place in many timezones. Administrators of the site will create meetings on behalf of teams everywhere. They may be in pacific timezone and receive a request to create a meeting from a team in England.

When creating the entry, the date/time they see if for pacific timezone, and to create the event with the correct time for GMT+1, they must do the math in their head as to what time in PST corresponds to the correct time in GMT+1.

Is it possible to have or add a field to specify which timezone the provided time is in, vs relying on the timezone set in settings?


texts: How to allow guest to make entry without login

texts:
I have a pretty simple form. I just realized that it doesn't work unless I'm logged in as admin.

Is there a way to bypass that, or to simply turn off authentication altogether for Craft CMS? For this project, I think that would be fine.

Any ideas? I'd prefer to not use a plugin.

Here is the form:

        {% for entry in craft.entries.section('ScoreRequest').limit(1).find() %}
            <form method="post" action="" accept-charset="UTF-8">
            <input type="hidden" name="action" value="entries/saveEntry">
            <input type="hidden" name="sectionId" value="{{ entry.sectionId }}">

                  <input class="form-field" placeholder="Your Name" id="title" type="text" name="title">

                  <textarea class="form-field-2" placeholder="Your Email Address" id="body" name="fields[email]"></textarea>

                            <textarea class="form-field-2" placeholder="Your Phone Number" id="body" name="fields[phone]"></textarea>

                  <textarea class="form-field-2" placeholder="Your Company" id="body" name="fields[body]"></textarea>

            <input class="form-button" type="submit" value="Send">
            </form>
        {% endfor %}


texts:
I'm stuck on a problem with categories. I never worked with them before so maybe it's not as difficult a I think.

I need the following structure:

Type of company 1 (e.g. Bakery)
    -Bakery 1 + website
    -Bakery 2 + website
    -Bakery 3 + website

Type of company 2 (e.g. Supermarket)
    -Super 1 + website
    -Super 2 + website
    -Super 3 + website

So my parent categories only need 1 field (type of company)
and the children need 2 types of fields (url + company name)

How can I accomplish this?


texts: Is there a CacheService equivalent in Craft 3?

texts: CacheService is exactly what I need to cache a custom API endpoint in PHP, but I don't see it in Craft 3. What would be the correct way to do this in Craft 3?


texts:
Any thoughts why a Sprout Form is not saving a form submission that contains a file.

Not throwing any errors and on submission the user is returned to the form.

This is a local build - I thought it might be a permissions issue with the file upload but nothing in logs, which seem to suggest that the entry/submission is being saved (event is valid, element saved).

However, nothing is being saved in the back-end and the file is not being uploaded to the allotted directory.

Confused - any help appreciated.


texts: Multi-locale pages 404 on subdirectories

texts:
I'm developing and running a Craft site locally through Laravel Homestead and am having issues with pages 404'ing in a multi-locale setup.

I've followed this guide closely: https://craftcms.com/docs/localization-guide and still running into problems.

Basically, I want to have a Spanish locale set up, with English as the default top level. So my example.com/xyz-article will be the English version, and example.com/es/xyz-article will be the Spanish version.

Here is how my folder structure is set up:

craft/
public/
   .htaccess
   index.php
   es/
      index.php
      .htaccess

My craft/config/general.php is set up like this:

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

    '.dev' => array(
        'devMode' => true,
        'userSessionDuration'           => 'P101Y',
        'rememberedUserSessionDuration' => 'P101Y',
        'rememberUsernameDuration'      => 'P101Y',
        'invalidLoginWindowDuration'    => 'P101Y',
        'cooldownDuration'              => 'PT1S',
        'maxInvalidLogins'              => 101,
        'siteUrl' => array(
            'en_us' => 'http://example.dev/',
            'es' => 'http://example.dev/es/',
        )
    ),
);

My index.php file under the public/es directory looks like this:

<?php

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

// Tell Craft to serve the Spanish content
define('CRAFT_LOCALE', 'es');

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

if (!is_file($path))
{
    if (function_exists('http_response_code'))
    {
        http_response_code(503);
    }

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

require_once $path;

Finally, both of my .htaccess files inside the public and es directories are identical and look like this:

<IfModule mod_rewrite.c>
    RewriteEngine On

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

Going to example.dev brings up the English homepage just fine, and example.dev/es brings up the Spanish homepage just fine. Everything looks good so far...but when I try to navigate into subdirectories, the es/ pages always 404's.

For instance, I set up a Single called "Testing", enabled it for both locales, and pointed it to a template inside my craft/templates folder called testing/index.html. example.dev/testing brings up the English version, but example.dev/es/testing gives me a 404 error.

The odd thing is, is that the ugly version of the URL at http://example.dev/index.php/es?p=testing brings up the Spanish version, and Live Preview also works and displays/updates when I'm working on the Spanish version of the page.

I'm at a bit of a loss as to where I'm going wrong here -- it seems like some paths are just screwy but I can't find where I may have entered something in incorrectly. Any help would be appreciated!

UPDATE: Here are the log errors I'm getting when I load the es/testing page.


texts:
I'm getting started with Craft, using version 3 beta, and I don't find the menu option for adding locales so I guess it's not yet ready but there must be another option.

Could anyone guide me through the process of creating a multi-language Craft 3 site?


texts: Loop through categories and get bottom-most category for each tree

texts:
I need to get the last item that don't have a child. So in this case I need

Mobiltelefoner
Ipad
Køleskab
Vaskemaskine

How to I get the last item that don't have a child without knowing the amount of levels?


texts:
Is there a way to get "vanity URLs" for my assets? Something like:

www.example.com/download/asset.pdf

rather than:

www.example.com/several/subfolders/for/organisation/purposes/asset.pdf

I know that dumping all assets into a /download folder will work but this is far from an ideal solution. Is there another way?


texts:
If i include javascript in a template using:

{% set myJS %}
//some JS in here
{% endset %}

{% includeJS myJS %}

Is there a way to minify the javascript that gets output on the page? I had a look at the documentation but couldn't find anything. The only way i have found to do it otherwise is to put the javascript in an external file, minify that, and include it with {% includeJsFile %}. Any ideas on how i could do this? Or is there a better way to achieve the same result?


texts: Is there a tool to migrate Joomla/K2 entries into Craft?

texts:
I have a Joomla site with K2 installed, and a couple of thousands of articles (no custom fields) and corresponding images.

Is there a script to help migrate those into Craft? Or will I have to manually write something custom to move the content?

Thanks in advance


texts: How can you allow users to create products in Craft Commerce

texts: I want site members to login and create products in Craft Commerce, so the products they create should only be visible to them on the back-end, e.g,  user (A) should login and view his products in Craft Commerce, user (B) logs in and only see his products.  How can I achieve this in Craft Commerce?


texts: Database Connection Error after updating from Craft 2 to 3

texts:
Good evening all,
I am updating a small site from Craft 2 to 3, and after following the instructions in the documents, I loaded up the backend of my site and was greeted with the install screen.
I know that this typically means that the DB_TABLE_PREFIX is improperly set, but I triple-checked and I'm 99% certain that it's correct. I double-checked with my Craft 2, which looks like
// The prefix to use when naming tables. This can be no more than 5 characters.
    'tablePrefix' => 'craft',

And matched it to my .env file:
# The prefix that should be added to generated table names (only necessary if multiple things are sharing the same database)
DB_TABLE_PREFIX=craft

I also checked for a craft_info table, and that is present. The version listed in the version column is 2.9.2, if that makes a difference.
I am unable to login to my admin panel, or view my website now. I get the following when viewing my website:
Database Connection Error – craft\errors\DbConnectException
Craft CMS can’t connect to the database with the credentials in config/db.php.
↵
Caused by: Database Exception – yii\db\Exception

Any help is greatly appreciated!
-Shad


texts:
It feels like I’m trying to do the impossible, but I can’t imagine this problem is unique to my project. Hoping someone here has figured it out before!
I have two channels, creators and products, and I can assign any number of products to a creator through a related entries field: creatorProducts.
How do I display the top 10 most popular products? Or, in other words, how do I sort the products by the number of creators they’ve been assigned to?
Haven’t been able to find the answer anywhere. Welp.


texts: Have the country in craft.commerce.countriesList default

texts: Is there a way I can have the array from craft.commerce.countriesList automatically default to the country my store is in?


texts:
I need to build a plug-in. Actually I've built half of the plug-in already but I am questioning my approach. I wanted to get another point of view to see if I'm headed down the wrong path.

In my Craft control panel I want to be able to add a ZIP file to an entry or just into Assets directly. In an entry I can currently do this through an Assets field type. But I need to extend the functionality because I need to do some file validation on the zip file and then unzip it and then validate the contents of the unzipped content as well. Finally I then need to have the ability to reference the folder that contains the unzipped files.

In more concrete words, I want to be able to upload a zip file that contains an animated advertising banner. As an example, the zip file would be named "acme_banner_300x250.zip". Uploading that file would check that the banner dimensions are stated in the filename (300x250) and that the contents of the ZIP include an "index.html" plus it must contain an image file with the word "backupImage" in the file name. If all those things are true, it would unzip the file and then delete the original ZIP.

Finally, when this asset is included in an entry, I want to be able to pick it from the asset list (where it shows the backupImage file from the zip as the thumbnail) and have it be able to report the proper height and width properties along with a 'url' property that points to the folder containing the index.html file.

(Side note: These are all files I've built myself so I am not worried about malicious content being included in the upload, although if there is a way to scan them for malicious content, that would be good with me.)

My current half-finished plug-in does the following: It will intercept an uploaded asset using the "assets.onBeforeUploadAsset" event listener and then unzip the file (if the extension is "zip") in a location I can designate. I'm left with the original zip file in the Assets listing and I'm struggling with how to use the unzipped directory in my entry because that unzipped location isn't associated with the zip file listed in my assets.

I'd like to select whether this whole process happens or not. Right now, any ZIP file gets unzipped and I would prefer to be able to upload a ZIP file and have it remain a plain old ZIP file sometimes (i.e. when a client needs to get a ZIP of files from me).

Am I going down the wrong path trying to work within Assets to build this functionality? It feels like I'm creating a new type of Assets rather than just working within the existing Assets available file types.


texts: Restricting entry editing in the admin section

texts:
We have custom permission setup where we have certain admins that are only allowed to edit specific entries. This is done by modifying the entries sources:

Event::on(
    Entry::class,
    Element::EVENT_REGISTER_SOURCES,
    [$this, 'modifyEntrySources']
);

And by hooking into cp.users.edit:

Craft::$app->getView()->hook(
    'cp.users.edit',
    function ($context) {
      if (!$this->canEdit($context['entry'])) {
        throw new ForbiddenHttpException('You do not have permission to edit this entry!');
      }
    }
);

This works great except for the modal editing, because the cp.users.edit does not cover the modal. I believe the modal is driven by isEditable on the entry but I am unsure how to hook into that.

Any advice would be greatly appreciated.


texts: 500 Error with no details on site migration

texts:
I'm trying to migrate my site from a PHP5.6 host to a PHP 7 host in preparation for Craft 3.

I've copied everything across and am trying to load an exact copy of the production site on a different domain to see if it's all working as expected.

Unfortunately I don't make it far.
On hitting the site I get:

PHP Fatal error:  Uncaught Error: Call to a member function run() on integer in /blah.com.au/htdocs/craft/app/index.php:62

Stack trace:
#0 /blah.com.au/htdocs/public/index.php(19): require_once()
#1 {main}
thrown in /blah.com.au/htdocs/craft/app/index.php on line 62

There are no other details anywhere.
To avoid cache issues I've also done a fresh upload of Craft and then copied across my config, templates, plugins, public directories etc.
Exact same error.

I've updated the config files (db/general) to have the correct paths for this new domain. The database is the same as production.

my .htaccess shouldn't be causing issues.

Any ideas peoples?


texts:
Is there an easier way to get the CP's currently selected locale? In my plugin I am currently using this method.

public function getCurrentLocale() {
    $id = is_array($this->value) ? $this->value[0] : false;
    $segments = craft()->request->segments;
    $lastSegment = end($segments);
    $locales = craft()->elements->getEnabledLocalesForElement($id);

    if (in_array($lastSegment, $locales)) {
        return $lastSegment;
    }

    return null;
}


texts: Saving remote image to assets field in entry

texts:
I'm working on importing entries from EE to Craft. I started with the craftimport plugin, and I am expanding it to do a bit more. One of the things I need is to save an image from a remote URL into an entry's assets field.

So far I've only managed to save it to disk, and then I can go into Craft admin and index the assets folder, and re-run the import, which will save the relation between the image and the entry using this:

$command = craft()->db->createCommand();
$imgRecord = $command
            ->select('id')
            ->from('assetfiles')
            ->where(array("AND", "filename='" . $images[0]['filename'] . "'", "folderId=2"))
            ->queryRow();

if ($imgRecord['id']) {
    $imgFieldRecord = FieldRecord::model()->findByPk($imgFieldId);
    $imgFieldModel = FieldModel::populateModel($imgFieldRecord);
    craft()->relations->saveRelations($imgFieldModel, $entryModel, array($imgRecord['id']));
}

So I'm wondering if it's possible to do this whole thing in one run instead of two? I guess the only thing the indexing does is look for images and store them in the database. But I can't seem to find anything in the documentation that tells me how to do it.


texts: Getting an array of ids from an array of eager-loaded elements within Twig

texts:
I have been using the ids() method on the ElementCriteriaModel returned by a call to an entries field within a Twig template to return an array of ids for further processing.

Now I wish to eager-load these entries, but the entries are returned as an array with no access to the ids() method.

Is there an efficient way to get this array of ids within Twig, or would I be better moving this to a plugin?


texts: Viewing expired entries and live one with the same template

texts:
Working with Craft 2, I have a channel for events that each entry has an expiration date. Live entries should show the upcoming event info and expired entries should show archive info.

I have created a costume route to enable viewing of the expired entries:

news/{slug} →  news/_entry

when I am adding this to the code:

{% set entry = craft.entries.section('news').slug(slug).status('live, expired').first() %}

I can see the expired entries info but than if I am viewing a live entry, the data that I am viewing is not from the entry I am visiting but from the first entry in the section. If I drop this line from my code, than I cannot see the info from the expired entries.

Is there a way to be able to view both?


texts: Content / fields of newly created single don't show up

texts:
After a fresh install of Craft on my localhost, two problems occur:

1) The modal window to upgrade Craft only says "An unknown error occured."

2) Newly created singles are not editable, the edit pane stays empty with no input fields at all.

I looked into craft.log and there seems to be an issue with CHttpRequest.php, but I can't say if this is a local config problem or if it's a bug:

******************************************************************************************************
2015/02/25 13:08:35 [error] [php] Cannot modify header information - headers already sent (/Users/me/Sites/test-dev-craft/app/framework/web/CHttpRequest.php:1392)
Stack trace:
#0 /Users/me/Sites/test-dev-craft/app/framework/web/CHttpRequest.php(1329): Craft\CookieCollection->remove()
#1 /Users/me/Sites/test-dev-craft/app/services/UserSessionService.php(1170): Craft\CookieCollection->add()
#2 /Users/me/Sites/test-dev-craft/app/framework/web/auth/CWebUser.php(203): Craft\UserSessionService->renewCookie()
#3 /Users/me/Sites/test-dev-craft/app/services/UserSessionService.php(91): Craft\UserSessionService->init()
#4 /Users/me/Sites/test-dev-craft/app/framework/base/CModule.php(387): Craft\UserSessionService->init()
#5 /Users/me/Sites/test-dev-craft/app/etc/web/WebApp.php(569): Craft\WebApp->getComponent()
#6 /Users/me/Sites/test-dev-craft/app/framework/base/CModule.php(103): Craft\WebApp->getComponent()
#7 /Users/me/Sites/test-dev-craft/app/etc/web/WebApp.php(160): Craft\WebApp->__get()
#8 /Users/me/Sites/test-dev-craft/app/framework/base/CApplication.php(180): Craft\WebApp->processRequest()
#9 /Users/me/Sites/test-dev-craft/app/index.php(62): Craft\WebApp->run()
#10 /Users/me/Sites/test.dev/index.php(19): require_once()
REQUEST_URI=/test.dev/index.php/admin/actions/tasks/getRunningTaskInfo

This is my local setup:

Mac OS X 10.10.2
Apache/2.2.29 (Unix) DAV/2 mod_fastcgi/2.4.6 mod_ssl/2.2.29 OpenSSL/1.0.2
PHP Version 5.6.5
MySQL 5.6.22 - Homebrew

Any help would be highly appreciated!


texts: Sprout Form submit: The CSRF token could not be verified!

texts:
I have a form created by Sprout Forms, which results in an error when submitted:

The CSRF token could not be verified!

Here is the log:

2016/06/09 11:06:17 [error] [exception.Craft\HttpException.400] exception 'Craft\HttpException' with message 'The CSRF token could not be verified.' in /home/forge/www.fira.co.uk/craft/app/services/HttpRequestService.php:1314
Stack trace:
#0 /home/forge/www.fira.co.uk/craft/app/framework/base/CComponent.php(561): Craft\HttpRequestService->validateCsrfToken(Object(CEvent))
#1 /home/forge/www.fira.co.uk/craft/app/framework/base/CApplication.php(212): CComponent->raiseEvent('onBeginRequest', Object(CEvent))
#2 /home/forge/www.fira.co.uk/craft/app/framework/base/CApplication.php(183): CApplication->onBeginRequest(Object(CEvent))
#3 /home/forge/www.fira.co.uk/craft/app/index.php(62): CApplication->run()
#4 /home/forge/www.fira.co.uk/public/index.php(19): require_once('/home/forge/www...')
#5 {main}
REQUEST_URI=/publications/industry-statistics
HTTP_REFERER=http://www.fira.co.uk/publications/industry-statistics


texts: Get entries that aren't related to current user

texts:
I am trying to get all the entries that don't related to the current user via a user field.

I have used the following code to fetch all the entries that do related to the current user

{% set entries = craft.entries.section('movementCoursesEntries').level(1).relatedTo({
   targetElement: currentUser,
   field: 'permittedUsers'
}).find() %}

When I try to exclude these entries from the rest of the entries in the structure, I get nothing
{% set unrelated = craft.entries.section('movementCoursesEntries').level(1)|without(entries) %}

{% for entry in unrelated %}
    {{ entry.title }}
{% endfor %}

Any idea how to filter those entries properly?
Thank you!


texts: Members' site in Craft possible out of the box?

texts: I built a site in another CMS with an add-on which allows entries to be converted to member bios, and another add-on which makes sure all files uploaded by different members are viewable to that member only. The site allows users to search bands and read band profiles/listen to demos (Mp3s), each Member (band) uses a front end publish page to create their profiles (bios), would this workflow be possible using Craft?


texts: Multi-Environment Config using port in database server

texts:
I'm in the process of creating a multi-environment config and my client has set up a staging server with non-standard ports for the mysql server. I am unsure how to add the port number in the config file. I've tried the following with no success.

'STAGING' => array(
        'server' => '123.456.789.123:3939',
        'user' => 'myusername',
        'password' => '***********',
        'database' => 'mydatabase',
    ),

I've been able to successfully connect the database when on a completely different server/mysql combo so I know that the config files work.


texts:
Good morning and thank you in advance. How can I replace '#' with the entry.title. I have tried everything and I keep getting hash errors. Current code is this:

{{ wordBoldTitle|replace({'#':'{{entry.title}}'} )|raw }}

Trying to concatenate the  with the entry.title.


texts:
I'm supposed to display the most recent 6 items from a Matrix field but provide a slider so that the user can navigate through them (hiding the ones on the left, displaying new ones on the right).

I can think of how to do this in JavaScript, but I'm new to Twig and templating in general. How should I approach this problem?

Updating to show how I would in Javascript using the slick library.

html

js

$('.pictures').slick({
  infinite: true,
  slidesToShow: 6,
  slidesToScroll: 6
});

and how I'm trying to with Twig:

  {% for block in entry.recentWorkExamples %}

         {% set rw_image = block.recentWorkImage.first() %}

   {% endfor %}

The problems is, it doesn't swipe but all of the pictures pile up.


texts: I have just started using Feed me to import a festival schedule, and I have run into an issue with how their API is set up. The URL I have to use for the feed (with the token) outputs only a <link>URL.xml</link> to a temporary XML-file with a unique filename each time. So there's pretty much a feed inside the feed. Any way of getting Feed Me to look at the linked XML-file, or any other suggestions on how to solve this?


texts: Craft Commerce 2: Get products which are availableForPurchase

texts:
I try to get all the products of a certain category which have availableForPurchase set to true.

{% set criteria = craft.products.type( 'weine' ).relatedTo( cat ).search( 'availableForPurchase:1' ).orderBy( 'reihenfolge' ) %}

I don't use variants, but I guess I need to check the availability for the default variant. Is this possible in the query?


texts: Is it possible to integrate assets with Clouflare CDN service ? In docs only Amazon, Google and Rackspace are referred.


texts: Adding users outside of CP or front-end registration form

texts:
Is there a simple / best practice way for creating new users programatically? My specific use case involves capturing user data for online sales using a 3rd-party form with Stripe integration. When a user checks out and makes the purchase (not on the Craft site), I'd like to capture the data and generate a user account automatically on the Craft site.

My current idea, which should work, is to trigger Zapier to write a custom record (containing the user fields) to the MySQL database directly. I've done it before in other contexts but am curious if there's a better way?


texts:
Previously on EE I've used Low Search to generate a filter based search form, based on categories. But with Craft I can't seem to find an add-on - Or even know if I need one!

What I'm trying to achieve is a filer menu with categories e.g.:

[ ] Category 1
[x] Category 2
[ ] Category 3
[x] Category 4
   [ ] Category 4.1
   [ ] Category 4.2
[ ] Category 5

I've been reading over the documentation over at:

https://craftcms.com/docs/searching and https://craftcms.com/docs/templating/search-form

But I'm struggling to see how I can make this work within a search form itself.

I'm thinking I can generate a query fine to search the categories. But I can't work out how to link what is checked with a query.

Any help would be gooooood :)


texts:
I can't get rid of that pesky index.php?p= from my urls.

http://mysite.com/index.php?p=about/people

If I manually remove index.php?p= e.g. http://mysite.com/about/people it works, but then goes back to adding the index.php?p= as soon as I navigate away.

I've tried adding 'usePathInfo' => true, and 'omitScriptNameInUrls' => true, to general.php

PathInfo works, http://mysite.com/index.php/testPathInfo = 'success'

When I add garbage to htaccess I get server error, so htaccess works.

And I have another site with a very similar build on the same server that's working fine.

Is there anything else I can look at?


texts: Prevent caching from inside of the cache tag

texts:
Does anybody know, if it is possible to prevent caching from within the cached code/content?
Something like:
{% cache ... %}
...
{% do notCache %}
...
{% endcache %}

Why? Because if there is a content builder inside of the cache tag, certain content elements could simply disable caching that way by calling  {% do notCache %}


texts: Auto collapse craft commerce variant matrix

texts:
Is there a way to auto collapse Craft Commerce Variant Matrix Blocks?
I work with many variants per product and it is very cluttered when expanded.
I've already tried this way:
Possible have matrix rows collapsed by default in the Control Panel?
Thanks!


texts:
My plugin init function:

function init(){

    craft()->entries->onSaveEntry = function(Event $event) {

        //redirect to wanted url

    };

}

Is there a fancy way to redirect to my plugin url if, for example the entry channel is jobs.

Or I have to use header() function. Thank you in advance.


texts: Generating a precache manifest for service workers

texts:
I'm thinking of using Google's Workbox to pre-cache a bunch of files, and I've been scratching my head as to how to generate unique hashes for files when they change. Something like this:

 workbox.precaching.precacheAndRoute([
    {
      url: '/',
      revision: '383676',
    },
    {
      url: '/about',
      revision: 213142,
    },
    {
      town: '/location',
      revision: 742125,
    },
  ]);

Ideally the revision number would change when the entry or related entries included in the page are changed/saved. I got this working but I'm not sure how to get related content to clear the cache:

// service-worker.js

{%- cache using key 'abc' -%}
    {
      url: {{ craft.entries.id(64).one.uri }},
      revision: {{ random(100000, 999999) }},
    },
{%- endcache -%}

This seems to work when said entry is saved, but I'm not sure how to deal with a related entry being saved. I'm also not sure this is the most performant way to go.


texts: How do I "register" a service in a Craft 3 plugin?

texts:
In Craft 2, services were auto-loaded when using the craft()->plugin_serviceName->myMethodName() signature, but it seems like there's a catch in Craft 3, when using the new MyPlugin::getInstance()->myServiceName->myMethod().

I'm working on a business-logic plugin using a local path repository in my project's composer.json, and there are a rash of problems that come of this, mainly to do with creating + renaming services, as the service locator seems to cache them pretty aggressively.

How can I ensure these changes are picked up right away?


texts: How can i request image locations through elements api for an entry in section?

texts:
i have endpoint:
'news/<slug:{slug}>.json'
i print out EntryModel-Class in transformer function and it doesn´t seem to contain any photos like how it is described in Element Api example loop at the bottom of docs.
i need to return all images and their locations as json for specific entry.
any ideas?

'news/<slug:{slug}>.json' => function($slug) {

        return [

            'criteria' => [
                'section' => 'news',
                'slug' => $slug

            ],
            'transformer' => function(EntryModel $entry) {

                print_r($entry);

                //doesnt work --->
                // $photos = [];
                // foreach ($entry->photos as $photo) {
                //     $photos[] = $photo->url;
                // }
                //<----- doesnt work

                return [
                    'locale' => $entry->locale,
                    'slug' => $entry->slug,
                    'status' => $entry->status,
                    'title' => $entry->title,
                    'url' => $entry->url,
                    'uri' => $entry->uri,

                    'id' => $entry->id,
                    'heading' => $entry->heading,
                    'subheading' => $entry->subheading,

                    'linkUrl' => $entry->linkUrl,
                    'postDate' => $entry->postDate,

                    'children' => $entry->children,
                    'author' => $entry->author,
                    'link' => $entry->link,
                    'next' => $entry->next,
                    'parent' => $entry->parent,
                    'section' => $entry->section,
                    'type' => $entry->type,
                    'ancestors' => $entry->ancestors,
                    'body' => $entry->body,
                    'articleBody' => $entry->articleBody,
                    'featuredImage' => $entry->featuredImage,
                    'backgroundColor' => $entry->backgroundColor,
                    'serviceBody' => $entry->serviceBody,
                    'featuredThumb'=>$entry->featuredThumb,
                    'heroImage'=>$entry->heroImage,
                    'indexHeading'=>$entry->indexHeading,
                    'shortDescription'=>$entry->shortDescription,
                    'root'=>$entry->root
                    // 'photos' => $photos    <- i need image locations related to an entry
                    //'fields' => $entry->fields
                    // 'caption' => $entry->caption
                    // 'shortDescription'=> $entry->shortDescription,
                    // 'elementId' => $entry->elementId,

                ];
            },

        ];
    }

nothing under postDate seems to return anything....


texts: How to Show the Total Word Count of an Entry?

texts:
Any way to show the total word count in real-time to authors while they are writing an entry that has multiple blocks?

I don't need per-block word count ... I need total word count shown in real-time.


texts: Locked users' content fully blocked and unable to unlock

texts:
Just ran into an issue where one of my users was locked out due to too many login attempts (or at least it seems that way).

This caused all sorts of havoc in my site:

The content that was created by that user was not accessible by
others.
The front end broke (though I guess I should've set an "if no
user rule")
The user couldn't be found in the users list.

In order to fix this I had to go into the database and change the locked status from 1 to 0.

Has anyone else experienced this?
Is there a better way of handling it? (while keeping the limit of attempts).
Craft Team, can this be modified to cause less trouble? e.g.: lock the users but not their content; make the user unlockable from within the CP


texts:
What is the best way to work with non-craft database tables as models?

I have a given table and I should render its records with multiple filtering and pagination. Importing them to entries is not an option, the table is always changing. So I would like to use as an ElementCriteriaModel.

Where should I get started? Writing a plugin is the only way? Iy yes, how can I create a model from this external table?


texts: Group looped entries into blocks and wrap in markup every x number of loops

texts:
I am trying to loop through all the entries in a section and "group" them into items which are in blocks of 9 then wrap them with some html markup so there will be the following code:

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

    {% for item in selectedWork %}

      {{ item.title }}

    {% endfor %}

The outer
 and
 tags need to wrap round the first 9 items then then next 9 etc. etc. Also the panel--1 needs to increment so that each panel goes in order so panel--1 holds 1-9 items then panel--2 holds 9-18 items etc. Is this possible using some kind of array splice or something?


texts: How to auto enable a plugin after install?

texts:
I am developing a plugin for craft 3 and the plugin just got published to the store.
I can browse through the store and install the plugin but it stays disabled. The user will have to goto Settings -> Plugins and then manually enable the plugin even after installing. Is there a way to auto enable the plugin after install?


texts: PHP Warning on Asset Upload: PelInvalidDataException

texts:
I have a front-end form to upload image files, which works 100% perfectly most of the time. However, I've noticed with larger sized images, I'll get a PHP error saying:

PHP warning
include(pathToCraft/craft/app/vendor/lsolesen/pel/src/PelInvalidDataException.php): failed to open stream: No such file or directory

I'm not sure if this is an issue on my end or Craft. Should I be expirementing which file size starts causing this and restricting uploads from surpassing that limit in the plugin before saving entry?


texts: Non Integer Quantities in Craft Commerce

texts:
I am making a custom store that can sell half pounds of items. I've noticed through sending calls through my plugin to the craft()->commerce_cart->addToCart($cart, $itemNumber, $qty); to add an item to an order while specifying a non-integer quantity gives me the error: "Qty must be an integer"

Is there any way to allow quantity to be a non-integer? Customers will be ordering in .5 pound increments occasionally. I am not anemic to plugin development and php so I thought I'd ask the community if there was a way around this, or if I'm stuck with Qty being an integer.

Couple other options I've though of:

Make a custom field to deal with qty
Split my items into .5 increments so someone adding 5.5 lbs would really be adding qty 11 and there'd be special things going on with the admin and front-end to hide that fact


texts: How to manage a large database when upgrading from 2.0 to 2.1

texts:
I am trying to upgrade a site from 2.0.2551 to 2.1.2570. I have ~18k entries and ~28 elements. The upgrade process seems to want to save all the elements again as far as I can tell, is there any way to avoid this or make it quicker? Is there some magical SQL I might play with to do it all?

At present I've had it sat for 14 hours before I gave up...

Incidentally I can legitimately reduce the number of entries to about ~3k and the elements to ~11k as I can just re-import those from an API service - I have tried this and it still takes an awfully long time.

Any advice or previous similar situations you people have run in to would be most helpful :)


texts: How to get a Task's description inside runStep()?

texts:
I know that I can get the default description of a Task with:

$this->description;
//or
$this->getDescription();

But how can I get the description if it got changed on creation:

craft()->tasks->createTask('Mailer', $new_description);

Adding it as an attribute doesn't seem "right" to me:

craft()->tasks->createTask('Mailer', $new_description, array('description' => $new_description));


texts: Pagination returns a result after last page has been reached

texts:
I understand I can use a conditional to output a 'next page' link only when next pages exist, but I am finding a problem with direct URLs.

Let's say you have 20 entries and 10 per page.

The URL /news (or /news/p1) and /news/p2 should work, but I would expect /news/p3 to show no results or a message.

What I'm finding however is that /news/p3 and beyond returns the last entry in the collection.

Here's the template code:

{% paginate craft.entries.section(listingSection).order('postDate desc').limit(2) as entriesOnPage %}

Loading the latest content...

        {% for entry in entriesOnPage %}

            {% if entry.section.handle != 'tweet' %}

                {% switch entry.tileSize %}

                    {% case "Single" %}

                        {% include '_partials/_isotope_block_single.html' %}

                    {% case "Double Horizontal" %}

                        {% include '_partials/_isotope_block_horizontal.html' %}

                    {% case "Double Vertical" %}

                        {% include '_partials/_isotope_block_vertical.html' %}

                    {% case "Quadruple" %}

                        {% include '_partials/_isotope_block_big.html' %}

                    {% case "Quote" %}

                        {% include '_partials/_isotope_block_quote.html' %}

                {% endswitch %}

            {% else %}

                {% include '_partials/_isotope_block_tweet.html' %}

            {% endif %}

        {% endfor %}

    {% if paginate.nextUrl %}

                Load more posts

    {% endif %}

{% endpaginate %}


texts:
In my main plugin file I have the following code in my registerCpRoutes fucntion:

public function registerCpRoutes()
{
    return array(
        'campaignreports/subscribers/detail\/(?P<listId>\d+)' => 'campaignreports/subscribers/_detail/'
    );
}

I have a _detail.html template located in /templates/subscribers/_detail.html

For some reason this doesn't seem to work. I keep on getting a "Page not found" error.
As far as I can tell I have followed the docs on dynamic routing
Any ideas on what is going wrong here?

PS: I have uninstalled & reinstalled the plugin


texts: Is it possible to search an asset filename stored on a remote Amazon S3 volume?

texts:
I'm successfully using the .search element attribute to search asset filenames stored locally.

{% set mediaExists = craft.assets.folderId('6').search('filename:' ~ vLogID|slice(0, 5)) %}

Is it possible to search filenames stored on a remote Amazon S3 volume?

In my testing, it doesn't seem to be finding the remote files. It works when searching the local volume folderId('3') by not when the remote S3 folder folderId('6').

Background:
There is no direct relationship between an entry and assets. I upload all assets to the server via FTP and then index the volume in my Craft Control Panel. I can see the S3 asset in Craft CP and have cleared cache and reindexed the S3 folder source.

I am using a url query string to tell the template what the LogID is for the entry that is displayed. Then, the code searches the asset folder for any assets that contain that LogID number. If there are any matches, then those assets are displayed on the front end page in a slider.

I can see the S3 asset if I type in the direct asset url link so the permissions of Public seem to be set correctly.

This is my code that is searching the asset filename on the server:

<!-- grab log id and use slice filter  -->
{% set vLogID = craft.app.request.segments|last %}

<!-- Check to see if there is any media uploaded  -->
{% set mediaExists = craft.assets.folderId('6').search('filename:' ~ vLogID|slice(0, 5)) %}

The above code says:

Grab the LogID from the url query string (example: 12345).

Then, search the asset folder (set by folderID), search all of the files in the folder for any filenames that contain LogID (example 12345).

It works when searching the local volume folderId('3') but not when the remote S3 folder folderId('6').


texts: Is it possible to access Twig variables in a plugin variable using PHP?

texts:
I have a controller that returns route variables to the page:

craft()->urlManager->setRouteVariables(array(
  'errors' => $entry->getErrors()
));

On the page that gets loaded, I can access the variables I set in the template:

{% for error in errors %} ...

However, I want to handle this variable dynamically. Is it possible to access the 'errors' variable in my MyPluginVariable.php file without passing it directly to my variable function?

I don't want to do this:

{{ craft.myPlugin.doSomething(errors) }}

That passes my variable to the plugin variable and I can access it just fine.  But I don't want to ask the user to pass this variable to the function every time, I'd prefer to just handle it in the background.

So, on the page that gets loaded, instead of outputting the variable, can I have a Twig tag like this:

{{ craft.myPlugin.doSomething() }}

And directly access the 'errors' variable in my plugin?  Something like (this doesn't work):

craft()->request->getRouteVariables('errors')


texts: Get count of new entries since last visit

texts:
I'm relatively new to craft, but thanks to this board I am making great progress :-) But here is my first question, which is not answered in here:

I would like to get the count of entries of a certain section, which have been published since the last visit of a user. I'm pretty sure I have to somehow use a cookie for this, but am completely unaware of how to do this in combination with twig :(


texts: Return json formatted entries and include a header for Access-Control-Allow-Origin

texts:
Hi Not sure on the best way to do this. I have some javascript that requires a json formatted file to populate a calendar. I can do this in php by adding the following to the file that is being requested:

header('Access-Control-Allow-Origin: *');
    $array = array(
    array('date' => "27/9/2015", 'title' => 'BBC Event', 'link' => 'http://www.bbc.co.uk')
    );
echo json_encode($array);

I need to be able to do the same with craft. I have tried just formatting the entries in twig which returns the json as it should be but because the header is missing the javascript call does not run it. I have also created a small plugin to pull out all the entries which may be a better option. I just need to know how to return those entries in json to a template as per the above php would create with a header included.

Any help much appreciated.

Cheers


texts:
My client has requested to be able to filter the results page by price via a dropdown, which you can see in the attached screenshot.

Basically the results page shows a list of around 15 property developments, and is ordered alphabetically currently. I've setup two other dropdown filters to sort the categories by Location and by individual Development. And these work well. However, I'm stuck on how to actually implement this for price, and I can't find anything on the boards or documentation that have helped. So am hoping someone can give me some guidance.

The client wants the price dropdown to have the following options:

£0 - £999,999
£1,000,000 - £1,999,999
£2,000,000 - £2,999,999
£3,000,000 - £3,999,999
£4,000,000 - £4,999,999
£5,000,000+`

My initial approach is to create a tag group called priceRange and a tag field also called priceRange and I've entered the options above as tags and got them to show in the dropdown with the following code:

<form class="form-inline" action="{{ url('developments') }}" method="get">

    Price

      <select id="price1" class="form-control" name="price1" onchange="this.form.submit()">
        <option value="">All</option>
        {% for category in craft.tags.group('priceRange').order('title asc') %}
        <option value="">{{ category.title }}</option>
        {% endfor %}
      </select>

</form>

{% set query = "" %}
{% if craft.request.getParam('price1') and
craft.request.getParam('price1') is not empty %}
{% set query = craft.request.getParam('price1') %}
{% endif %}

{% set queryFilter = craft.categories.group('developments').search(query).order('title asc') %}

{% if queryFilter|length %}
{% for category in queryFilter %}

..the content..
{% endfor %}

So I have them showing in the dropdown, but any help on how to actually get it filter the results by by the selected price range would be very appreciated, and then sort those results by highest price.

Or a better approach even, as I am wary with the tags approach that the client might add extra tags with different prices for the same ranges. So I would ideally like to give them a defined list of options in CMS to select from that they can't then edit if possible?


texts:
I need to store phonetics for word definitions in a plain text field. An example would be something like "Craft Website" => \ ˈkraft ˈweb-ˌsīt \, like you'd see in a dictionary.

If I try saving \ ˈkraft ˈweb-ˌsīt \ in a custom plain text field, I get a database exception, presumably because it takes issue with all the unusual characters not found in UTF-8.

Does Craft have a way to handle this without needing to manually adjust my database?


texts: Error: "Tried to read the folder contents...but could not"

texts:
I'm stumped on this one, for the longest time when I clicked the "Clear Caches" button in the CP, everything seemed to be ok. But I recently checked the craft.log after noticing things didn't seem to be clearing out after all. There was this error:

2016-02-16 09:25:11

Level   error
Category    application
Message Tried to read the folder contents of /home/[company-name]/craft/storage/runtime/temp/, but could not.
2016-02-16 09:25:11

Level   error
Category    application
Message Tried to read the folder contents of /home/[company-name]/craft/storage/runtime/assets/, but could not.
2016-02-16 09:25:11

Level   error
Category    application
Message Tried to read the folder contents of /home/[company-name]/craft/storage/runtime/cache/, but could not.

The permissions are as follows:

/craft 755
  /storage 777
     /runtime 777
        /temp 777
           empty
        /assets 777
           empty
        /cache 777
           09f795de983f214fb0e9188dd884ec27.bin 664
           +another 26 of the same - these don't clear when I click the clear cache button

I tried changing the 664 to 777 but it reverted itself back to 664.

Any thoughts are appreciated!


texts: Maintaining and deploying many multi-site from a single codebase

texts:
We're developing an application that uses a multi-site Craft back-end with a JS front-end, making use of GraphQL. The intention is to maintain a single codebase that can be used to deploy new and update existing instances of the application.
Each client has their own installation of Craft (currently Craft 3.5), with multiple sites in each. To illustrate:
Client A:

site 1, clienta.ourdomain.com/someslug
site 2, clienta.ourdomain.com/anotherslug

Client B:

site 1, clientb.ourdomain.com/customslug
site 2, clientb.ourdomain.com/orangeslug
site 3, clientb.ourdomain.com/frenchslug

Client C:

site 1, clientc.ourdomain.com/potatoes

...etc
The underlying Craft components (i.e. fields, sections, entry types, plugins, etc.) are identical across clients. Initially, I thought that project-config would be all over this until I realised that site data is held in Project Config. With each client having a different number of sites with different slugs etc., that rules out keeping project config in a single git repository.
This, therefore, presents a maintenance and deployment nightmare. As it stands, the only (terrible) option as I see it is:

Create some kind of baseline config and store a matching SQL dump with it
Remove project config from the repo
Manually create migrations for any subsequent modifications.

I had considered forks of the main repo for each Client but again, if there's any project config in those, there's the potential to hose a client's site by modifying site-related data.
The ideal solution would be the ability to configure (!) project config, such that it ignores anything to do with sites. As far as I can see from the generated yaml, sites are only referenced in defining the site itself, and sections' site settings. Configuring the latter programmatically when a site is created is fairly straightforward.
If anyone has any experience of a similar setup, I'd very much appreciate the benefit of their experience.


texts: Mysql error when defining related tables

texts:
I'm trying to create some relational tables from 2 records but I keep getting the mysql error:

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1005 Can't create table 'craft1.#sql-75c_603' (errno: 150)

The relationship is between 2 tables: quote and quotedItem. I based the code off the relationship seen here: http://www.yiiframework.com/doc/guide/1.1/en/database.arr between the Post and User tables.

The tables create fine without the relationship defined (I've also noticed they create with the relationship but I also get the above mysql error when installing the plugin so I presume it hasn't worked correctly).

I'm new to making plugins so there's probably something obvious I'm doing wrong but if someone could point me in the right direction that would be great.

Here's my code for quoted Item:

class ShoppingCart_QuotedItemRecord extends BaseRecord
{
    public function getTableName()
    {
        return 'shoppingcart_quoteditems';
    }

    protected function defineAttributes()
    {
        return array(
            'quoteId' => AttributeType::String,
            'itemId' => AttributeType::String,
            'quantity' => AttributeType::String
        );
    }

    public function defineRelations()
    {
        return array(
            'quote' => array(static::BELONGS_TO, 'ShoppingCart_QuoteRecord', 'quoteId'),
        );
    }
}

And here's quote:

class ShoppingCart_QuoteRecord extends BaseRecord
{
    public function getTableName()
    {
        return 'shoppingcart_quotes';
    }

    protected function defineAttributes()
    {
        return array(
            'title' => AttributeType::String,
            'country' => AttributeType::String,
            'name' => AttributeType::String,
            'email' => AttributeType::String,
            'company' => AttributeType::String,
            'phone' => AttributeType::String,
            'department' => AttributeType::String,
            'reference' => AttributeType::String,
            'questions' => AttributeType::String
        );
    }

    public function defineRelations()
    {
        return array(
            'quotedItems' => array(static::HAS_MANY, 'ShoppingCart_QuotedItemsRecord', 'quoteId'),
        );
    }
}


texts:
Is there any way to merge trashed elements with an existing element? I'm creating a custom restore action so you can merge a trashed (commerce) Product with an existing one. The mergeElementsByIds function is failing because it uses the getElementById function which ignores trashed elements. Is there any work around?

Thanks in advance!


texts: Craft 3 setPasswordPath config not working for front end users

texts:
How do I change the link that's sent in a forgot password email that's sent to front end users in Craft 3? The setPasswordPath config isn't working for me.

The users don't have access to the CP. In my global config settings I have 'setPasswordPath' => '/account/set-password' I have a template based on the doc's Set Password Form example that loads at mysite.test/account/set-password.

The email is sent via a template that is based on the doc's Forgot Password Form example.

The links in the emails look like this: mysite.test/actions/users/set-password?code=r8tyzUikpXko0b2o5A785TC73geK0jvh&id=a91a64a3-8869-4f0d-a11b-2ad54d69303c

I want them to link to my template like this: mysite.test/account/set-password?code=r8tyzUikpXko0b2o5A785TC73geK0jvh&id=a91a64a3-8869-4f0d-a11b-2ad54d69303c

What am I doing wrong?


texts:
I read through the docs for Commerce, but could not figure out how to use Purchase Orders with Commerce.  I am still working through the trial version to make sure Commerce can do what the client is wanting.  I know the paid version has a manual gateway.  Want to make sure it will allow the collection of a Purchase Order.

Jeremy I tried what you suggest.  Here is what I have...

    {% if not craft.commerce.paymentMethods|length %}

No payment methods available.

    {% endif %}

    {% if craft.commerce.paymentMethods|length %}
        <form method="POST" id="paymentMethod" class="form-inline">

            <input type="hidden" name="action" value="commerce/cart/updateCart">
            <input type="hidden" name="redirect" value="commerce/checkout/payment">

            {{ getCsrfInput() }}

            Payment Method

            <select id="paymentMethodId" name="paymentMethodId"
                    class="form-control">
                {% for id,name in craft.commerce.paymentMethods %}
                    <option value="{{ id }}"
                            {% if id == cart.paymentMethod.id %}selected{% endif %}>{{ name }}</option>
                {% endfor %}
            </select>

                Purchase Order Number
                <input type="text" name="purchaseOrder"
                    placeholder="Purchase Order"
                    class="purchase-order-field"
                    value="{{ formValues.lastName }}">

        </form>
    {% endif %}

I am not surprised that it is not working as I really don't know what I am doing here.  Sure my form is wrong.  Any suggestions.  With your help on other areas I am almost finished.  This is the last thing I need to do and I will be finished.  Any suggestions or help will be greatly appreciated.


texts: Set custom sort order for index pages in the CP?

texts:
Good chance this is more of a feature request than a question you can help out. But as I am new to Craft plugin development and might oversee something I ask it anyways:

Now that it is possible to customize the index pages in the CP using the plugin hooks modifyEntryTableAttributes and getEntryTableAttributeHtml, what do I have to do to make my custom columns appear in the sort order dropdown / make the entries sortable by my new columns?


texts: Passing Twig Variable into Template from Include?

texts:
I'm trying to pass a variable value from an include into a template file.  The variable is imageRatio. Within this include file I have the logic which sets the right image ratio. My goal with this is to have one place to set the logic which I can reuse in different templates - I'm trying to keep the code DRY.

When I do the below get an error saying Variable "imageRatio" does not exist. What am I doing wrong?

The Main Template

{# The Image Ratio include #}
{% include '_includes/builders/images/imageVariants' %}

{# Create an Image Variant #}
{% set optimizedImages = block.image.one()[imageRatio] %}
{% include '_includes/builders/images/imageOptimize' %}

Image Ratio Include

{# Define Image Varient #}
{% if block.imageRatio == 'thumb' %}
    {% set imageRatio = 'imageVariantsThumb' %}
{% elseif block.imageRatio == '16by9' %}
    {% set imageRatio = 'imageVariants16by9' %}
{% elseif block.imageRatio == '3by2' %}
    {% set imageRatio = 'imageVariants3by2' %}
{% endif %}


texts: How can I select users that are not members of any user groups?

texts:
I'm struggling to find a way to use craft.users to select all users that are not members of any groups. Looking at the User Element Type both the groupId and group parameters are used to perform additional queries which will return nothing unless a valid group Id or handle is provided... I think.

Is it possible to find users not in groups or will I have to do this post retrieving all users... I need to paginate the results so this is not ideal.


texts: Is there a way to have checkbox field labels translatable?

texts:
So I have a checkbox field in the new entry editor page. Attached image is an example of said checkbox. Just a standard checkbox field.

Is there a way for these checkboxes to be translatable? I'm redisplaying these checkboxes again in the front-end as filters so users can click the any of the checkboxes and the entries display will be filtered based on their input.

Short of hardcoding all these checkbox values and applying the translate tag on them, I'm not sure what else I can do.

Thanks!


texts: How to separate a parent and it's children when looping through a category?

texts:
I have categories of cities and states set up as parents and children, for example:

California
  - Los Angeles
  - San Francisco

New York
  - New York City

When I use:

{% for place in entry.location %}
  {{ place }}
{% endfor %}

it returns to me the city state (for example: "Los Angeles California"). How can I separate out the parent and child? Ideally, I want to do something like this:

{{ place.child }}, {{ place.parent }}

Thanks.


texts:
I have a site that I need to remain turned off for a while (while the client enters content). I do however need public user registration to be available.

Is it possible to make this one page visible even when the system is switched off in the settings?


texts: Cannot find control panel after installation

texts:
After installing craft on apache server, when I try to access control panel using web/admin, serwer throws 404 error.
I didnt changed cpTrigger setting. Default craft template that displays after installation is displayed correctly.

.htaccess file in web directory was not modified in any way, its contents are default:

<IfModule mod_rewrite.c>
    RewriteEngine On

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


texts: Remove outdent & indent from Redactor2 "lists" button

texts:
Redactor 2 introduced a single "lists" option for ordered and unordered lists but unfortunately this adds the outdent and indent options in as well.
Any way of removing outdent/indent again?


texts: How do I set up a section for pages with very flexible content?

texts:
I'm trying to build a page similar to the index page of buildwithcraft.com. There you have a page with (visual) sections ("A new kind of flexible", "Ready where you are" and so on). Each one has different backgrounds and maybe different layouts as well. Therefore you need a different set of input fields for every such section.

What's the best way to set up a (craft) section that allows you to edit pages like that?


texts:
Is there a way to omit index.php from the URL when using IIS server? Adding

'omitScriptNameInUrls' => true,

seems to break the site (except for the front page). index.php is removed from the menu links, but when called the sub-pages result in a 404.

This is my first Craft site on IIS, and I have no experience with IIS. It is the client choice unfortunately.


texts: Replacement for deprecated EntryRevisions service

texts:
Client has a custom Craft plugin for managing their bespoke publication workflow on a large website. Content creators create new or updated content that is saved as drafts, then inspected and approved by editors before publication.

This plugin makes heavy use of the EntryRevisions Service Which has been deprecated in CraftCMS 3.2. For example, the plugin often fetches a draft instance by ID before performing other actions (publish/edit/delete), using information in the draft to create a notification email, or getting the contents of the draft for review. The plugin has it's own tables the track drafts by it's ID alone, so it's my primary means of looking up drafts.

The API documentation says to use the EntryQuery API instead, but the docs don't mention how to get a draft or revision.

Does anyone know how drafts are fetched and worked with going forward?


texts: Padding on .redactor-editor hides "structure" setting display

texts:
Trying to use the Redactor "structure" setting: https://imperavi.com/redactor/docs/settings/special/#setting-structure

Craft overrides the padding on .redactor-editor, which makes the display a bit broken when using this setting.

https://goo.gl/photos/Qi9HbLmsvyGNGxsw9


texts: Query all categories once and get individual categories from array

texts:
I am working on a site that needs to both list all categories and also pull out individual categories by their id.

I would like to query the DB once for all the categories (to improve performance), and then pull out which ones I want, but am struggling to find a solution.

{% set catNavigation = craft.categories.group('products').limit(null).find() %}

{{ catNavigation.id(102).first.title|raw }}

{{ catNavigation.id(126).first.title|raw }}

This is giving me an error.

Array to string conversion

So I guess I can't grab pieces of an element criteria model after using find.

If I don't use find, then I query the DB multiple times.

I thought about creating my own array of categories dynamically with twig, but that has not gone well.

Is there a way to accomplish what I'm after? It's as if I need to search within an array of data that has already been returned from the DB. Hope that makes sense.


texts: How do you use a Matrix to toggle between multiple fields from multiple blocks?

texts:
I have 1 Matrix field:
contentBlock

With 2 Block types:
text
photo

With nested fields:
text -> text
photo -> photo

My attempt at using if statements, which didn't work, to toggle between text and photo looks like the following:

{% for block in entry.contentBlock %}
    {% if block.type == 'text' %}
        {{ block.text }}
    {% endif %}
    {% elseif block.type == 'image' %}
        {% set image = block.image.first() %}
            {% if image %}
                <img src="{{ image.getUrl('thumb') }}" alt="{{ image.title }}">
            {% endif %}
{% endfor %}

Would using {% switch %} be a better method, or was I close to correct using the if statements?
I think getting the hang of this will open up the true posibilities of using Craft Matrix fields.

Thank you for any input on this question.


texts: Is it possible to merge entry parameters to create a dynamic field handle?

texts:
I'm trying to merge a field name prefix with entry.section to make a dynamic field handle. I'm guessing I'm setting the sectionMatrix variable incorrectly, causing the code to fail without error. Any tips would be greatly appreciated.

Channels:

News
Press

Each channel has is own matrix field, with different blocks:

entryMatrixNews
entryMatrixPress

Template Code:

{% set newsSectionIds = craft.entries.section('news').ids() %}
{% set pressSectionIds = craft.entries.section('press').ids() %}
{% set entryIds = newsSectionIds|merge(pressSectionIds) %}
{% set entries = craft.entries.id(entryIds) %}

{% for entry in entries %}
   {% set sectionMatrix = 'entry.entryMatrix' ~ entry.section %}
   {# sectionMatrix then equals either entry.entryMatrixNews or entry.entryMatrixPress #}

   {% for block in sectionMatrix %}
      {# my matrix code #}
   {% endfor %}

{% endfor %}


texts:
The customer currently has an app build with Symphony 3.4. The current set-up is too complex to maintain, user unfriendly and not flexible, lags a maintainable SEO structure.
The main function of the app (site) is to combine client request to professional workers. As an example: a client has a leak in the sink and is looking for a plumber.
Process steps:

Existing or new client fills out a form (registers himself as a
user), selects the category of professionals he needs, suggest a
date for the fix, describes the problem (texarea) and uploads one or
more photos showing the issue. This is in fact an order without a
price.
The admin (a person in the back-end) decides which professional
(professionals are signed up via a separate process, and are also
registered users) fits best. And couples the clients order to the
professional.
An email notification is sent to the pro. The pro logs in to his
account, accepts the order to be accomplished at the date given by
the client. Adds a quotation (single price field) and a description.
The client receives an email notification that his order was coupled
to a professional and is requested to login and accept the quotation
given by the pro.
Once accepted by the client the pro fulfils the order at the date given.
The pro logs in to his account, adds a photo and time of the job
done. Uploads the invoice(.pdf).
The client gets a notification, logs in, pays the invoice (using stripe: cc and PayPal)
and is requested to give a rating from 1-5 and a comment on the job done. The order
status is set to fulfilled.
The pro is notified that his invoice is paid and is able to see the
rating (not the comment) for his work on this assignment.

There's a whole lot more but this is the core process of the system and we lacking a bit of experience specifically there.
So the question is can this be handled in Craft alone? Craft Commerce seems to have some of the functions available but expects a product/order price (in our situation the price is only set later in the process). Is a dedicated plugin needed to accomplish these tasks?


texts: What happened to commerce_discounts->saveDiscounts or How to relate vouchers to product types in Commerce 2?

texts:
We sell vouchers to our shop users. To prevent them for being used on vouchers themself, i could relate them to specific productTypes or even products in Commerce 1.

craft()->commerce_discounts->saveDiscount($discount, $groups, $productTypes, $products)

In Commerce 2 the 3rd and 4th parametes are gone. How can i relate vouchers to product types programmaticely?


texts: Submitting checkbox data from a front-end form for a 'Categories' Field Type

texts:
I have read a few docs about front-end forms such as the Checkbox field docs.

Although that doc doesn't seem to give an example of what I need.

I have a 'categories' field type. I am creating a front-end form that will need to submit what is checked to the entry. I have tried a few different ways and can't get it to work. This is the last code I tried:

Design Tags

{% set categories = craft.categories.group('designs') %}

{% for category in categories %}
    <input type="checkbox" id="designTags" name="fields[designsTags][]" value=" {{ category.id }}"> {{ category.title }} </input>

{% endfor %}

I also tried changing category.title to category.id, but no luck with that either.

And before that, I tried something similar to the code at the bottom of this page (using the option.value) and it still wouldn't work.

Any help you can give is greatly appreciated! :)


texts:
When I watch my site trough live preview the previewframe is left blank, and in the console there appears the error: `

  XMLHttpRequest cannot load http://domain.com/template . No
  'Access-Control-Allow-Origin' header is present on the requested
  resource. Origin 'http://www.domain.com' is therefore not allowed
  access.

What is that?


texts: Method to grab URL hash in Twig or craft.request?

texts:
Is there a method or recommended way of grabbing URL hash parameters with Twig?

For example, if my URL is http://mysite.com/my-page#hash, is there a way to grab the hash?


texts: Non-admin users cannot preview/view entries when site front end is disabled (multisite)

texts:
I am running a multisite setup on 3.6.11.2. We are attempting to generate a new site and while we work on the structure/content I have the 'Enable on the front end' setting switched off. As an admin, I can still use the 'Preview' and 'View' options just fine (url looks something like /path/?siteToken=abcd123 when viewing), and if I grant admin access to another user they can as well. However, non-admin users are unable to preview/view the pages on the disabled site. I have given them the 'access when site is off settings' as well as access to the disabled site.
Checking the apache access log, non-admin users appear to be getting the same treatment as non-users, which is a 302 that then turns into an endless chain of 302s that are hitting index.php?siteToken=abcd123.
Is there a way to allow people access to preview/view entries when sites are disabled on the front end, without giving them full admin access?


texts: How to upload a template in Craft CMS 3 on an Ubuntu web server

texts: Really new to this platform and could use some help with how to upload a theme/template which I downloaded from ThemeForest.  The files are compatible with HTML 5 and Craft 3 is on an Ubuntu server.


texts: Product Combination Discount in Commerce 2?

texts:
Is there a way to set a discount in Commerce 2 that applies when, for example, three various products are in the cart?

Use case;
Say you have a blue shirt, a black pant and a red cardigan, in the cart, and you wish to treat those as a kit. When all three are in the cart (either specific color variant, or simply a product), subtract $20 (or a percentage) from the total.

Edit;
It would seem that adjusters is the way to go. Can someone shed some light on where those go, and how one would go about it when checking for multiple products against each other? Is the best way to create a module? Is there no admin UI whatsoever for adjustments? Is there a way to build adjustments with twig? Sorry, that's a lot of questions in one topic.


texts: Set category's canonical URL on a custom route

texts:
Global category content canonical URL pattern seems to set og:url, but not the canonical one. I've tried replacing @web with the address proper without any change. I suspect I've misconfigured something.
The category group's URL pattern is: product-categories/{slug},
and it's canonical URL in content SEO is: @web/products/{category.slug}.
A custom route loads the template: products/{tag}.
Which does a: seomatic.helper.loadMetadataForUri(category.uri).
However,
In a category's SEO preview the canonical URL is still product-categories/{slug}.
While in the header of a product/{category} page the canonical URL link isn't present.
Adding a link with seomatic.link.create({"rel": "canonical","href": canonicalUrl,}) works like a charm.


texts:
I've got a notification set up when a user is saved/updated.

I'm trying to add the author/user who made the update

Tried the following to see what returns and nothing:

{author}

{author.email}

{author.firstName}

{{object.author.email}}


texts: Imager - HTTP status “401” error while generating transform

texts:
When I uploaded the website to a new server, some transforms don't generate and throw an exception instead:

HTTP status “401” encountered while attempting to download “https://domain.com/web/uploads/image.png”

I'm not really sure what causes this - some images cause this problem and some don't. All are from the same asset source.


texts: Entry reverse lookup on ancestor's field

texts:
I need to tune performance on a Craft 2 build. We are quite new to Craft CMS, so please bear with me if the question sounds silly.

We need to render a page that needs to display information from 4 sections, A->B->C->D, with the latter having a reference to the former, i.e. B has a field linking to A, C has a field linking to B, and D has a field linking to C. The page needs to list A entries with information gathered from B, C, D. We ended up using relatedTo in three foreach lookup until D, which turned out to be super inefficient. I managed to find out that using eager-loading of elements can greatly reduce the number of queries, which in my case, I've got 400+ queries down to about 40. The page load time is roughly 2s (from previous 30+ seconds!).

However, I think there might be an even better way to query the db. Currently, I am querying all elements of A, taking this array to query all related entries of B, which again is taken to query all entries of C. On querying entries of C, this is where eager-loading happens. The query on C section looks like this:

$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section = 'Section A';
$criteria->with = array(
    'b',
    'b.field_a',
    'd',
);
$criteria->relatedTo = array(
    'targetElement' => $obj,
    'field' => 'field_d'
);

I am wondering if there's a way to query related entries based on a field from an ancestor, like

$criteria->relatedTo = array(
    'targetElement' => $obj,
    'field' => 'field_d.c.b.a.field'
);

That would save me from querying B and C entries.

Many thanks!


texts:
Is there a way to override the Craft Commerce config files ?

I'm specifically talking about this one, deep inside the plugin craft/plugins/commerce/etc/currencies.php

I'd like to change the default amount of decimals for Euros