texts:
After I install craft, I am getting the following error when trying to load the website including the admin page:

PHP Stack trace:
PHP   1. {main}() \aspace\index.php:0
PHP   2. require_once() \aspace\index.php:14
PHP   3. CApplication->run() \aspace\craft\app\index.php:35
PHP   4. Craft\WebApp->processRequest() \aspace\craft\app\framework\base\CApplication.php:180
PHP   5. Craft\UserSessionService->requireLogin() \aspace\craft\app\etc\web\WebApp.php:272
PHP   6. CHttpRequest->redirect() \aspace\craft\app\services\UserSessionService.php:371
PHP   7. CApplication->end() \aspace\craft\app\framework\web\CHttpRequest.php:805
PHP   8. CApplication->handleError() \aspace\craft\app\framework\base\CApplication.php:0
PHP   9. CErrorHandler->handle() \aspace\craft\app\framework\base\CApplication.php:816
PHP  10. Craft\ErrorHandler->handleError() \aspace\craft\app\framework\base\CErrorHandler.php:131
PHP  11. CErrorHandler->handleError() \aspace\craft\app\etc\errors\ErrorHandler.php:152
PHP  12. CErrorHandler->render() \aspace\craft\app\framework\base\CErrorHandler.php:289
PHP  13. CWebApplication->runController() \aspace\craft\app\framework\base\CErrorHandler.php:331
PHP  14. CController->run() \aspace\craft\app\framework\web\CWebApplication.php:282
PHP  15. CController->runActionWithFilters() \aspace\craft\app\framework\web\CController.php:265
PHP  16. CController->runAction() \aspace\craft\app\framework\web\CController.php:286
PHP  17. CInlineAction->runWithParams() \aspace\craft\app\framework\web\CController.php:308
PHP  18. Craft\TemplatesController->actionRenderError() \aspace\craft\app\framework\web\actions\CInlineAction.php:49
PHP  19. Craft\BaseController->renderTemplate() \aspace\craft\app\controllers\TemplatesController.php:190
PHP  20. Craft\TemplatesService->render() \aspace\craft\app\controllers\BaseController.php:98
PHP  21. Twig_Environment->render() \aspace\craft\app\services\TemplatesService.php:220
PHP  22. Twig_Environment->loadTemplate() \aspace\craft\app\vendor\twig\twig\lib\Twig\Environment.php:292
PHP  23. __TwigTemplate_d77269d0acd17023cd9970dd5812452d2a881ef03373e6e22c0d80eb68481e00->__construct() \aspace\craft\app\vendor\twig\twig\lib\Twig\Environment.php:345
PHP  24. Twig_Environment->loadTemplate() \aspace\craft\storage\runtime\compiled_templates\d7\72\69d0acd17023cd9970dd5812452d2a881ef03373e6e22c0d80eb68481e00.php:10
PHP  25. __TwigTemplate_9fccce442511366b01108e1e704c62f53125ce92b05eb6545ea02e38a06a15b3->__construct() \aspace\craft\app\vendor\twig\twig\lib\Twig\Environment.php:345
PHP  26. Twig_Environment->loadTemplate() \aspace\craft\storage\runtime\compiled_templates\9f\cc\ce442511366b01108e1e704c62f53125ce92b05eb6545ea02e38a06a15b3.php:10
PHP  27. Twig_Environment->getTemplateClass() \aspace\craft\app\vendor\twig\twig\lib\Twig\Environment.php:323
PHP  28. Craft\TemplateLoader->getCacheKey() \aspace\craft\app\vendor\twig\twig\lib\Twig\Environment.php:265
PHP  29. Craft\TemplateLoader->_findTemplate() \aspace\craft\app\etc\templating\twigextensions\TemplateLoader.php:71
PHP  30. Craft\TemplatesService->findTemplate() \aspace\craft\app\etc\templating\twigextensions\TemplateLoader.php:119
PHP  31. Craft\TemplatesService->_validateTemplateName() \aspace\craft\app\services\TemplatesService.php:835
PHP  32. Craft\PathHelper::ensurePathIsContained() \aspace\craft\app\services\TemplatesService.php:1178
PHP  33. Craft\HttpRequestService->decodePathInfo() \aspace\craft\app\helpers\PathHelper.php:29
PHP  34. Craft\StringHelper::convertToUTF8() \aspace\craft\app\services\HttpRequestService.php:1072
PHP  35. Craft\StringHelper::getEncoding() \aspace\craft\app\helpers\StringHelper.php:390
PHP  36. mb_detect_encoding() \aspace\craft\app\helpers\StringHelper.php:460

Can anyone help me with this error?


texts:
Is it me, or can we not search using partial words in Craft CMS? This seems to be the case in the backend when search entry titles or assets, but a client has recently pointed it out on the front-end as well.

For example, we've got an entry title containing the word 'Peruvian' but searching for 'Peru' returns no results, while searching for 'Peruvian' does return a result.


texts: Element Actions for Entries being viewed from modifyEntrySources

texts: Im using the modifyEntrySources hook in my plugin, when I view the entries based on my custom criteria it doesn't show the checkboxes for element actions, is there a way to get these back or is this a bug?


texts: Recommendations for Form Integrations with Salesforce?

texts:
I'm new to Craft and really loving it so far. I'd like to use something like Sprout Forms or Freeform (are there others worth looking at?) but I really need to be able to submit any data to Salesforce.

I know Freeform has a Salesforce integration but from talking with support it sounds like it only works with Leads and I need custom Object support.

i.e. we have job application forms and other applications that use custom Objects and from time to time we do add others.

With Sprout Forms I've been looking into Payload Forwarding and what I could maybe do with that.

Does anyone have any experience with this and any recommended approaches? I'm more of a Front-End Dev so looking at something I could sort myself but if not I'll be looking at hiring someone to help me pull a solution together.


texts:
I'm building a site that makes heavy use of the Matrix field, which overall has been great. The one problem I'm running into is that I find myself duplicating a lot of Matrix blocks.

To use the documentation as an example, you see block types such as heading, pull quote, image, etc. Building out a complex site, I find myself using these common types of blocks in various matrixes(matricies?) and the only way I've found to do so is literally to just type the same thing over and over, which leads to more time and potential inconsistencies, not to mention the maintenance.

Obviously I could just define one large matrix field and put it everywhere, but I'd like to have more control than that across different pages. Is there a way to reuse these components or perhaps a different style that is recommended?

Similar question here, but I'm specifically asking about entire blocks, not individual fields.


texts: Is there a way to credit a customer's account in Craft Commerce?

texts:
Our client would like to accept gift certificates as a form of payment. I've looked into the 2 stripe plugins they offer for gift certs, but neither of them will work for my client -- one is a separate off-site gateway, and the other is $90 a month, which is off the table completely.

Is there a way to assign credit to a user's account and allow them to take that amount off before the purchase? So we would sell the gift certificate and enable it on the user account, then they could purchase things online?

Any other good ideas on how to handle gift certs?


texts:
I have been trying to get my head wrapped around Migrations in Craft 3 and find myself struggling with added a new section.

I have managed to add a new volume, but not a section. Here’s where I have got to so far…

<?php

namespace craft\contentmigrations;

use Craft;
use craft\db\Migration;

/**
 * m180428_195138_test migration.
 */
class m180428_195138_test extends Migration
{
    /**
     * @inheritdoc
     */
    public function safeUp()
    {

      if (is_null(Craft::$app->volumes->getVolumeByHandle("newvolume"))) {
        $volume = new \craft\volumes\Local([
          "name" => "New volume",
          "handle" => "newvolume",
          "hasUrls" => true,
          "url" => "@web/images/newvolume",
          "path" => "@webroot/images/newvolume"
        ]);

        Craft::$app->volumes->saveVolume($volume);
      }

      if (is_null(Craft::$app->sections->getSectionByHandle("awesomeNews"))) {
        $section = new \craft\models\Section([
          'name' => 'Awesome News',
          'handle' => 'awesomeNews',
          'type' => 'Channel',
          'siteSettings' => [
              new \craft\models\Section_SiteSettings([
                  'siteId' => Craft::$app->sites->getPrimarySite()->id,
                  'enabledByDefault' => true,
                  'hasUrls' => true,
                  'uriFormat' => 'foo/{slug}',
                  'template' => 'foo/_entry',
              ]),
          ]
        ], true);

        Craft::$app->sections->saveSection($section);

      }

    }

    /**
     * @inheritdoc
     */
    public function safeDown()
    {

      $newvolume = Craft::$app->volumes->getVolumeByHandle("newvolume");
      if (!is_null($newvolume)) {
        Craft::$app->volumes->deleteVolumeById($newvolume->id);
      }

      $awesomeNews = Craft::$app->sections->getSectionByHandle("awesomeNews");
      if (!is_null($awesomeNews)) {
        Craft::$app->volumes->deleteSectionById($awesomeNews->id);
      }

    }
}

The migration states it has been successful, however, I only see the new volume, not the section. I have tried to execute this with only the block relating to the section.

Does anyone know if it is possible to create a new section with Migrations? If it is, any idea what may be wrong with the above?


texts: Examples of magazine/newspaper publication websites using Craft?

texts: I was just wondering if anyone has any examples of any mag/newspaper websites that use Craft? I'm interested to see the blend of technology or how the layouts turned out. Thanks!


texts: Craft Admin assets do not load over https (Apache & Cloudflare)

texts:
staging.website.com loads perfectly over https. However, https admin pages immediately break because the assets are trying to load over http. If I navigate to the https asset directly, it loads fine. It would seem that Craft is failing to recognize the https request and kick over to the https url.

Server Setup:

Cloudflare DNS / SSL
Arcustech VPS with Ubuntu & Apache

How I am enforcing HTTPS currently:

Cloudflare Page Rule (Always Use HTTPS)
Craft config: general.php > environmentVariables (siteUrl, baseCpUrl, etc.)

I do not have any https redirects going in my .htaccess - just the standard craft index.php logic. Adding https rules in the .htaccess will cause infinite loop redirects.


texts: Cannot connect to outside mssql database in production

texts:
Error: Craft CMS can’t connect to the database with the credentials in config/db.php.
I have two database connections. One to mysql for the bulk of the website including all things craft, and one connection to mssql. I modified /config/app.php to include the mssql connection credentials to access them via twig:
        {% set myquery = craft.query()
        .select(['*'])
        .from(fromSql)
        .orderBy('Project ASC')
        .all(craft.app.theMSSQLConn)
        %}

This works on my local and staging environment, but the errors start on production. The file throwing the errors (mysite/vendor/craftcms/cms/src/db/Connection.php) first threw an error "Craft CMS requires the PDO_PGSQL driver to operate". I'm not using pgsql, but I installed the extension anyways and now I have a new error, in the same function of open(), stating craft cannot connect to the database with the credentials in config/db.php. The file config/db.php contains the mysql credentials which are correct and are working. I'm not sure what to do. It seems like Craft is attempting to open my mssql connection using the credentials in config/db.php as opposed to the credentials provided in config/app.php.
Edit: craft.app.theMSSQLConn is returning the correct connection string.
For more context, I was following an article by Andrew Welch here: https://nystudio107.com/blog/cutting-the-cord-removing-plugins#plugin-4-connect


texts: Associate child categories only to an entry

texts:
When adding a Categories field to a section, if you select only child categories, Craft automatically selects the parent categories too. I emailed Craft support about this and they explained it's by design and the workaround is to use a Structure instead of Categories.

I'm unhappy with this as a workaround and was hoping their was another way to do this, either with a custom plugin or something else?

Any help much appreciated

Thanks!


texts: On a Archive: how could I break cache for the current year, but not the others?

texts:
I have an archive of an event based site.
I know how to break cache until the next event. No Problem

{% cache until nextEvent %}

But the archive works the following way:

archive
-- 2014 (latest year)
-- 2013
-- 2012
-- 2011

The until nextEvent part makes only sense for the latest year. The other years should be cached forever.

How could I achieve such a thing?

-- edit --

Maybe I have to go a little more into the details:
I get the year in the forth segment.
Now it should cache the whole loop and never break it, unless it's the actual year, then break it each night:

{% set latestYear = now|date("Y") %}

{% if year is not defined %}
    {% redirect "club/programm/archiv/"~latestYear %}
{% endif %}

{% set year = craft.request.getSegment(4) %}

{# Set the first day of the year and the last #}
{% set lastyear = year -1 %}
{% set nextyear = year +1 %}
{% set yearbegins = '1 January ' ~ year %}
{% set yearends = '1 January ' ~ nextyear %}
{% set unixbegins = yearbegins | date('U') %}
{% set unixends = yearends | date('U') %}

{# Today at 00:00 #}
{% set today = now|date("Y-m-d") ~ ' 00:00' %}
{% set tomorrow = now|date_modify("+1 day")|date("Y-m-d") ~ ' 00:00' %}

{% set entriesByYear = craft.entries.section('programm').limit(null).cf_date('and', '>= ' ~ unixbegins, '< ' ~ unixends, '< ' ~ today| date("U")) %} {# '> just to make syntax highlighting correct #}

{% cache until tomorrow %}
    {% for month, entries in entriesByYear | group("postDate|date('F')") %}

        {# MONTHLY HEADER #}

{{ month }} {{ year }}

        {# ENTRIES PER MONTH #}
        {% for entry in entries %}

                {% include "programm/_common" %}

        {% endfor %}
    {% endfor %}
{% endcache %}

maybe that helps someone to help me ;)
cheers
stefan

--- edit 2 and solution ---

so after the comments of victor I updated the code. and it works like a charm:

{% set latestYear = now|date("Y") %}

{% if year is not defined %}
    {% redirect "club/programm/archiv/"~latestYear %}
{% endif %}

{% set year = craft.request.getSegment(4) %}

{# Set the first day of the year and the last #}
{% set lastyear = year -1 %}
{% set nextyear = year +1 %}
{% set yearbegins = '1 January ' ~ year %}
{% set yearends = '1 January ' ~ nextyear %}
{% set unixbegins = yearbegins | date('U') %}
{% set unixends = yearends | date('U') %}

{# Today at 00:00 #}
{% set today = now|date("Y-m-d") ~ ' 00:00' %}
{% set tomorrow = now|date_modify("+1 day")|date("Y-m-d") ~ ' 00:00' %}

{# Get the Date of the next Event, to allow caching until then #}
{% set nextEvent = craft.entries.section('programm').cf_date('>= ' ~ today| date("U")).order('cf_date asc').first() %}{# '> just to make syntax highlighting correct #}
{% set nextEventDate = nextEvent.cf_date|date_modify("+1 day")|date("Y-m-d") ~ ' 00:00' %}

{# Get all the events within the year concerned #}
{% set entriesByYear = craft.entries.section('programm').limit(null).cf_date('and', '>= ' ~ unixbegins, '< ' ~ unixends, '< ' ~ today| date("U")) %} {# '> just to make syntax highlighting correct #}

{# If the year is the current year, cache it until the next event. Otherwhise, cache indefinitely #}
{% if year == latestYear %}
    {% cache until nextEventDate %}
        {% include "club/programm/_archive_common" %}
    {% endcache %}
{% else %}
    {% cache %}
        {% include "club/programm/_archive_common" %}
    {% endcache %}
{% endif %}

thanks for all the fish!
stefan


texts: How do I output the value of a field from a Category selected from a Matrix?

texts:
I'm new to craft so this is a bit newbie question.

I have a category group with a set of categories, each category has a plain text field associated with it. The category group is then used as a field in a Matrix so the user can select one of the categories in the group. Basically all I want to do is list the plain text field from the selected category onto the page.

I tried working something out from https://craftcms.com/docs/relations (Going through a matrix section) but I just kept breaking everything. Any assistance would be appreciated!

Thanks.


texts: Get 404 Error When Going to mydomain.com/news

texts:
Craft newbie here.  I have been playing with craft now for a few weeks and built out a couple of pages. I am really liking it this CMS.  The one small problem that I just noticed however, is when I tried to go to the news template (for example) by going to http://example.com/news I get a 404 error.  It works fine when going to http://example.com/index.php/news.

Am I missing something or does the index.php always need to be in the address?

When I read the documentations it says either way would work, so I am sure I am doing something wrong or missing something really simple.

I would appreciate it if someone can point me in the right direction.


texts: How do I reference the settings of my plugin?

texts:
In the main Plugin.php file of my plugin, I can retrieve the plugin's settings like this:

$this->getSettings()

How do I retrieve those same settings from elsewhere in the plugin?

I want to reference those setting from my Service.php file.


texts:
How can I avoid local specific templates? I'd like just to use one template for all languages.

My current template structure is extending layouts/_base, and layout/_site [similar to happylager demo] and I have a template called 'help' but i dont want to set 'fr/help', 'es/help'


texts: Dynamic asset subfolder path for Craft Commerce

texts:
I have a asset field where I would like to save the images in dynamic folders.
The upload folder should be parsed for the Dropdown field values in a Matrix field.

For a normal Dropdown field it works with

{{ object.dropdownFieldHandle }}

but for a Dropdown field in a Matrix field i can't get it working.

Any help is very appreciated. Thank you in advance.


texts:
I have a category page displaying only the entries associated with the respective category. I have added a dynamic sub nav for categories using the following:

    {% nav category in craft.categories.group('biographySection') %}

            {{ category.title }}

    {% endnav %}

I need to add an active class on the active link. Can’t figure out the best way to do this. Any help is appreciated.

Below is the code used to display the content from a selected category:

{% set bio = craft.entries.section('biographies').relatedTo(category).find() %}
{% for entry in bio %}
    {{ entry.title }}
{% endfor %}


texts: How to fetch entries in custom plugin Craft 3?

texts: I am creating custom search based on entries. I need to fetch entries in custom plugin.


texts: Changed section from Channel to Structure, but can't re-order entries

texts:
As the title says, I changed a section from Channel to Structure, but when clicking on that section in the dashboard, the layout still looks like a Channel, and I'm not able to reorder/drag the entries.

I've tried switching the section back to a Channel, and then again back to a Structure, with no change. Most of the entries were added since switching over to Structure, but they all still behave like Channel entries.


texts:
When either of two of our admin logins attempt to add a new admin user and select to send an activation email, we get this error message:

  Internal Server Error  stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

Why is Craft CMS attempting to connect with SSL3 which is intentionally disabled at the server level due to known vulnerabilities?


texts:
I've got a project where I'm trying to set up a basic page layout – header, body, footer. But I also want the option for a user to add an image or bit of content (let's call it a "sidebar") that splits the body section into two columns – one for body copy on the left and one for the new content on the right.

For this, I'm using a Matrix field (for the user to create sidebar content on the fly) and Bootstrap (for the grid). When sidebar content is created for the entry, I'm hoping to be able to add a "col-sm-8" class to the body wrapper, as well as add a div with the "col-sm-4" class for the sidebar column for it to reside in.

Now, I have experience with creating static layouts in Bootstrap, but I'm woefully inexperienced at dealing with anything related to coding logic that isn't an if/else statement, and I can't seem to work out the code for Matrix in Twig.

I also need to be able to add different kinds of content (or blocks) in the sidebar, so the logic should also need to check for whether one or more kinds of blocks are populating, but still apply the same effect.

Can anyone provide an example of how to do this?

edit: BTW, I have read the documentation on templating Matrix fields. I just don't know how to check for multiple block types in order to print a class name & create a new column.


texts:
How should I structure a .csv and process the data to import matrix fields?

Whith table I used a json_encode but of course this doesn't work with matrixes.


texts: How can I push a result of entries/products from a loop into an array?

texts:
In the grand scheme, I am trying to get all products that are not related to specific categories.

Since any product can belong to any given number of categories, I am trying to loop through all categories and then only query against the categories that I want.

This is what I have so far:

{% set excludeCategoryIds = [36, 44] %}
{% set allProducts = craft.commerce.products.type('myType').order('title asc') %}
{% set products = [] %}

{% for category in craft.categories.group('myCategories').relatedTo(allProducts) %}
    {% if category.id not in excludeCategoryIds %}
        {% set entries = craft.entries.relatedTo(category) %}

        {# push entires into products?? #}
        {% set products = products|merge([entries]) %} {# doesn't work #}
    {% endif %}
{% endfor %}

Once all products are found, then I'll loop through them.

{% if products|length %}
    ...
{% endif %}

I could also loop through each of the entires as described in the docs but it's starting to feel like this is getting out of control.

Is there a better way to only show products that are not related to specific categories?

Thank you for any suggestions!


texts: How to update (or CRUD) products (or entries) via API?

texts:
I want to update certain fields of a product (or entry) from a 3rd party.

I see some talk about plugins and some refer to this .all talk about Creating a RESTful API with Craft 3.

I found the Craft CMS Element API, but it seems to be a way to create a read-only API.

How can I update a product's fields from a 3rd party?


texts:
I would like to configure the rich text editor in Entries->Singles content blocks like I do in my plugins and forms.  I know I can configure Redactor config within the /craft/config/redactor directory, but that does not impact the editor within //admin/entries/.

Where is the config for the admin entries editor?


texts: How do you show which Sale a product has applied in Commerce?

texts: It's easy to know if a product has a valid Sale applied to it with product.defaultVariant.onSale - but how do you know which Sales are being applied to the product? How do you output that the product is currently part of a specific named sale, and any associated content you might want to show?


texts: How to display entries with a custom date field within month

texts:
I've got a date field, and I'm grabbing the month and year from the url. What I'm after is to display all the events within the month, but for some reason I can't get this to work

{% set firstDayOfMonth = month ~ "/1/" ~ year|date("U") %} // returns the 1st day of the month in unixtime

{% set daysInThisMonth = firstDayOfMonth|date('t') %}
{% set lastDayOfMonth = month ~ "/" ~ daysInThisMonth ~ "/" ~ year|date("U") %} // returns the last day of the month in unixtime

{% set thisMonthsEvents = craft.entries.section('events').eventDate('and', '>= ' ~ firstDayOfMonth, '<= ' ~ lastDayOfMonth) %}

{% if thisMonthsEvents | length %}
    some events
{% else %}
    no events
{% endif %}

Any ideas? firstDayOfMonth and lastDayOfMonth return dates fine, but no matter how I format them, the result is no entries returned. For example, firstDayOfTheMonth could output "2014-6-01" and lastDayOfMonth could output "2014-6-30", and I've got an event with an eventDate of 18th June 2014, but nothing is being returned.


texts: Returning an array to Twig from a plugin

texts:
I'am writing a plugin that has to return an array of data, however Twig does not seem to accept it if I return a PHP array.  I don't want to use an explode in Twig to make it into an array.

I have seen in other plugins i can just call a function from twig like this.

{% set result = craft.winkelwagen.printWinkelWagen(currentUser.id) %}

{% for output in result %}
    {{ output }}
{% endfor %}

However, I get an array to string conversion error.  Does anyone know the correct way to do this?

Thanks in advance.


texts: How do I make a custom HTML Email template that will be used by the system?

texts:
Right now, everything sends in plain text.
On the Control Panel, if you go to Settings -> Email, there is a field for "HTML Email Template" that says "The template Craft CMS will use for HTML Emails".
But how do I know what fields to place in the template and what email is being sent out by the system?


texts: Fetch Craft Commerce purchasable element type

texts:
How should I retrieve a purchasable element criteria in Craft Commerce ?

To get entries, I just do

craft()->elements->getCriteria(ElementType::Entry);

I have tried the following without any success to get purchasables

craft()->elements->getCriteria(ElementType::Purchasable);
craft()->elements->getCriteria(ElementType::Purchasables);
craft()->elements->getCriteria(ElementType::Product);


texts: Craft Commerce: Geo Location, and option select dropdown to switch between currencies

texts:
I would like the user to be able to switch between currencies (and tax), but I haven't figured out how to pull the currencies defined in Craft Commerce into a for loop. (I am pretty new to this platform)

I need this to be changeable on the front end via both a drop down menu in the header and automatic Geo locating.

Any suggestions greatly appreciated :)


texts: Is it possible to have category listing page of entries if the category is defined within a matrix block inside said entries?

texts:
I think I have been staring at this problems too long and I need a kick in the right direction...

Here is what I have (the content modeling is a tad wonky but this is what we're dealing with):

Clients Channel

Work Samples Matrix Field (1 matrix block inside the matrix field)

Category matrix block field pulling from work categories
Assets matrix block field to upload images
Table matrix block field to enter youtube ID's

This is what I need to do:

When a category is selected by a user I take the user to a category listing page that contains all clients (from the Clients channel) with work samples within that category (categories within the matrix block from each client in the client channel).

For example: All clients with "website" samples should be displayed on a page at http://domain.tld/category/website

What is the most efficient way to pull this off in Craft/twig?

Reading the Craft docs is getting me about 1/2 there but something in the relationships docs isn't clicking yet.


texts: Outputting SVG from an asset field inside a matrix field with svg()

texts:
I've set up an asset field inside a matrix field where a user can upload SVG icons, but I'm having trouble outputting them using the svg() function.
{# Correctly shows the path #}
{{ callout.icon[0].url }}

{# Correctly displays the SVG within an image tag #}
<img src = "{{ callout.icon[0].url }}" alt=""  />

{# No output #}
{{ svg(callout.icon[0].url) }}
{{ svg(callout.icon) }}

Can anyone see what I'm doing wrong with the svg() function? Other than being inside a matrix field, what I'm doing doesn't seem to differ from the example in the documentation. I'm trying to avoid using any plugins if at all possible.


texts: How can I sort entries by a custom field in the CP, Craft 3?

texts:
I have an events section with a custom field of eventDate and it would be very helpful to editors to have them listed in event date order.
In Craft 2 I used the plugin CP Sortable Custom Columns by Mikkel Rummelhoff but he hasn't ported it to Craft 3 and may not, he says.

I would have thought this option would be useful to many people, so has anyone got any suggestions as to how to achieve it, I'm not a plugin developer myself.


texts:
I have included the navigation using Bootstrap 3 navbar. It is put together using Craft entries. I need the 'What we do' dropdown to be triggered when pressing the text or caret arrow but at the minute they are displaying as two different menu li as shown.

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

            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#collapse-ptm" aria-expanded="false">
                Toggle navigation

            </button>

            {% nav entry in entries %}

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

                            {% children %}

                        {% endifchildren %}

            {% endnav %}


texts: How do you find more documentation about queries, services, plugins, etc?

texts: So I've been having so much trouble finding adequate examples of how to do things when writing a plugin. How do you find more?  (see below for my own answer)


texts: How do I make my variable available inside an assets loop?

texts:
I have an entries field called 'customerLogoBarUrl'. It contains one entry. So I can do this:

{% for item in entry.customerLogoBarUrl.limit(1) %}
  {% set theUrl = item.url %}
{% endfor %}

But then I need to output that variable inside an assets loop:

{% for item in entry.customerLogoBar %}
  {% for asset in item.logo %}

  {% endfor %}
{% endfor %}

This yields theUrl doesn't exist.


texts: Twig_Error_Runtime on Local Dev Environment

texts:
Trying to set up craft on local environment and getting the following error once running mysql. Any clue what usually causes twig_error_runtime?

Twig_Error_Runtime

Method "bust" for object "Craft\CraftVariable" does not exist in "_layout" at line 66 (/Users/username/Sites/site.com/craft/app/vendor/twig/twig/lib/Twig/Template.php:485)

#0 /Users/username/Sites/site.com/craft/app/etc/templating/BaseTemplate.php(41): Twig_Template->getAttribute(Object(Craft\CraftVariable), 'bust', Array, 'any', false, false)
#1 /Users/username/Sites/site.com/craft/storage/runtime/compiled_templates/f7/b1/be6fe94a8e6c7ce48ecb00086d0a2ebde7cc24cc43eec4a6ba82fa4a24c9.php(128): Craft\BaseTemplate->getAttribute(Object(Craft\CraftVariable), 'bust', Array)
#2 /Users/username/Sites/site.com/craft/app/vendor/twig/twig/lib/Twig/Template.php(313): __TwigTemplate_f7b1be6fe94a8e6c7ce48ecb00086d0a2ebde7cc24cc43eec4a6ba82fa4a24c9->doDisplay(Array, Array)
#3 /Users/username/Sites/site.com/craft/app/vendor/twig/twig/lib/Twig/Template.php(287): Twig_Template->displayWithErrorHandling(Array, Array)
#4 /Users/username/Sites/site.com/craft/storage/runtime/compiled_templates/44/d5/7fc586931d2e13dfcd02f8209765153f695b63c7cf7dd78afa05d76029c4.php(27): Twig_Template->display(Array, Array)
#5 /Users/username/Sites/site.com/craft/app/vendor/twig/twig/lib/Twig/Template.php(313): __TwigTemplate_44d57fc586931d2e13dfcd02f8209765153f695b63c7cf7dd78afa05d76029c4->doDisplay(Array, Array)
#6 /Users/username/Sites/site.com/craft/app/vendor/twig/twig/lib/Twig/Template.php(287): Twig_Template->displayWithErrorHandling(Array, Array)
#7 /Users/username/Sites/site.com/craft/app/vendor/twig/twig/lib/Twig/Template.php(298): Twig_Template->display(Array)
#8 /Users/username/Sites/site.com/craft/app/vendor/twig/twig/lib/Twig/Environment.php(293): Twig_Template->render(Array)
#9 /Users/username/Sites/site.com/craft/app/services/TemplatesService.php(223): Twig_Environment->render('404', Array)
#10 /Users/username/Sites/site.com/craft/app/controllers/BaseController.php(74): Craft\TemplatesService->render('404', Array)
#11 /Users/username/Sites/site.com/craft/app/controllers/TemplatesController.php(201): Craft\BaseController->renderTemplate('404', Array)
#12 /Users/username/Sites/site.com/craft/app/framework/web/actions/CInlineAction.php(49): Craft\TemplatesController->actionRenderError()
#13 /Users/username/Sites/site.com/craft/app/framework/web/CController.php(308): CInlineAction->runWithParams(Array)
#14 /Users/username/Sites/site.com/craft/app/framework/web/CController.php(286): CController->runAction(Object(CInlineAction))
#15 /Users/username/Sites/site.com/craft/app/framework/web/CController.php(265): CController->runActionWithFilters(Object(CInlineAction), Array)
#16 /Users/username/Sites/site.com/craft/app/framework/web/CWebApplication.php(282): CController->run('renderError')
#17 /Users/username/Sites/site.com/craft/app/framework/base/CErrorHandler.php(368): CWebApplication->runController('templates/rende...')
#18 /Users/username/Sites/site.com/craft/app/framework/base/CErrorHandler.php(351): CErrorHandler->renderError()
#19 /Users/username/Sites/site.com/craft/app/framework/base/CErrorHandler.php(218): CErrorHandler->renderException()
#20 /Users/username/Sites/site.com/craft/app/etc/errors/ErrorHandler.php(128): CErrorHandler->handleException(Object(Craft\HttpException))
#21 /Users/username/Sites/site.com/craft/app/framework/base/CErrorHandler.php(131): Craft\ErrorHandler->handleException(Object(Craft\HttpException))
#22 /Users/username/Sites/site.com/craft/app/framework/base/CApplication.php(740): CErrorHandler->handle(Object(CExceptionEvent))
#23 [internal function]: CApplication->handleException(Object(Craft\HttpException))
#24 {main}


texts:
I'm having that dreaded GROUP_BY issue on a website. I suspect the server auto-updated itself or something as the site was fine before.

Now it's running on mySQL 5.7.10. The site wont load. I get the usual:

Internal Server Error CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #18 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'creighton_mma_craft.structureelements.root' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

I followed the instructions I have used before (adding the settings into my.cnf to return the group by settings to previous behavior).

It works for a few mins, then the whole of mySQL dies. I can no longer access it at all. I can only bring it back up by removing the line and restarting mySQL. I have tried several times and get the same result each time.

WHAT ON EARTH IS HAPPENING??


texts:
This is possibly more of a Twig thing, but if I have a hash…

{% set hash = {
    "key": "value"
} %}

How can I output the key name?

{% for value in hash %}
    {{ value }}
{% endfor %}


texts: Changing Username On Front End To Another Account Email

texts:
We have a front end form for a logged in user to change their Username (email). In our testing, it does not appear to check against and prevent selecting an email address that's already taken (like happens on a login form). However, our Create Account from - which is almost identical - works.

This Form (our create account form) works and catches duplicate emails and returns an error:

<form id="createForm" method="post" accept-charset="UTF-8">

    {{ getCsrfInput() }}
    <input type="hidden" name="action" value="users/saveUser">
    <input type="hidden" name="redirect" value="{{ siteUrl }}account/signup-sent">

        Email *
        <input id="signupEmail" name="email" placeholder="Email" value="" data-parsley-type="email">

        Confirm Email *
        <input id="confirmEmail" placeholder="Confirm Email" value="" data-parsley-type="email">

        Password *
        <input name="password" id="password" type="password" placeholder="Password" value="">

        Confirm Password *
        <input name="confirmPassword" id="confirmPassword" type="password" placeholder="Confirm Password" value="">

    <input type="hidden" name="fields[accountReceiveEmails]" value="">

        <input type="checkbox" name="fields[accountReceiveEmails][]" value="yes" id="emailOptin">
        Yes, I would also like to receive offers, discounts and news for Cadex products by email.

        <button>Create Account</button>

</form>

This is our form for users logged into their account. It does not return an error when a user tries changing their email to one that already exists in another account:

<form id="profileCredsForm" method="post" accept-charset="UTF-8">
    {{ getCsrfInput() }}
    <input type="hidden" name="action" value="users/saveUser">
    <input type="hidden" name="redirect" value="account/profile/saved">
    <input type="hidden" name="userId" value="{{ currentUser.id }}">

        Current Password *
        <input id="currentPassword" name="password" placeholder="Current Password" value="" data-parsley-required="true">

        New Password
        <input name="newPassword" id="newPassword" type="password" placeholder="New Password" value="">

        Confirm New Password
        <input name="confirmNewPassword" id="confirmNewPassword" type="password" placeholder="Confirm New Password" value="">

        New Email
        <input id="email" name="email" placeholder="New Email" value="">

        Confirm New Email
        <input id="confirmNewEmail" placeholder="Confirm New Email" value="">

    <button type="submit">Update</button>
</form>

We've tested this repeatedly, changing an email to one for another existing account and no error is returned, the form submits and the email is sent to confirm the new email address.

Also, as an aside, the confirm link in the follow up email seens to ignore the activateAccountSuccessPath set in our config. Is that expected behaviour?

Thanks.


texts: What is the typical owner:group for Craft files and folders?

texts:
Using cpanel, apache. All requirements are met for Craft. On a typical default set up I believe that the public_html is user:nobody. What should the ../craft folder owner and group be? With what permissions? What about sub folders?

I  getting 403 forbidden with 0744 and 0774 permissions.


texts:
I've read the docs but I can't seem to get this to work properly. I want to edit a single address on a separate page from where all addresses for a customer are listed. I have the link to the edit page, which looks like this:

Edit

Then on that edit-address template I have the following:

{% set addressId = craft.request.getParam('addressId') %}

<form method="post">
    {{ getCsrfInput() }}
    <input type="hidden" name="action" value="commerce/customerAddresses/save">
    <input type="hidden" name="redirect" value="account/address-book">

    {% if addressId %}
        <input type="hidden" name="address[id]" value="{{ addressId }}">
    {% endif %}

    <input type="text" name="address[firstName]" value="{{ address ? address[firstName] : '' }}">
    <input type="text" name="address[lastName]" value="{{ address ? address[lastName] : '' }}">
</form>

That leads to a "Variable 'address' does not exist" error. I understand why I get that error but I'm not sure how to get the value field to show the address info. Having a blank form field isn't going to cut it.


texts: SquareBit Charge Plugin: How to retrieve error messages from failed ajax call?

texts:
This is a continuation of How could I submit the Charge plugin using Ajax?

I'm using the Charge plugin to handle my Stripe payments. I'm having to use ajax to submit the charge form before submitting a second form that is on the page. The problem is when the ajax call fails, I can't seem to get the error messages that are causing the failed attempt.

I'm pretty sure part of the reason is because I get a 404 every time it fails, because 'url: charge/charge' path doesn't actually exist on my server. So, console.log(data) is basically useless to try and find how to access the error(s).

This is the code that I currently have:

this.ajaxReq = $.ajax({
  method: "post",
  url: 'charge/charge',
  data: $('#charge-form').serialize()
}) .done(function(data) {
    console.log('success');
}) .fail(function(data){
    console.log('failed');
    // Need to get error messages from Stripe/Charge?
});


texts: Show entries in the Control Panel as a grid, to reorder position

texts:
I am looking for a way to display entries in a (5er) grid
in the Craft backend (Control Panel) and show only the featured images.

I have a customer who has on her website a gallery, where 5 squares are on
one row. Right now there are around 50 entries, more to come.

All the squares are entries, which have detailed information
on a certain product behind it. The squares are pictures and the customer wants to be able to reorder them, to get the best (aesthetic) combination.

I was thinking of a structure because with this it is easy to order
the entries, but in the Control Panel they are shown as a list.

Is there a way to accomplish this?

I was thinking maybe the Neo plugin might be of help, but I could not try it.


texts: I'm having trouble to load an ttf and a woff file in Craft 3. I'm getting an error 500. The files exists and when trying to access it via the browser it shows: Twig Syntax Error – Twig_Error_Syntax Unexpected character "" for both of the files. Any suggestions ?


texts:
Using Element API I would like to remove the limit to how many entries are in the JSON output.

The default is 100 entries, with pagination. I would like 1 response with all entries.

Here is my current call:

return [
'endpoints' => [
    'fullmembers.json' => [
        'elementType' => 'User',
        'criteria' => ['group' => 'fullMembership'],
        'transformer' => function(UserModel $member) {
//....

Thanks in advance guys!


texts:
Trying to output navigation:

Home
About
Services

Sub 1
Sub 2
Sub 3

List item
Testimonials
Contact
Get Quote

I'd like to remove the link to the Services page, preferably to  and if accessed through url, redirect to homepage.

Here's how I'm currently outputting nav:

        {# get menu items #}
        {% set pageItems = craft.entries.section('services').level('<= 2') %}
        {# % set pageItems = craft.entries.level('<= 2') %# }

        {# Output the sub menu #}

Home

            {% set entry = craft.entries.slug('about').first %}

{{ entry.title }}

            {% nav page in pageItems %}

                    {% if page.navigationTitle %}{{ page.navigationTitle|nl2br }}{% else %}{{ page.title }}{% endif %}

                {% ifchildren %}

                        {% children %}

                {% endifchildren %}

            {% endnav %}

            {% set entry = craft.entries.slug('testimonials').first %}

{{ entry.title }}

            {% set entry = craft.entries.slug('contact').first %}

{{ entry.title }}

            {% set entry = craft.entries.slug('get-a-quote').first %}

{{ entry.title }}

Any help is much appreciated. Thanks in advance.


texts:
As an extension of this question
How to link to previous/next entries in a section?

If my page is set to automatically provide a entry var in my template.
And I can simply access a field like this

entry.title

Which means I don't need to do something like this

{% set entry = craft.entries.section('blog').first() %}

If I want to get the next entry and previous entry based on this entry's entry type. Is it possible?


texts:
I'm working on a Craft project that has 3 sites. The content for one section is pulled from an API using a console script which runs every 5 minutes.
This has been working fine but I've discovered a bug that the title's aren't being updated across all sites as they are translatable.
This is my current code.
$entry->title = $data->name;
$entry->setFieldValues([
    'body' => $data->text,
    'relatedArticles' => array_map(function($id){
        return [
            'relatedId' => $id,
        ];
    }, $data->related),
    'categories' => array_map(function($cat) {
        return (isset($this->categories[$cat])) ? (int) $this->categories[$cat] : false;
    }, $data->categories),
]);
$success = Craft::$app->elements->saveElement($entry);

All other fields are not translatable so they work fine, Is there a way to propagate the title across all sites or do I need to loop through all the sites to update the entry?


texts: Accessing Commerce ‘Product Fields’ in events hooks

texts:
I've added an Entries field called linkedCourseEntry to a Product (Product Type > Product Fields tab). In the Product itself I've assigned an entry.
I need to access linkedCourseEntry from one or more Events, but can’t work out how to do so.
For example when EVENT_POPULATE_LINE_ITEM is used:
Event::on(
    LineItems::class,
    LineItems::EVENT_POPULATE_LINE_ITEM,
    function(LineItemEvent $event) {

        $lineItem = $event->lineItem;
        $purchasable = $lineItem->getPurchasable();

        // Somehow access the 'linkedCourseEntry' data here... help!
    }
);

Can anyone point me in the right direction please?


texts: Smart Map Lat+Lng is present but no pin on map

texts:
My map isn't showing all of the markers that it should. I am querying a user group to return the locations as follows:

{% set locations = craft.users.group('fullMembership') %} {{ craft.smartMap.map(locations, options) }}

FYI There are around 400 users in this group and only a small amount of them have logged in and set their Map Pin.

Each user in this group has a profile page; Those user who have located their address  all show their map pin on their profile. However the members Directory index map is incomplete, some pins are missing.


texts: Rewrite locale urls on nginx, but not for registration links

texts: I'm using this Gist to rewrite the urls on a localized website running on nginx. It's working fine, except for the account activation links. They are localized as well, but they shouldn't. I'm sure there can be made an exception in the rewrite rule for all urls starting with /actions. But I don't know how. Can anybody help?


texts: How can I run the Control Panel from a separate domain?

texts:
Is it possible to separate the public site and the Control Panel on separate domains (i.e. www.domain.com and admin.domain.com)?

With baseCpUrl you're able to force the admin URL to admin.domain.com, but is it possible to also remove the redirect from www.domain.com/admin and completely remove all possible ways to access/redirect to the CP from www.domain.com?

(I guess setting cpTrigger to a random string would be one way, but then you also end up with the admin address similar to admin.domain.com/hjkads78ads5ads785ads68ads67)


texts: Import local image with FeedMe assumes wrong folderId

texts:
I am importing Entries from Google Spreadsheets and I have a column in my spreadsheet containing the filename of an image already existing in Craft.
The import itself works, but images are not found / not selected in the asset field.
In the logs I can see that the image query is wrong, it looks like that:
Search for existing asset with query {"siteId":1,"status":null,"folderId":1,"kind":null,"limit":"9","filename":"test-container-3.png","includeSubfolders":true}
The filename is correct, however the folderId is wrong, it should be 2.
I tried working with plain filenames like "test-container-3.png", I also tried prepending an alias pointing to the correct folder (absolute URL) like "@importImages/test-container-3.png". Made no difference.
How does FeedMe decide to use folderId 1 in its query? How can I change this?


texts: Using Sprout SEO, how do I use the seoDivider setting in templates?

texts: Sprout SEO has a setting in the admin screens to "Select the character that will be used between Title segments". I think it's called seoDivider, but I can't see how to use this in my templates, and can't see any reference to it in the documentation.


texts:
Why is this depreciated? Is there an example of the preferred method?

  Looping through element queries directly has been deprecated. Use the all() function to fetch the query results before looping over them.

Thanks.


texts:
This is an .htaccess question which I found the answer to but, I need to integrate it with the .htaccess that comes with Craft.

I need to add trailing slashes to the end of all URLs.

I know there is a General Config Setting for adding trailing slashes to URLs to "dynamically-generated URLs" but, in the case there are any hard coded urls with out the trailing slashes or if someone links to the site without trailing slashes it would be nice to set it and forget it via the htaccess.

For example:

http://mydomain.dev/news/news-entry

would 301 redirect to

http://mydomain.dev/news/news-entry/

This is what comes with Craft by 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:
I'm trying to upgrade an Craft site from 1.3 to 2.3 and have gotten into a broken state.

The update button failed, so I tried a manual update. This noted that I needed at least version 2.1, which I then downloaded and tried. It throws the following error and reverts:

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

When I revert back to 1.3 the admin screen is now blank.

The relevant versions/schema info:

Version: 1.3, Build: 2486, Schema: 1.3.15 (blank login)
Version: 2.1, Build: 2570, Schema: 2.1.2 (SQL error)
Version: 2.3, Craft Build: 2635, Schema: 2.3.4 (desired version)

The craft_info table shows that I'm running 1.3. The site is up, but I can't access the backend.

Any help greatly appreciated!


texts: Possible have matrix rows collapsed by default in the Control Panel?

texts:
Is it possible to have all Matrix rows in the Control Panel entry be in the collapsed state by default?

Thanks.
Lori


texts: Proper way to implement array of objects as Craft field

texts:
I'm using Craft CMS for the first time and have a question about the proper/best practice to store what would equate to an array of objects (or just a plain array) in Javascript or JSON.

Say I'd like to store a number of entries with the following shape :

{
    newspaper: 'New York Times',
    article: 'How to Write Web Apps Without Help From Stack Overflow',
    authors: [
        {
            name: 'John Doe',
            title: 'Staff Writer'
        },
        {
            name: 'Jane Smith',
            title: 'Editor'
        }
    ],
    categories: [ 'technology', 'web' ]
}

I understand that I store the first two properties as "Plain Text" fields, but I am confused on the proper way to store the authors and categories arrays as Fields. It looks like I would use a Matrix Field for this, but in the demo I'm referencing, they use Matrix fields in a slightly different way.

Just looking for validation that I should use matrix fields in this case, or some direction otherwise.


texts: Update 3.5.15.1 - Fixed a bug where the Updates utility wasn’t showing “Update” buttons

texts:
The update button is missing, and the fix is available, but impossible to initiate from the CP.

Before I embark on a manual update, I wondered if there was a URL that I could use to trigger the update? (What URL does the button normally run?|)
Cheers
Matt


texts: 'onBeforePerformAction' alternative for craft 2.4.0?

texts: Is there an alternate event for onBeforePerformAction? I want to handle an onDeleteEntry, but apparently that doesn't work on a bulk delete (deleting from the check boxes).


texts: Is there anything that will prevent an entry from being worked on by 2 editors at the same time?


texts: Can I output the Placeholder Text of a plain text matrix block?

texts:
Is there a way to output the Placeholder Text of a plaintext field if there's no specific value entered to the Entry?

(Am I missing something — should it happen automatically if there's no specific value entered?)

The docs say: "The text that will be shown if the field does't have a value" — does shown just mean in the form on the Entry form in the admin, or also on the front-end as a value of block.FIELDNAME ?


texts: Cycle outputs plain text, should be html

texts:
Is this normal behavior?

{% for entry in entries %}
{{ cycle(['

', '2', '3', '4'], loop.index0) }}
{% endfor %}

Results in:

&lt;div&gt;&lt;/div&gt;

2

3

4

is there a way to force the output as it is?


texts: Commerce: Payment does not get completed

texts:
I am having trouble getting a payment completed (SaferPay, offsite gateway). After coming back from the payment provider I get redirected to the unchanged payment page again with the following error message: Payment Error: , the error code (?) is 0.

I have found this in the logs:

$_GET=array (
'commerceTransactionId' => '87'
'commerceTransactionHash' => 'f4dcff157345d68b54934791fe7b0522'
)
$_POST=array (
'DATA' => '<IDP MSGTYPE="PayConfirm" TOKEN="(unused)" VTVERIFY="(obsolete)" KEYID="1-0" ID="Oh7p4zbhSnWOUAzjGE5bAS4rSnAb" ACCOUNTID="401860-17795278" PROVIDERID="1395" PROVIDERNAME="PayPal Saferpay Test" PAYMENTMETHOD="16" ORDERID="2435" AMOUNT="3071" CURRENCY="EUR" IP="84.141.245.197" IPCOUNTRY="DE" />'
'SIGNATURE' => '3eec17d64cd2f4e9e57402e3efb1d91d79af35cf462f1f971ad2aa79ceda5e6814d7fb4d82cf2bfe044c791cbc38ea3007598d4d0ac6ba16db08e1abb2dc0b61'
)
$_SESSION=array (
'1c4d338641dbdf309e6ed655daae834eYii.CWebUser.flash.error' => 'Payment Error: '
'1c4d338641dbdf309e6ed655daae834eYii.CWebUser.flashcounters' =>
array (
'error' => 0
)
)

The QUERY_STRING cuts after the transaction hash:

'commerceTransactionId=87&commerceTransactionHash=f4dcff157345d68b54934791fe7b0522'

Strangeley enough it is working locally, where the log says the following:

$_GET=array (
'commerceTransactionId' => '56'
'commerceTransactionHash' => '2db11e4c56020b3adad7565478f2bc56'
'DATA' => '<IDP MSGTYPE="PayConfirm" TOKEN="(unused)" VTVERIFY="(obsolete)" KEYID="1-0" ID="GCzE6MbphEYrSAUYhlA9bnvY6Y7b" ACCOUNTID="401860-17795278" PROVIDERID="1395" PROVIDERNAME="PayPal Saferpay Test" PAYMENTMETHOD="16" ORDERID="2435" AMOUNT="20430" CURRENCY="EUR" IP="84.141.245.197" IPCOUNTRY="DE" />'
'SIGNATURE' => '0378583461a09e40efe22a39cc5c7ca4c3bbe4e7f89c041154b00bcd1b65604309d219bad395ee2fefabc8726e9afd2364b769baa08ac927317698a9ab795e8b'
)

Remotely it lives on a sub domain. What could be the problem?


texts: How can I filter with facets in algolia with nested structures?

texts:
I have a site that currently uses a structure where we have a parent entry and children under it. On the parent page we have entries that have been created with matrix blocks. The structure is as follows below in the screenshot:

On each parent page we want the ability to filter by the child entries under it. So far we have got it working well with a little fiddling but the only issue is that its showing entries for other nested children not related to the parent entry.

So for instance the result we want is:

Bedroom furniture(parent page)
 - Beds
 - Bedroom storage
 - etc
 - etc

But what we are seeing is:

Bedroom furniture(parent page)
 - Bed
 - Armchairs

The filters on the page should only be the child entries that belong under that parent.

Now here is the code we have got in the algolia plugin when indexing the commerce product:

[
            'indexName' => 'allProducts',
            'elementType' => 'Commerce_Product',
            'transformer' => function(Commerce_ProductModel $product) {

                $typesCriteria = craft()->elements->getCriteria(ElementType::Entry, [
                    'section' => 'products',
                    'relatedTo' => [
                        'targetElement' => $product,
                        'field' => 'productBlock.product',
                    ]
                ]);

                $types = array_map(function($el) {
                  return [
                    'title' => $el->title,
                    'id' => $el->id,
                    'level' => $el->level,
                  ];
                }, $typesCriteria->find());
                $typesByLevel = [];

                foreach ($types as $type) {
                  $typesByLevel['types.level' . $type['level']][] = $type;
                }

                $variantAmount = count($variants);

                return array_merge([
                    'title' => $title,
                    'id' => $product->id,
                    'frontImage' => $fm,
                    'type' => $product->type->name,
                    'types' => $types,
                    'designer' => $designer,
                    'brand' => $brand,
                    'price' => $totalPrice,
                    'productPrice' => $product->defaultVariant->price,
                    'material' => $product->variantMaterials[0]->title,
                    'url' => $url,
                    'variants' => $variantAmount,
                    'isInWishlist' => craft()->like->isLike($product->id),
                    'quickViewJson' => $mergedProductData,
                ], $typesByLevel);
            }
        ],

This code indexes the product and creates the levels in Algolia and we have this result in algolia below:

This gets the level but we need the level that is associated with the parent page only not from all other areas of the site.

On the parent page we then get the parent structure Id and do disjunctive faceting with js on that page the get the filters that belong to that page like so:

if( $('#product-search-config').length ){
 // type gets the entry.id
        const type = $('#product-search-config').data('type');

            searchProducts.addWidget({
              init: function(data) {
                console.log(data)
              },
              getConfiguration: function() {
                return {
                  disjunctiveFacets: ['types'],
                  disjunctiveFacetsRefinements: {
                    'types.level1.id': [type],
                  }
                };
              }
            });

    };

This needs to only find the filter relating to that parent as you see in the menu above.

Can this be done?

Thanks


texts: Is there a hook or event we can use to intercept a search request?

texts:
We are looking to log searches so we can report on them. Are there any hooks or events we can use to get this data?

If not, then how can a custom plugin log the initial search parameters, call the underlying core Craft search, and finally log the results?


texts: Set a user's group on a registration form using a hidden field

texts:
I am looking to have two separate front end registration forms for adding users to either the partners user group or the members user group. These have been created in the back end with the following user group handles: members and partners.

I have added the following hidden field to the partners registration:

<input type="hidden" name="userGroup" value="partners">

and the following hidden field to the members registration:

<input type="hidden" name="userGroup" value="members">

I have then created a plugin with the following code:

public function init() {

   parent::init();

     craft()->on('users.saveUser', function(Event $event) {

      // only fire if new user
      if ($event->params['isNewUser']) {

          // retrieve the userModel from the event
          $user = $event->params['user'];

          // check for presence of 'type' POST field
          $userGroup = craft()->request->getPost('userGroup');

          $userGroups = array();

          if ($userGroup == 'partners') {
              $userGroups[] = craft()->userGroups->getGroupByHandle('partners')->id;
          }

          if ($userGroup == 'members') {
              $userGroups[] = craft()->userGroups->getGroupByHandle('members')->id;
          }

          if (count($userGroups))
          {
              // assign the user to the groups
              craft()->userGroups->assignUserToGroups($user->id, $userGroups);
          }
      }
  });
}

This code is not adding the user to either of the groups but the user is created with no problem.


texts: Create custom field type with dynamic data

texts:
I would like to create a custom dropdown field with dynamic data

Ideally I would get data from one of my services, and then inject it dynamically in the HTML select field

I read the plugin documentation on custom field types, but couldn't find anything about this


texts: Is it possible to create category for only one site in a multisite setup?

texts:
If not, how would you best approach this issue?

For us, different sites have different categories, and also, not always the same number of categories.

At the moment, when we create a category, it gets created for all sites and only thing we can do is rename it on different sites.

If we delete a category from one site, it gets deleted on all sites.

Only solution that I can think of at the moment, is to have all categories created on all sites. In backend, all categories would be visible and available on all sites. On frontend we would just display only those categories which have entries in them, per site.

But we are talking about a lot of categories here, it would be messy.

Any better solutions?

Thanks!


texts: How can I get the same element ids that the DeleteStaleTemplateCaches Task ends up with before the element has saved?

texts:
I recently made a plugin that tries to keep the existing cache warm. It does this by listening to the elements.onBeforeSaveElement event, grabbing the id of that element and finding all the paths in the craft_templatecaches table then calls them with Guzzle.

The part I'm struggling with is the element id - when the event fires I just get the id of the element that first fired, in most cases the Entry. How do I ensure I get all of the correct cacheIds from the craft_templatecacheelements table? I only have the one element id, is there a way of ensuring I have all of the involved element ids?

I tried getting element ids from craft_relations by sourceId but still don't seem to be able to replicate the same kind of behaviour that the native cache clearing does. When I save an entry I get a bunch of element ids in the DeleteStaleTemplateCaches Task settings but can't find a way to get that same set of ids before the element saves.

I feel like I'm missing something fundamental ...


texts:
PayPal Express is one of the payment gateways included in Craft Commerce but I can’t find an example of how to set this up. Is it something that would require a custom plugin for posting secure data to PayPal or is there an easier way to do this out of the box?

I currently have a payment form as per the Commerce example templates with everything working through the Dummy gateway but now looking to replace that form with a simple PayPal Express checkout button, returning to the order page if successful. Any examples or pointers appreciated.


texts:
The green bubble (status is enabled) next to the category items in the category overview suggests that you can disabled/enable the category.

Is that possible? And if so, how?


texts:
I'm trying to find a way of using php's print_r to output the entries that were pulled from the entries in the database. I'm pretty much brand new to Craft cms coming from Laravel, so a common thing I've done in the past with querying the database is seeing what I got back by outputting my array using either print_r or laravel's dd($array) during testing for a sanity check. I can't seem to find an easy way of doing this in Craft. This is what I've tried so far:

{% set listItems = craft.entries().section('todoList').all() %}

{{ listItems }}

The {{ listItems }} of course gives the array to string conversion error when rendering the page, so I tried doing:

{{ listItems | join }}

but that only outputs the title of the entry. Thank you in advance for any help!


texts: Can't get past the install on local MAMP Pro install... "Oops screen"

texts:
Can't seem to get past the install screen for some reason or other... I fill in the relevant information, it starts to install then I get the OOPS screen... I looked in the log and I'm seeing the following ...

[Mon May 11 13:25:08 2015] [error] [client ::1] FastCGI: comm with server "/Applications/MAMP/fcgi-bin/php5.3.29.fcgi" aborted: idle timeout (30 sec), referer: http://travelexperience/admin/install
[Mon May 11 13:25:08 2015] [error] [client ::1] FastCGI: incomplete headers (0 bytes) received from server "/Applications/MAMP/fcgi-bin/php5.3.29.fcgi", referer: http://travelexperience/admin/install

But I have no idea what's up...

UPDATE

Okay I'm getting the following error in the craft log...

2015/05/11 12:48:19 [warning] [application] Skipping record /sites/travelexperience/craft/app/records/BaseRecord.php because it’s abstract or an interface.


texts:
After going through the documentation I believe that this is the correct code to output the url for the asset field but its not working and I have no idea why. Please help!

{% nav program in craft.entries.section('program').level(1) %}
  {% set active = entry is defined and program.isAncestorOf(entry) %}

      {% if program.featureImage|length %}

      {% endif %}

{{ program.title }}

{{ program.description }}

{% endnav %}


texts:
Currently in the admin panel, all entries per channel appear in a single list. Is it at all possible (at least, by default) to filter/search by type?

For instance a dropdown of all entry types, or just 'type: article' in the search form.

I know it is quite easy to do from the front-end, would it require a plugin to add the functionality to the back-end?


texts: How can I pre-select a product variant based on user profile?

texts:
I have a product variant that a user can choose from. It looks like this:

<select name="purchasableId" class="form-control">
    {% for purchasable in product.variants %}
        <option {% if purchasable.stock <= 0 and purchasable.unlimitedStock == false %}disabled {% endif %} value="{{ purchasable.purchasableId }}"
            {% if currentUser is defined and purchasable.myCustomField in currentUser.userField %}selected{% endif %}>{{ purchasable.myCustomField.label }} &ndash; {{ purchasable.price|currency(cart.currency) }}</option>
   {% endfor %}
</select>

Where I'm stuck is this:

purchasable.myCustomField

Should (and does) equal this:

{{ currentUser.userField }}

I know it's a syntax problem... just not sure where I'm off.

EDIT

To test, this is what the data looks like:

purchasable.myCustomField  // this is a drop down value is "blue"
currentUser.userField      // this is a checkbox that has the value "blue" in it


texts: Why is category.getUrl() returning incorrect subdomain?

texts:
Forgive me if this is a server configuration or other issue unrelated to craft, but perhaps someone has some insight on what might be causing this, and how to fix it.

When using a simple category.getUrl() for subnav, I am getting odd results where the subdomain is not 'www', but instead something else, like 'ddd' or 'w2w'. This is only happening in the production environment. And results vary depending on which page the nav is included on. Very strange.

{% set categories = craft.categories.group(group).all() %}
{% for category in categories %}
    {{ category.title }}
{% endfor %}

Any ideas are much appreciated? Thank you.


texts: Permission for "Send an activation email now?" Option

texts:
So it looks like site admins have the ability to choose whether or not to send a new user an Activation Email through the "Send an activation email now?" checkbox option on the Register a new user page on the Craft back-end.

I want to give this permission to a set of "Managers" user/permission group, but I cannot find the option that allows this permission to be usable.

The "Manager" user group currently has all "User" permissions checked.  Is the only way to fix this to make them an admin?

Was hoping to be a bit more granular. Any insights would be appreciated, thank you in advance.


texts:
in my Sections (Single, Channel and Structure) I am using one matrix field containing typical content elements, Text (One Column), Text (Two Columns), Image, Text-Slider, Image-Slider and so on...

My problem is the Text-Slider with Richtext and links in it. Unfortunately Matrix field doesn't offer any Repeater or Nested Matrix functionality so I don't know how to build the structure for this element.

My Image-Slider is a no brainer , I take an asset field and with every image there is another Richtext field I can use.

The Table field has no Richtext field in it...
There are a lot of small Text-Sliders all over the website.
Any Ideas? Thanks much!


texts: Freeform Plugin: Success Page and Submission ID - Template not Found

texts:
I am getting the following error when redirecting the form success message to a page. I am trying to pass in the submission ID...

HTTP 404 – Not Found – yii\web\NotFoundHttpException
Template not found: contact/success/5015

This is the Return URL

returnUrl: "{{ siteUrl }}contact/success/{{ submission.id }}",

I have set up a 'single' entry for the success page - do I need to somehow tie this in with the submission ID?


texts: How can I get blog categories and blog entry urls to play nice together?

texts:
I'm building a simple blog that has the ability to publish entries:

Within a set of categories.
With no category set.

The URL format of a blog entry is /blog/YYYY/MM/DD/{slug}

Everything so far works, my section blog works and the templates/blog/index.html template loads correctly as does the templates/blog/_entry.html for blog entries.

Categories however don't seem to work as they seem to be conflicting with the entry URLs… I have a list of all blog categories at the top of the blog section with each section, eg: 'Recipes', linking to /blog/recipes (using the {category.url} var).

In Craft I have set the Blog categories settings set to:

Category URL Format: blog/{slug}
Nested Categories: not set/empty
Category Template: _category.html (I have also tried _category without the .html extension as the value with the same result)

The issue is that when I navigate to blog/recipes I get a 404 instead of the system serving the templates/blog/_category.html template I have set up.

Note: There are no custom routes setup for this site.

I'm not sure what I am doing wrong, single entries serve up fine, but I can't seem to get to the category listing of a blog's category.

Any help would be much appreciated.


texts: Combine entries query, but filter one section by field

texts:
I would like to combine two sections: blog and recipes.

I need to filter the blog section by a field. I have an entries field on on Blog and I want to query those entries where the field is empty.

{% set posts = craft.entries({
   section: ['blog', 'recipes'],
   limit: 12,
   search:'-location:*'
}) %}

This will not return recipes. I think because the location field isn't present on recipes - only blog.


texts: Can Matrix fields be added/shown on the entries listing of the control panel?

texts: Is it possible to add a related matrix field and show the first entry in that field on the http://domain.com/admin/entries section of the control panel?


texts: Collecting total charge value where custom field is X

texts:
I'm using Charge to collect donations toward individual projects for a charity.

On the frontend, I want to display how much has been raised for an individual project.

To get a list of charges for a project, I'm doing

{% set charges = craft.charge.charges({
      search : { query : 'projectDonateTo:' ~ entry.id }}
   )%}

{% for charge in charges %}
    {{ charge.amount }}
{% endfor %}

which obviously loops through all charges but I can't fathom how to total these together.

Any ideas?


texts:
This is primarily directed to P&T, but I'm working on a project which is heavily using/extending Craft Assets.  I noticed in the Asset Service there is a reference to breaking changes in Craft 3.0.  I don't want to get too far down the road with this to realize it will have to be refactored.

I'm sure you're not willing to give a 3.0 release date, but any indication to what these change will look like or when they will happen is helpful.


texts:
I have created a field for the homepage called icon_font.  I now want to access that field in my template.  What is the best way to do that?  Do I have to use a for loop (even though there is only one homepage)?  Any help is appreciated.

Thanks,

Moshe

EDIT:
Note, the template in question is NOT my homepage template, but rather a different template which relates to a different section.


texts:
The very useful Redactor Styles plugin has stopped working for me. I have the little wand in the toolbar, and appropriately styled entries in the drop down, but clicking on them does nothing.

Styles JSON Object:

[
  {
    "btnName": "Button Link",
    "className": "redactor_format_button",
    "spanClass": "button_link"
  },
  {
    "btnName": "air",
    "className": "redactor_format_air",
    "spanClass": "air"
  },
  {
    "btnName": "water",
    "className": "redactor_format_water",
    "spanClass": "water"
  }
]

Redactor config file:

{
  /* docs say 'json', but really we are allowed basic javascript object */
  /* allowedTags: need inline for RedactorStyles */
  allowedTags: ['a', 'blockquote', 'br', 'div', 'dl', 'dt', 'dd', 'em', 'h2', 'h3', 'hr', 'i', 'iframe', 'img', 'inline', 'li', 'ol', 'option', 'p', 'select', 'span', 'strong', 'ul', 'video'],
  formattingTags: ['p', 'blockquote', 'h2', 'h3'],
  buttons: ['html','|','formatting','|','bold','italic','|','unorderedlist','orderedlist','|','link','image','video', '|', 'horizontalrule'],
  plugins: ['fullscreen', 'styles', 'pagebreak', 'clips'],
  stylesJson: RedactorStyles.stylesJson
}

The field is using that configuration, and neither Clean up HTML? nor Purify HTML? is checked. This used to work, and I don't think I've changed anything (famous last words...)


texts: Creating a modal popup using CraftCMS and Twig

texts:
I've been looking everywhere, I'm trying to create a modal using a global but I can't seem to figure out where to start.
JavaScript:
$popUp = new Garnish.Modal($('#popUpModal('),
$popUp.show(),
$popUp.hide()

    (document).ready(function(){
       setTimeout(function(){
         popUp();
      },3000);
  })
);

Twig:
{% set popUpModal = popUpModal.popUpModalContent %}
{% if popUpModal %}

        {{ popUpModal }}

{% endif %}


texts: Can image transforms decrease performance?

texts: If I have a site that will eventually have thousands of product images on it, would using image transforms slow things down?


texts:
I'm trying to using craft caching to cache a page without query string vars.

This tag

{% cache using key craft.request.path  %}

{% endcache %}

throws an error

Unexpected token "name" of value "using" ("end of statement block" expected)

This example is right from the Craft Docs, https://craftcms.com/docs/templating/cache

If I remove the "using ..." everything works fine.

Any ideas?


texts: Performance basics? BlogPost+Comments vs. One ever-expanding Matrix Field?

texts:
New to Craft, and unsure how it works under the hood.  In terms of overall performance, I'm curious to know which of the following scenarios is the most performant approach in terms of DB queries and server strain.

SETUP: I'm building a sort of blog/forum hybrid with user-generated posts.  But in this case, comments are not an afterthought tacked onto the main post (like most blogs).  Instead, comments are a central part of the overall content.  Sort of like StackExchange or Reddit.

SCALABILITY: Let's prepare for a site that grows to a million+ Posts... and millions more Comments.

IDEA 1: Build a traditional BlogPost/Comment system where each new Post requires users to upload a single image and a rich-text description.  Then Comments are tacked on as usual.

IDEA 2: Build each BlogPost with a Matrix Row featuring only 2 fields [ image | rich-text ], and instead of tacking on traditional comments, simply append additional rows to the post's Matrix Field via front-end editor form.

While Idea 1 is well-tested and proven, I think Idea 2 might save a lot of computational power on page delivery.

If I understand correctly, Idea 1 must make at least 2 (and probably several) loops through the database, first the Blog and then the Comments...

But Idea 2 needs only one loop through the Post/Matrix to grab everything. And then even little things would become easier, (e.g. Comment count = how many rows in the Matrix.  AND Image count = how many images in the entire Matrix field.  AND most recently updated post = most recent Post/Matrix update, not most recent Comment).... all without doing additional queries on a Comments table.

QUESTION 1: Is my understanding flawed, or does Idea 2 make more sense in terms of fewer queries and server load?

QUESTION 2: With Craft, is it possible for a Matrix field to be appended row by row from a front-end form?


texts: I'd like to know if it is possible to have Craft unzip a .zip file that authenticated users have uploaded through the CP. The idea is that the users will prepare several static html, javascript, css and image files -- rather than having them upload them all individually, I'd like to let them zip them, and upload a single file instead, and then use Craft to unzip them in place them in an appropriate spot. I've got the upload figured out - I'm just not sure how to move ahead with the unzip, or if it's even possible.


texts:
I have the following code for my news page. The links show up but I'm seeing all the entries on every page. I'm not sure if this is related to my featured entry at the top.

{% extends "_layout" %}
{% set title = "News" %}
{% paginate craft.entries.section('news').limit(5) as pageInfo, pageEntries %}
{% block content %}

Company News

{% for featuredEntry in craft.entries.section('news').featured('1') %}

                {% for image in featuredEntry.featuredImage %}

                {% endfor %}

{{ featuredEntry.title }}

                {{ featuredEntry.body.getPage(1) }}
                Continue reading

{% endfor %}
{% for regularEntries in craft.entries.section('news').featured('not 1') %}

{{ regularEntries.title }}

            {{ regularEntries.body|hacksaw(words='25', allow='
') }}
            Continue reading

{% endfor %}

{% if pageInfo.prevUrl %}Previous Page{% endif %}
{% if pageInfo.nextUrl %}Next Page{% endif %}

{% endblock %}


texts: Better way to group by category and include full category entry

texts:
The basic idea is that I want to group my entries by category, but I want more than just the category title—I need the entire category entry. My previous post alludes to this, but I've since discovered the query I was doing there was returning all related entries regardless of their existance in the block.result entry.

I'm currently doing this—which is exactly what I want, but it doesn't see very efficient... Is there a better way?

{% set results = block.result %}
{% for category, catEntries in results | group('infographicSection.first().title') %}
    {% set fullCat = craft.categories.title(category).first() %}

{{fullCat.title}}

{{fullCat.body}}

    {% for entry in catEntries %}

{{entry.title}}

    {% endfor %}

{% endfor %}


texts: Passing Querystring Variable to PHP Code in Plugin

texts:
I'm pretty new to Craft and PHP, and I am needing to design a page in Craft (powered by a plugin) which will pass a variable in a querystring (or equivalent in Craft) to the PHP code in the plugin.
In my case, it would be a username (e.g. jsmith) to pass to the plugin PHP code, which would query an XML file for a node having 'jsmith' as the username value.
My first question is - in Craft, can I use a querystring like:
?username=jsmith

or would I need to use something more Craft-specific?

My second question is - can Craft (Twig template) pass to the PHP plugin by including the PHP file (service)?

Thanks for your help in this


texts: Select dropdown linking to Matrix blocks

texts:
I need a little bit of assitance. I have a matrix block that outputs floorplans diagrams and it's specification per floor in a property (see screenshot attached below.

I've got the matrix fields outputting correctly on the page, but I need to get it to only output a single floor at a time, and not all floors, and then let the user click on a select dropdown to change to the floor level that they want to view.

Here's the current markup:

Hopefully someone can help to get it working?

<form class="form" action="{{ entry.url }}" method="get">

      <select id="development1" class="form-control" name="floor" onchange="this.form.submit()">
        <option value="">Select Floor</option>
        {% for block in entry.floorplans %}
        <option value="{{ block.floorplanlevel }}">{{ block.floorplanlevel.label }}</option>
        {% endfor %}
      </select>

</form>

{# Start Matrix Block #}
{% for block in entry.floorplans %} {# Main Field Handle #}
{% switch block.type %}

{% case "floorplan" %} {# Matrix Block Type Handle #}
......


texts:
I would like to manually crop the image transforms for an uploaded image.

I know there are crop plugins for Craft (image-resizer, AviaryImageEditor), but these plugins crop the original image and not the image transforms..

I'm looking for something very similar to the manual crop module in Drupal.

So you can upload one image, afterwards you manually crop the different image styles / image transforms..

Any suggestions?


texts:
I did a straight lift of the Craft3 Search Form example.

It "works."  There are no errors.  But, it is not showing all results. I can type F and it works. I type F- and it works.  I type F-15 and it does NOT work, even though the F and F- searches included F-15 in the results. Any search with F-XX, H-XX, MQ-XX (where XX is a number such as 4, 9, 15,16 or 22)  fails to display the appropriate results.  It gets stranger.  C-XX, A-XX, RC-XX, and HC-XX WORK!!! And, these are the title fields. So, I can't figure out what is throwing things off.

My search input is ...

<form action="{{ url('search/results') }}">

<input type="search" name="q" placeholder="Search">

<button type="submit" class="button">Go</button>

My Search Results are a straight lift from the Craft3 example.


texts: Use variable passed via include to set value of paramenter

texts:
I have an include setup for Navigation which works fine if I hard code in the level of the structure I want to use. However I need this to be set differently if the nav appears in the head or the footer.

head:

      {% include "_includes/nav"
        with {
          'listType' : 'list-inline pull-right',
          'navLevel'  : '2'
        }
      %}

footer:

      {% include "_includes/nav"
        with {
          'listType' : 'list-unstyled',
          'navLevel'  : '1'
        }
      %}

The include looks like this where I want the .level('<=2') to have the value passed via the include. However when I attempt this .level('<=navLevel') or similar the entire nav does not render.

{% set navigation %}

 {% set pages = craft.entries.section('navigation').level('<=2') %}

   {% nav page in pages %}

       {# Check for entry type / get related entry #}
       {% if page.type == 'internalLink' %}
           {% set linkedEntry = page.sitePageLink.limit(1).first() %}
           {{ page.title }}
       {% endif %}

       {# Check for entry type / get offsiteLinks #}
       {% if page.type == 'offsiteLink' %}
           {{ page.title }}
       {% endif %}

       {% ifchildren %}
         {# dropdown not set up yet #}

              {% children %}

      {% endifchildren %}

   {% endnav %}

 {% endset %}

 {# replace data-uri with active class #}
 {{ navigation|replace({('data-url="' ~ craft.request.getUrl() ~ '"'): 'class="active"'})|raw }}

Please advise


texts: Grouping entries by category - most efficient approach

texts:
I have come up with the following code to group entries by categories;

{% set hotTubs = craft.entries()
  .section('newHotTubs')
  .orderBy('price asc')
%}

{% set hotTubsCats = craft.categories()
  .group('newHotTubBrands')
  .relatedTo(hotTubs)
%}

{% block content %}

  {# Loop the categories #}
  {% for category in hotTubsCats.all() %}

    {{ category.title }}

    {# Get and loop through entries related to this cat #}
    {% set hotTubs = craft.entries.relatedTo(category) %}
    {% for entry in hotTubs.all() %}
      {% include '_includes/blocks/related-tub-new' %}
    {% endfor %}

  {% endfor %}

{% endblock %}

However, I wanted to check if this is the most efficient approach or if this could be improved upon?


texts:
I'm a little bit new to Craft, but it's already my favorite CMS, even after 8 years or so in Wordpress.

Here's what I need to do. I have integrated a preloader into my site, using preload.js, and I need to know if there is a way to utilize Twig within my JavaScript files.

Essentially, preload.js gets all of the assets to preload from a load Manifest, which is created with JSON. I got this working properly as an inline script, simply pulling the sources of all my assets, based on this question. What I need to know is, is there a way to use these Twig tags inside of an external JavaScript file? I know that there is in liquid, but I'd like to get this working here as well.

Thanks.


texts:
We have a channel on the following page that shows 'Issues' of our magazine: http://ambitmagazine.co.uk/issues

We have issues going all the way back to issue 1, but the channel page currently only shows issues back as far as issue 32:
http://ambitmagazine.co.uk/issues/32 (displaying in the channel feed)
http://ambitmagazine.co.uk/issues/31 (not displaying but the URL returns the issue information, and no other settings are different in the backend).

Does anyone know why this page might not be showing everything? Thanks!


texts: Create order programmatically in Craft Commerce

texts:
I want to create order via code in Craft Commerce. How can I achieve that?

Thanks in advance.


texts: Temp folder and file upload permissions issue

texts:
Using Sprout Forms Plugin, and following the front end file uploads example, I'm trying to use the famous jQuery File Upload plugin to deal with batch of large files and get upload progression.

This works fine, but :

How can I keep the files in a temporary folder before the form is submitted ?
When user is a guest, I'm getting a 403 (Forbidden) error after each
file upload (this happens even using Guest Entries's plugin from Pixel&Tonic, and with CSRF Protection is disabled) ;

Thanks for your help!


texts: Adding a RESTful, OAuth API on top of Craft

texts:
I’m currently considering options for a project that will require a standard sales site, commerce features and a user database. The user database will require a web frontend and an API for communication with a mobile app (read and write).

My dilemma is whether it makes sense to consider Craft for all three components, which will give us all the benefits of a unified system, or to split the user database into a separate project where we could take advantage of something like Laravel Passport, which seems like the obvious option for efficiently building a secure API.

The HTTP Messages plugin looks useful but doesn’t appear to deal with authentication at all and preexisting options for Yii/Craft OAuth appear limited to nonexistent. I get the sense that Craft 3/Yii 2 would make life easier, but waiting for a stable Craft 3 release isn’t possible.

Has anyone had any experience developing a secured API on top of Craft? If so, what route did you take and would you do it again?


texts:
I'm trying to order my entries by a numeric custom field named score, some of these values can be 0 but unfortunately, it's not getting ordered at all?

{% set users = craft.users.group('influencer').order('score').limit(24) %}

{% if users|length %}
    {% paginate users as pageInfo, pageEntries %}
    {% for user in pageEntries %}

/* New Code */

  {% set users = craft.users.group('influencer').orderBy('score desc').limit(24) %}

          {% if users|length %}

          {% paginate users as pageInfo, pageEntries %}
          {% for user in pageEntries %}


texts: Multiple category relationship criteria (or)and(or)

texts:
Is there a way to do relatedTo categories where the category is (a or b) and (c or d or e)?

I can get (a or b) working using:

{% paginate craft.commerce.products.relatedTo(categories).limit(20) as pageInfo, products %}

I can separately get (a and b) working using:

{% set relationParam = ['and', { sourceElement: product }] %}
{% for category in categories %}
    {% set relationParam = relationParam|merge([{ targetElement: category }]) %}
{% endfor %}
{% paginate craft.commerce.products.relatedTo(relationParam).limit(20) as pageInfo, products %}

I need to combine these though as I am working with 3 category groups for filtering and want to match products where it is related to any of the selected categories in group 1, and any of the selected categories in group 2, and any of the selected categories in group 3.

An example of selections would be like so:

Group 1: Essentials, Pearlised

Group 2: C6

Group 3: Reds, Greens

Using the 'or' syntax gives me too many results where they no longer match on each group and using the 'and' syntax is too restrictive and wants the product to have all of the selected categories. Does anybody know how I can nest the relatedTo criteria in such a way to get what I need?

I've attempted using the following but it didn't yield any results at all:

{% set relationParam = ['and'] %}
{% if rangeCategories|length %}
    {% set rangeParam = ['or'] %}
    {% for category in rangeCategories %}
        {% set rangeParam = rangeParam|merge([{ targetElement: category }]) %}
    {% endfor %}
    {% set relationParam = relationParam|merge(rangeParam) %}
{% endif %}
{% if sizeCategories|length %}
    {% set sizeParam = ['or'] %}
    {% for category in sizeCategories %}
        {% set sizeParam = sizeParam|merge([{ targetElement: category }]) %}
    {% endfor %}
    {% set relationParam = relationParam|merge(sizeParam) %}
{% endif %}
{% if colourCategories|length %}
    {% set colourParam = ['or'] %}
    {% for category in colourCategories %}
        {% set colourParam = colourParam|merge([{ targetElement: category }]) %}
    {% endfor %}
    {% set relationParam = relationParam|merge(colourParam) %}
{% endif %}
{% paginate craft.commerce.products.relatedTo(relationParam).limit(20) as pageInfo, products %}

I've not seen any examples of people using both 'and' 'or' syntax and there are no notes about this on the documentation so any help would be appreciated. Thank you.


texts: Where should an encryption key be stored?

texts:
I'm working on a plugin that needs to encrypt some user data. I'm setting an encryption key for SecurityService, but am trying to decide where to store that encryption key so it can be used on subsequent requests to decrypt the data. A few options are coming to mind:

StatePersister: this is where Craft keeps its cookie validation key, but is likely to be ignored by .gitignore, so probably wouldn't be persistent for long.
Plugin Settings Table: this is the approach being used by the SecureField Plugin. It's very straightforward, but also minimally secure as pretty much any SQL injection attack would compromise the key and its encrypted data. The upside is that the key's persistence is practically guaranteed.
Extend CStatePersister: This could be used to persist state in a writable location of my plugin's folder. It's more likely that this would be preserved in version control, but not very likely that the location will be writable on a production server.

As it stands, storing the key in the database is the most likely to work on a wide variety of servers, but probably has the poorest level of security. Am I missing any other options?


texts: Creating a slideshow with dots navigation

texts:
I have this slideshow implementing to entries, which works except Dot navigation.

A count of Dots in navigations depends on manually inputing attributes and assigning
numbers from 0...∞ ascendingly like this.

Actually, I limit(3) count of entries, so I know that there will be a certain number of dots. However, If there aren't any entries defined or only 1 entry defined, than I always get all three dots appeared, which don't function. So there MUST to be the exact number of dots as entries.

1 Entry: 1 Dot
2 Entires: 2 Dots
3 Entries: 3 Dots

So I'm thinking to go with if condition or loop through entries, but with my attribute output with number increased by 1.

So far, I've started with if, because no need to loop ... and I don't know, if this is right way.

{# Display navigation if the condition is true #}
{% if craft.entries.section('handle').lightswitchHandle('1') is defined %}

{# This is where I end up ... some comparission filter maybe ? #}
{% if craft.entries.section('handle').lightswitchHandle('1') %}

{% elseif craft.entries.section('handle').lightswitchHandle('1') %}

{% endif %}

{% endif %}

Update

    p
    n

    {# Get the slides, store in variable called "slides" #}
    {% set slides = craft.entries.section('food').news('1').limit(3) %}

    {% if slides %}

        {# Output slides, using the same "slides" variable #}
        {# Loop through "news" with lightswitch on #}
        {% for slide in slides %}
            {# Entry type - Article #}
            {% if slides.type == 'article' %}
                {% include '_includes/components/food/news-article' %}
            {# Entry type - Person #}
            {% elseif slides.type == 'person' %}
                {% include '_includes/components/food/news-person' %}
            {# Entry type - Recipe #}
            {% elseif slides.type == 'recipe' %}
                {% include '_includes/components/food/news-recipe' %}
            {% endif %}
            {% else %}

Any Text

        {% endfor %}

    {% endif %}

{% if craft.entries.section('food').news('1') is defined %}
{# Output navigation, check length of "slides" variable #}

     {% for i in 1..slides | length %}

     {% endfor %}

{% endif %}


texts: How can I get Craft Commerce talk to the API of a CRM?

texts:
A client wants his CRM connected to Craft Commerce. If someone finishes an order the customer data and the ordered products should be send to the CRM.
I assume I have to write a plugin for that, but I have no idea how to start and how the grab the desired data. Can anyone point me to the right direction? The CRM used is https://www.bitrix24.com/ if that's of importance.


texts: Upgrade failed - what needs to be restored?

texts:
Unfortunately I tried to (auto)upgrade to v2.5.latest on a live site (after testing on another development (but different site)) and it failed resulting in the site being down. What is the best way to restore the site to pre-upgrade and working state? I plan to

Remove the existing database and replace with the one created by the
backup process - that part seemed to go OK.
Replace the /craft/app directory from the version that matches the database backup.

Are there other files/things I need to do to recover the situation?


texts: Craft 2: Locale throwing 404 in frontend

texts:
I have my two locales set up as described in the official documentation.

I am able to translate my pages and fields in the CP as supposed to and have two versions ready in the backend, both with a green dot behind them.

However, when I try to access any page apart from the homepage in my 2nd locale in the frontend I get a 404 error.

DE is my first locale, placed within the /public/ folder.
EN is my second locale, placed within the /public/en/ folder with the index.php referring to ../../craft as shown in the official docs and the same .htaccess copied from the parent /public/ folder.

Furthermore, this is my general.php setup for the local development server, where I can not see any obvious mistakes yet:

'.develop' => array(
  'rootUrl' => 'http://deque.develop:8888/',
'siteUrl' => array(
    'de' => 'http://deque.develop:8888/',
    'en' => 'http://deque.develop:8888/en/',
  ),
  'environmentVariables' => array(
  'baseUrl'  => 'http://deque.develop:8888',
  'basePath' => 'http://deque.develop:8888',
  'devMode' => true,
)

I did not write the /en/ in any of the CP settings, only have the correct translations for the URL string there, so that should be no issue. The URLs are rendered fine and as supposed in the Frontend anyway. It’s just that a 404 is displayed for any English pages instead of the actual content.

In Craft’s log file I could only find this hinting at something:

2018/04/13 12:52:20 [error] [exception.Craft\HttpException.404] Craft\HttpException in /Users/Tobias/Development/deque_2018/craft/app/controllers/TemplatesController.php:72

Any hints where I might be making a mistake?


texts: How do you return a message if no entries are found?

texts:
I thought this would be very easy but I'm having a hard time figuring it out.

How do you output a warning/message if there are no entries to loop through?

{% set entries = craft.entries.section('news').limit(5).find() %}

{% if entries|length %}
    {% for entry in entries %}
      {# Do Loop #}
    {% endfor %}
{% else %}

No entries found.

{% endif %}

Or am I just sleepy and approaching this all wrong?


texts: Commerce: what is the purpose of a line item's snapshot?

texts: Having nearly completed my first real Commerce project, I managed to utilize most of the features offered in Commerce 3. However, I never quite figured out what the use of a line item's snapshot is for. What is it and when would you need to use it? There isn't anything about it in Commerce's docs.


texts:
When creating sections, I need a way to toggle all of them off or on. I have 188 sites and you can imagine how big of a pain it is to untoggle one by one.

Am I able to do this somehow? Create a module?

Edit: I've been told creating this many sites isn't a good idea, so perhaps this is a foolish question