texts: How do I output entries by their category?

texts:
Ok, so basically I want to loop through categories and output the title of each category along with all the associated entries. Like so:

Category 1: Entry 1 Title, Entry 3 Title

Category 2: Entry 2 Title, Entry 4 Title

(Where entry 1 and 3 are category 1 - and entry 2 and 4 are category 2)

This was the closest I got:

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

        {% for category in categories %}

{{ category.title }}

            {% for entry in craft.entries.section('people').relatedTo(category).find() %}

                     {{ entry.title }}

            {% endfor %}

    {% endfor %}

How would I do this?

Thanks!


texts: Craft Commerce Barclays ePDQ integration

texts:
Has anyone got this plugin/payment gateway to work?
Having issues with both client and test account details - testing on Craft Commerce 3 and know plugin was developed for Craft Commerce 2 so it is possible therein lies the problem so wondering if anyone has had any joy getting this to work with Craft Commerce 3.
(all submissions are logging a unknown order/1/s/ - SHASIGN field sent in the transaction request doesn't match the SHASIGN calculated on BarlcayCard end - error)
Cole


texts: saving user field type custom field - Failed to set unsafe attribute

texts:
I have tried to save a custom field of "user field" type which resulted in this error.

  "Failed to set unsafe attribute"

code:

$order->setAttributes(array(
    'operatorUid' => Craft::$app->user->id
));

Has anyone encountered a similar issue or can you let me know how to save a custom userType field to an order?


texts: Two domains - single install - Live Preview works only on one

texts:
I have a multi-site setup on two different domains (actually subdomains) with a single Craft install. I have modified config/general.php file to make it work on both the subdomains. Each domain has different template set completely independent of each other. However, Live Preview will work on entries created for only one sub-domain (one that is specified in the control panel). The option is not available for the other subdomain. This is because the public link for the entries corresponding to second subdomain is being parsed as those belonging to the first subdomain. Obviously those links are giving 404 error and hence the Live Preview button is not active.

Is there a way to tell craft that certain entries belong to a specific subdomain?


texts:
Recently we've had someone/something trying to perform a XSS attack using a form which saves all data into sessionStorage and then sends it to a custom craft plugin to pair it with a user.

A solution to stop these XSS vulnerabilities from craft docs is to "enable all “Purify HTML?” Rich Text field settings" but I've noticed this option only exists for Rich Text fields.

So my question is, is it somehow possible to activate "Purify HTML" on plain text fields (and other types of input like select and checkboxes)? Or do I need to escape/encode these fields on the client side (and how)?


texts: Is it possible to achieve lead scoring, personalisation / marketing automation using Craft?

texts:
Is there a Craft equivalent of this type of marketing automation?

lead scoring
personalisation

For example (4 min): https://www.youtube.com/watch?v=Ck9ywjBTEGM

Is there any plugin or external service that can be used with Craft to achieve this?


texts: Mailer Service Error when sending notifications emails on Freeform Pro

texts:
Can anyone give me a bit more insight into why I'm getting a "Mailer Service" error when trying to send an Admin Notification with Freeform Pro?  I get an error like this:
Unexpected end of template in "__string_template__aca8878083d6682fbce7766c168754a57b4bea4edfc409322a30b8425bbfa4e7" at line 3. {"template":"formSubmission","file":"/Users/ljk/Sites/mysite-craft3/vendor/twig/twig/src/TokenStream.php"} []

This makes me think there is an issue with the notification template - but I'm just using the pre-populated information that is given when I create a new notification. I've checked the file the error is pointing to, but nothing seems out of the ordinary (it's never been edited either). I've tried sending notifications with and without using form submission data.
For what it's worth, I'm using SendGrid and the test emails send correctly. I also have confirmed that the submissions are valid and not spam.


texts: Display related entries on the entry page they are related to

texts:
I have a number of 'blog' channel entries related to various 'fayre' entries
I want to display all the blog entries related to the fayre entry page they are related to (Entry field is 'fayreBlog'), but not ones which are not related to that entry, so far I can only display only one blog entry and not more (even though there are more related to the entry I am relating to) not sure where my code is wrong? it resides in the fayres _entry.twig template:

{% set relatedBlogs = craft.entries.section('blog').relatedTo(entry).all() %}

{% for post in relatedBlogs %}
    <p>{{ post.title }} </p>
{% endfor %}


texts: Save field inputs upon submission of front end form for reuse in new form?

texts:
Is there a straightforward way of saving the input of two form fields when a form is submitted from the front end and reusing it in another form?

One field is a select2 field (Users) which can contain multiple users and the other is a number field (Log ID).

The current workflow is that a user fills out a form and it's submitted to the database.  It's very likely that he will need to fill out additional forms immediately afterwards and two of the fields he inputed (Users and Log ID Number) in the first form are the same in the second form.

The workflow that came to mind was whether after first form submission, I could append the Users and Log ID into the url query string and then have them available to prepopulate in the additional forms.  Perhaps on a successful form submission page, I could have a button to allow the user to submit another form and if clicked, it goes to the new form page and grabs the url query string values and enters the info in the two fields.

Totally open to other ways of seeing this too so feel free to throw your thoughts out there.

Thanks!
Lori


texts: How to pass extra filters to products field type?

texts:
We are adding a 'Featured products' field to a category fields config and we're looking to filter the list of products that are selectable by the category this field is appearing in.
For example, if the user is selecting a featured product within the 'chairs' category I'd like the only products to show in the list to be within that category.
How could I configure this to get the relationship for the 'chairs' category in the products that are returned?
Thanks


texts: amforms: Import form submissions from one site into another

texts: Using Craft 2 and amforms, I created a massive form on a client's temporary site while working on the full refresh on a staging server.  While that development's been going on, the live temp site has been collecting form submissions the whole time.  We're preparing to overwrite the live server with staging's db, and the only thing that needs to be conserved from the live temp site is all those form submissions that came in.  Does anybody know a solution on how to do this?  I've purchased Verbb's Feed Me plugin but unfortunately it doesn't include importing to custom element types.


texts:
Problem:
I want to be able to log things to my Craft DB from an external app, via some sort of request.

So my first question is, is there any plans for any kind of built-in development log, or should use something like: https://github.com/themusicman/lumberjack/

Second, I'd have to set up some kind of shared key authentication so I could post to this log with an external request.

What tools does Craft/Yii already have for this process, and what would need to be custom development?


texts: Change field arrangement from the entries page

texts: In ExpressionEngine you can rearrange the field types from inside the entry. I was wondering if there was any feature like this in Craft? I've got a lot of different types of entries so it's a pain to jump back and forth between sections and entries to see if the organisation is correct, plus it would just be easier to organise if I can see what the final product would be.


texts: Fields filled out via JS randomly show up empty?

texts:
I've been working on a client's website and have come across a puzzling issue; the form is set up to take several separate fields and combine it all into one field (eg. there's 3 separate fields for the Birthday, the day, month, and year. At submission these fields are all combined and put into one singular field to prevent clutter in the backend).
This works fine for some users but at random the fields that are filled via JS are empty (I know this because when I display the fields separately they all show the correct info while the JS filled field is empty). I am also unable to test this on my laptop as it doesn't ever happen on there.
I am also not able to show all the fields separately on the backend because some fields are shown via a for loop, so showing 10*4 different fields on the backend is not optimal.
The website is running on Craft 2.8.0.2 and using the built in fields for forms (so there's no separate plugin for forms).


texts: How to allow multiple entries to have the same slug?

texts:
Users create an account and their profile (domain.com/userName) is a template pulling info from craft users.

Each user can create entries, all stored in a Structure section (domain.com/userName/entrySlug).

Problem is when different users have an entry with the same title, entrySlug can become entrySlug-1 etc.  Although the URL is unique, the slug obviously can't be with entries in the same structure.

But I cannot think how to set this up. A structure per user seems overkill.

Thanks


texts: Turn a tag field id into an instance of the tag model

texts:
The add-on I'm using to import blogs has this to save tags to an entry:

craft()->relations->saveRelations($tagFieldId, $entryRecord['elementId'], $tags);

Where the first arg is the field id for the tag, the second is the entry, and the third is the tags.

I'm getting an error that says $tagFieldId needs to be an instance of the tag model:

  Argument 1 passed to Craft\RelationsService::saveRelations() must be
  an instance of Craft\FieldModel,

Can I turn my little field ID into an instance of this? How do I get a fresh one, if not? Thanks for your help.

Any suggestions on approaches appreciated.

Also - would tag tagmodel but I'm a wee newbie.


texts:
I've been adapting the very useful geo plugin to fetch currency and exchange rates based on a visitors IP address. [ see: https://github.com/lukeholder/craft-geo ]

The plugin uses Craft's vendor package "guzzle" to contact 3rd party APIs and request data which then gets cached in JSON form.

When its not cached i was wondering how can you tell if Guzzle is making the request - there are no headers in dev tools and no noticeable traffic for the requests. So how can you see if the Guzzle has guzzled when cache is off?


texts: How to disable plugin when unable to log in?

texts:
I'm getting a blank page for both the front end and the CP/admin, and am tyring to figure out why. I changed my hard drive at about the same time as making a bunch of changes to a plugin, so just trying to figure out what I've screwed up.

I already did this: deleted vendor/craftcms followed by

composer clearcache
composer install

Is there a way to disable plugins from outside the CP?


texts: Dukt Video plugin oAuth issue with development environment

texts:
I'm wondering if anyone has come across this issue I have with the Dukt Video plugin and oAuth using it in a development environment using craft.dev?

Google oAuth only excepts top level domains for the re-direct url so the .dev url gets flagged as incorrect so I am unable to add the the redirect url to Google.

I've also encountered a problem on Vimeo where is throws a cURL error #60 after trying to connect.

And trying to use oAuth with Facebook or Twitter throws the following error:

  cURL Error # 60: SSL certificate problem: unable to get local issuer certificate

I need to test the plugin in a development environment so does anyone know a solution?


texts: Craft Commerce - On the fly product / product from entry form

texts:
Good Evening.
Does anyone know if the following is possible within Craft Commerce

Can data from normal entries be used to populate a one-off on-the-fly product?
Can an entry form be used to create new products or can they only be entered only in the admin section?

Any thoughts on the above or suggestions of other ways to create products from the front end would be appreciated.


texts:
Edit: This is confirmed as a bug in Craft, that will be fixed in its next release. If you're running into this, please see the temporary fix over at GitHub: https://github.com/craftcms/cms/issues/3772

I'm leaving up the original post for posterity.

--

I'm running into an issue with the recent update for Craft 3.1. I've not changed any of my code on the archive pages, but the list of entries on my archive pages stopped showing up.

Here is the code I use to set up the date ordering.

{% set firstEntryEver = craft.entries.section('posts').orderBy('postDate asc').one() %}
{% set lastEntryEver = craft.entries.section('posts').orderBy('postDate desc').one() %}
{% if craft.app.request.getSegment(2) is null %}
    {% set year = 2018 %}
{% else %}
    {% set year = craft.app.request.getSegment(2) %}
{% endif %}
{% set archiveBlurbs = craft.entries.section('archives').type('yearBlurb').archiveYear(year) %}
{% set monthBlurbs = craft.entries.section('archives').type('monthBlurb').archiveYear(year) %}
{% set entriesInYear = craft.entries.section('posts').limit(null).after(year).before(year+1).all() %}

And the call I use is {% for month, entriesInMonth in entriesInYear | group("postDate|date('F')") %}. The content is then separated by month over a single year.

The logic I use here generally follows the official docs with some light modifications. I find that the content for all years shows up if I remove the before.

Any idea what might be at play here?


texts: How can I get the image picker on the WYSIWYG editor?

texts:
I am running on the latest version of Craft (Craft CMS 2.6.3015).  I have a blog entry, which has a Rich Text editor for the body field.

However, I do not have an image or file upload field in the WYSIWYG editor, please see the screenshot below.

I have tried adding "image" to the array in /craft/config/redactor/Standard.json but it has no effect.

I have checked the storage folder and all folders have correct permissions.

Where is the button and how can I add it?


texts: Why isn't search working on the live page?

texts:
I have search working on my local .dev site.   It does not work on my live hosted site.  There are no error messages; it just reloads the home page.

Here is the search code in my site template.  The results code is below...

    <form method="get" id="site-searchform" class="searchform" action="{{ url('search/results')}}">
        <input type="search" name="q" autocomplete="off" placeholder="Search&hellip;">
        <input type="submit" value="Go">
    </form>

The results page...

        {% if entries|length %}
            {% for post in entries %}

{{ post.title}}

{{ post.postDate | date('F d, Y') }} Name

            {% endfor %}
        {% else %}

You search for "{{ query }}" didn't retun any results

        {% endif %}

Any thoughts?
Thanks.


texts:
I'm displaying list of fields on frontend (using craft.fields.getFieldsByGroupId) and for that purpose I need the fields in group to be in particular order.

Is there a way to add 'order' property to fields model and make them sortable in CP? I can't find appropriate hook (if it exists)


texts: Direct relation between templates and PHP

texts:
Is there a direct relation between code in templates and PHP code inside a controller for example?
I need to translate

{% set relatedProducts = craft.entries.section('products').relatedTo({
                   targetElement: testVariant,
                   field: "productVariants.productSizes"
}) %}

into a controller and im not sure how.


texts:
Hi guys are the any more detailed tutorials on how to setup a multi site on Craft3 BETA? I created two sites now, a Danish and English through the admin (Settings → Sites). The domain is the same but the Danish version will have the path http://localhost:8888/dk whereas the English version will be everything that does not have the first path of /dk.

I have set in the general.php the following:

return [
    '*' => [
        'omitScriptNameInUrls' => true,
        'usePathInfo' => true,
        'generateTransformsBeforePageLoad' => true
    ],
   'SITEHANDLE_NAME_ENGLISH' => [
       'siteUrl' => 'http://localhost:8888/
   ],
   'SITEHANDLE_NAME_DANISH’ => [
       'siteUrl' => 'http://localhost:8888/dk'
   ],
    'defaultWeekStartDay' => 1,
    'enableCsrfProtection' => true,
    'omitScriptNameInUrls' => 'auto',
    'cpTrigger' => 'admin',
    'devMode' => false,
];

In the Danish folder /dk, I created a new index.php, and the site correctly direct to this file from the URL, BUT, it does not change the site to the the Danish site, even though I have defined my index.php with the new php constant:

<?php
// Project root path
$root = dirname('../');
define('CRAFT_SITE', "SITEHANDLE_NAME_DANISH");
// Composer autoloader
require_once '../craft_folder/vendor/autoload.php';

// dotenv?
if (file_exists("../craft_folder/.env")) {
    $dotenv = new Dotenv\Dotenv("../craft_folder/");
    $dotenv->load();
}

// Craft
define('CRAFT_BASE_PATH', "../craft_folder/");

$app = require '../craft_folder/vendor/craftcms/cms/bootstrap/web.php';

$app->run();

How do I tell Craft to load the Danish site from the index.php? Right now it will only load the primary site not matter what I try.

Thanks!


texts:
Here is my situation. This is not a whole code, only the part, where I'm having a problem. At the back end, model coverbackup is populated with files as well as model cover. If I depopulate cover (remove image from entry), I want to load model coverbackup. I was checking over and over, If I got to my file in matrix field correctly, but It seems I have.

Than I've tried to check if elseif statement loads anything on cover=false, I got empty output.

{# Get the slides stored in variable "slides" #}
{% set slides = craft.entries.section('handle').type(['article', 'blog', 'news']).order('RAND()').limit(3) %}

    {% if slides %}

        {% for slide in slides %}

            {% set cover = slide.coverImage %}
            {% set coverbackup = slide.entryContent %}

                    {% if cover %}
                        {% for cover in cover %}

                        {% endfor %}

                    {% elseif coverbackup %}
                        {% for block in coverbackup %}
                            {% if block.type == "image" %}
                                {% for image in block.images %}

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

     {% endfor %}

{% endif %}


texts: Can I stop the logged-in user from selecting other users in the author dropdown?

texts: I have a member group that has very fine grain options when they log in. They should only be able to add, edit, and delete their own entries in a single channel. At the moment they can select any user as the author. Is it possible to not allow them to change the author?


texts: Use `onBeforeSaveEntry` event to update EntryModel properties?

texts:
With my plugin I listen for onBeforeSaveEntry events and make changes to the $entry EntryModel. It works and I can change most properties from this function, but I have problems updating sectionId, typeId, authorId, postDate and expiryDate.

I looked up the relevant code in EntriesService.php and noticed that it might have something to do with a variable $entryRecord that gets saved to the DB separately (comment in the code: "Save the actual entry row").

Am I doing something wrong or is it simply not possible to set these properties from this function. As an alternative solution I could trigger a seperate saveEntry() from here, but this looks to be not the cleanest solution.

craft()->on('entries.onBeforeSaveEntry', function(Event $event)
{
    // Disable the entry
    $event->params['entry']->enabled = false;

    // Change the `authorId` (does NOT work!)
    $event->params['entry']->authorId = 1;
});


texts:
I think I've just about hit my wits end here. I'm trying to get set up on a new Rackspace server and I can't seem to get my URL rewriting to work properly. Here's what I got so far:

My Craft install is in /var/www/html.

apache2.conf

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

000-default.conf (my vHost configuration)

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/www

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

... and then within my craft install in /var/www/html

config/general.php

return array(

  '-- omitted --' => array(
    'devMode'              => true,
    'omitScriptNameInUrls' => true,
    'environmentVariables' => array(
      'siteUrl'            => 'http://-- ommitted --/',
      'fileSystemPath'     => '/var/www/html/www'
    ),
  ),
);

www/.htaccess

<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>

Am I missing any configuration here? I can't access any of my entries or the admin panel without appending index.php before the path.

Any help would be greatly appreciated!


texts: Multiple articles with individual entries

texts:
I am laying out a site which will have a newspaper style IA. There are multiple Main Sections and each section will have multiple Articles and each article has multiple entries.

The client only knows the names of the Articles and needs to create these and then subsequent start adding the  entries to each article. The articles have their own Landing Page (listing the entries) and there will be a Landing page for all Articles.

Creating the Articles as sections, with structures would have the benefits of the <nav> tag, but the layout for each entry will be the same.

Which is the easiest for the client? Setting the Articles up as Sections or as Main Categories (which they really aren't as the are simply titles for each article), or is there a better way?

PS: the Articles are like mini-books, with multiple chapters......


texts: Limit countries shown in checkout shipping to countries assigned in shipping zones settings?

texts: Is there a way to restrict the list of countries available in the checkout shipping address select menu to the countries assigned in the shipping zones?


texts: {{ category.title }} error with category groups

texts:
I feel like I'm missing something totally obvious here, but how do I output a category name for a category that is part of a category group on a single entry layout? The name of the category group is 'Archive' and the slug 'archive'.

Here is what I'm trying to do.

*name of category*

Here is what I tried

{{ category.title }}

However then I get the error "Variable "category" does not exist."

Trying the following code snippet from the official tutorial also did not work.

    {% for category in entry.postCategories.all() %}

        {{- category.title -}}

    {% endfor %}
  {% endif %}

resulting in the following error: "Calling unknown method: craft\elements\Entry::postCategories()"

Any help to solve this probably very simple problem is appreciated. Thank you!


texts: Data cached in plugin controller via CacheService won't expire

texts:
My cache won't expire. This is effectively my code:

    $template = (isset($params['template']) ? $params['template'].'?'.$config['pageParam'].'='.$pageParam : null);

    if(craft()->cache->get($template))
    {
        echo craft()->cache->get($template);
        craft()->end();
    }

    if(craft()->config->get('enableTemplateCaching'))
    {
        craft()->cache->set($template, $JsonValue, 'P1D');
    }

The cache saves just fine but when I forward the clock on my server a few days ahead and refresh the page it's still using the cached data. I've also tried actually waiting a few days in case it was using another clock but that didn't help either.

Is there something I'm missing? I figure Craft or the Yii Framework will take care of expiring the cache after the one day period set (P1D). I don't see any methods to check the date of the cache or anything where I could manually intervene.

For what it's worth I'm using theolampert's fork of the ElementAPI plugin which adds caching.


texts: Pulling the currently rendered field layout inside the CP

texts:
Inside the CP, is it possible to pull the ID for the current field layout being rendered (both in the Field Layout Designer and in element editing forms)?

A bit of context:

I'm writing a plugin which adds functionality to the built-in Field Layout Designer. The extra functionality basically allow admins to add metadata when they are editing field layouts. This metadata is stored in a custom table, using the field layout's ID as FK. The idea is that whenever a field layout is rendered (either inside the FLD, or when an element is edited/created) the plugin should pull the metadata for the current field layout.

Modifying the FLD UI is easy – when the plugin loads, I basically check the DOM (with jQuery) for a FLD container. If a container is found, the plugin loads up a script.

Saving the metadata is also easy; the plugin hooks into fields.saveFieldLayout like this:

craft()->on('fields.saveFieldLayout', function (Event $e) {
    $myPluginModel = new MyPlugin_MyPluginModel();
    $myPluginModel->fieldLayoutId = $e->params['fieldLayout']->id;
    $myPluginModel->metadata = craft()->request->getPost('myPlugin.metadata');
    craft()->myPlugin->saveStuff($myPluginModel);
});

The hard part is querying for the relevant metadata whenever a field layout is rendered, because I can't find a way to pull the currently rendered field layout's ID.

Here's ideas I've explored/solutions that doesn't work:

Neither the FLD nor the element editing forms expose their field layout's ID to the the DOM.
I've looked at the HttpRequestService to see if the field layout ID (or any other data I could use to query for the field layout ID) could be pulled from the request.
I've tried accessing the current controller class via craft()->controller – thinking if I could get to the current element type I might be able to pull the field layout from its model, but craft()->controller is always NULL.
I've attempted to pull the global Twig context (via craft()->templates->twig) to look for the fieldLayout variable.
Ideally, I wouldn't want to pull the relevant metadata client side (i.e. with AJAX), but I did also look at the global Craft JS object to look for clues, but found nothing.
Parsing the request path and storing the ID of the entry type, asset source, category group etc. along with the field layout ID would work. I'd like to avoid this, because it makes it impossible to support custom element types without hard coding stuff.

If it isn't possible – by any means – to pull the current field layout ID, the alternative approach is to somehow figure out which element type is being edited, then pull that element type's model and finally get the field layout model/ID from there. Ideally, I'd like to do this without having to hard code attribute names (i.e. entryTypeId, categoryGroupId etc), because I want this to work for any custom element type, too. Any suggestions in this regard is very welcome, as well.


texts: Array to string conversion Template Error

texts:
I have 2 bits of code that should be about identical with the exception of one being in a Matrix and one not. The bit that is not looks like this:

    {% for point in entry.keyPoints %}

{{ point.heading }}

                {{ point.text }}

    {% endfor %}

This works exactly as intended. and uses the "ICON" 3rd-party field type which essentially is a dropdown that allows me to pick which icon I want to use.

The code that i'm having trouble with is:

{% for block in entry.articleBody %}
    {% if block.type == "text" %}
         Some stuff here
    {% elseif block.type =="iconSection" %}
        {% if block.getPrev() %}
            {% if block.getPrev().type != "iconSection" %}

            {% endif %}
        {% else %}

        {% endif %}

{{ block.heading }}

                {{ block.text }}

        {% if block.getNext() %}
            {% if block.getNext().type != "iconSection" %}

            {% endif %}
        {% else %}

        {% endif %}
    {% elseif block.type =="video" %}
        some stuff here
    {% endif %}
{% endfor %}

It is saying Template Error (Array to String Conversion) with this bit highlighted:

As you can see the code is almost identical except it is BLOCK instead of POINT, and the block one is in a matrix where as the point item is not. What might be causing this and how might I resolve it?


texts:
I'm having an issue where a user is uploading images but they're not showing up correctly. The photo is listed in /admin/assets and shows the correct file size, kind, dimensions, etc but I'm getting a 404 error on the file's url.

I seem to able to upload images without issue myself.


texts: How to handle 'related' categories within import script

texts:
So I'm attempting to hack together a script to import thousands of entries and hundreds of categories from a bespoke system.

I have imported all the categories (around 800 of them) successfully. The category group they've been imported into has a 'relatedCategories' field so that each category can optionally be related to other categories in the group.

I'm now looking to do a second pass to import the related categories,  this is the part I can't quite get my head round.

The story so far...

    $db = new DbConnection(***);
    $db->charset = 'utf8';

    $entries = $db->createCommand()
        ->setText('SELECT * FROM categories')
        ->queryAll();

    foreach ($entries as $entry)
    {
        $craftcat_criteria = craft()->elements->getCriteria(ElementType::Category);
        $craftcat_criteria->title = $entry['title'];
        $craftcat = $craftcat_criteria->first();

        $related_array = array_filter(explode('#',$entry['similar']));

        $relatedcats = [];

        foreach ($related_array as $related_item)
        {
            $related_criteria = craft()->elements->getCriteria(ElementType::Category);
            $related_criteria->title = $related_item;

            $related_cat = $related_criteria->first();

            $relatedcats[] = $related_cat->id;
        }
    }

So I have the ElementCriteriaModel for the category and an array containing the ID of each of the related categories.

I'm going on the basis that it's craft()->relations->saveRelations() I need to use, but I just can't get the syntax right.

Can someone give me a shove in the right direction?


texts: JavaScript equivalent to "namespaceInputName"?

texts:
Is there a JavaScript equivalent to namespaceInputName?

My fieldtype settings are doing some interesting JavaScript gymnastics. Part of the process involves creating an array on the fly (so when the fields are submitted, the array will be stored properly). Currently, it's working great using JS code like this:

function(subfield, type, value) {
    var name = 'types[MyPlugin_MyFieldtype][dataArray][' + subfield + '][' + type + ']';
    var hidden = '<input type="hidden" name="' + name + '" value="' + value + '" />';
    // Then add that hidden field to the DOM
}

Here's where it gets interesting... This prefix works great as long as I'm building a normal field:

types[MyPlugin_MyFieldtype]

But, it stops working when I try to build my field within a Matrix. Because when my field is nested within a Matrix, the prefix should look something like this:

types[Matrix][blockTypes][4][fields]

Is there any way (in JavaScript) to automatically set that prefix properly?


texts: Element API Fetch Entries URL Within Matrix

texts:
I have a matrix with a field to set a Entries URL. Unfortunately the entry is not being returned, only an empty object.

Here are my field settings below and element api code.

See below for the response within the json. I get an empty object?

Why is no data coming through?

I'm fetching the data within a function like so:

Here is the code from my Element API:

function panelsMatrix($array) {
    $panelBlocks = [];
    foreach ($array as $block) {
        switch ($block->type->handle) {
            case 'panel':
                $panelBlocks[] = [
                    'heading' => (string) $block->heading,
                    'text' => (string) $block->text,
                    'image' => $block->image[0]->url,
                    'imagePosition' => $block->imagePosition,
                    'textBaseColour' => $block->textBaseColour,
                    'textHorizontalAlignment' => $block->textHorizontalAlignment,
                    'textVerticalAlignment' => $block->textVerticalAlignment,
                    'imageOffsetX' =>$block->imageOffsetX,
                    'imageOffsetY' =>$block->imageOffsetY,
                    'backgroundColour' => $block->backgroundColour,
                    'subPageDirect' => $block->subPageDirect->first()
                ];
            break;
        }
    }
    return $panelBlocks;
}


texts: Updating user profile matrix block with plugin (Craft 3)

texts:
I am working on a plugin for Craft 3 that will add new matrix data to users profile and keep the old/current data that is in the matrix field.

I have been looking at these but they are for Craft 2 so maybe that's the problem:

Updating user profile matrix block with plugin
Creating a matrix entry with a plugin

The below is what I have tried but getting the error "Class 'controllers\MatrixBlockModel' not found"

$member_id = Craft::$app->getUser()->getId();
$dateCreated = date('Y-m-d H:i:s');

$block = new MatrixBlockModel();
$block->fieldId = 77;
$block->ownerId = $member_id; //Users ID
$block->typeId = 11; //Block Types ID
$block->ownerLocale = 'en_us';
$block->sortOrder = 1;

$block->getContent()->setAttributes(array(
    'fileDownloaded' => 'fileDownloadedxxxxprotectedlinks_links',
    'manufacturer' => 'manufacturerxxxxprotectedlinks_links',
    'date' =>  $dateCreated,
));

$success = Craft::$app->matrix->saveBlock($block);

I also added:

use craft\elements\MatrixBlock;

Any ideas?


texts: Craft 3 - Moving assets between folders causes apache connection to max out

texts:
In Craft 3, I keep running into an issue when I try to move a large amount of files (around 200) by dragging and dropping from my “Holding” folder into a “Live” folder using Craft Assets section. Both folders are hosted on Amazon S3.  Even moving three files seems to take a really long time (about a minute).

After checking the server logs it looks like I am filling my max apache connection due to the search-index-perform-action.  The error suggested I increase my “MaxRequestWorkers” setting.

I move about 2,000 files every month and never had a problem on Craft 2.  I don’t know if should change the “MaxRequestWorkers” setting or if there is something else I should consider doing.  If I should change the setting, where is it, I can't seem to find it.

I use Transmit FTP to initially move the files into the Holding folder and then index the assets in that folder. Then in Craft CMS control panel, I drag the files from Holding folder to the main Live folder so that the asset index gets updated.

UPDATE

I looked in my phperror.log file and found these three types of errors occuring:

PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 1048576 bytes) in /storage/avxxxxx/www/public_html/vendor/craftcms/cms/src/helpers/DateTimeHelper.php on line 231

PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /storage/avxxxxx/www/public_html/vendor/craftcms/cms/src/elements/db/ElementQuery.php on line 2215

PHP Fatal error:  Maximum execution time of 90 seconds exceeded in /storage/avxxxxx/www/public_html/vendor/league/flysystem/src/Util.php on line 322

PHP Fatal error:  Maximum execution time of 90 seconds exceeded in /storage/avxxxxx/www/public_html/vendor/league/flysystem-aws-s3-v3/src/AwsS3Adapter.php on line 294

PHP Fatal error:  Maximum execution time of 90 seconds exceeded in /storage/avxxxxx/www/public_html/vendor/league/flysystem/src/Util/ContentListingFormatter.php on line 52

It seems like when I move a file from Holding (950 files) to Live (20,000) files is where things get hung up.

Holding -> Live = 1 file takes 7 seconds to move
Live -> Holding = 1 file takes 20 seconds to move

Could it be an issue with the cache or search-index?

Here are my current settings if it helps:

memory_limit 256M

max_execution_time = 90

Max Requests = Per Child: 300 - Keep Alive: on - Max Per Connection: 150

Timeouts = Connection: 10 - Keep-Alive: 2


texts:
After playing around with Craft CMS for awhile I'm a little curious how some of you would approach this.

How would you add a tabbed div to an entry?

An example of the tab div below, it's the first example in the Bourbon Refill framework site.

Bourbon Refills

Thanks


texts:
I'm trying to get my head around the following issue. I have a site which uses a base layout template base.twig, on which 3 layout templates are build (using extends). One of them is main.twig.

I want to use the paginate information variable pageInfo (see docs) in a block that's defined in the base template, to show the total number of entries found in the {% block pageTitle %}{% endblock %}. I tried a number of things, including defining a pageTitle variable in the base.twig template, to override in the content block, but all without any luck.

These are stripped down versions of my files:

_layouts/base.twig

        <title>{{ title }}</title>

        {% block header %}{% endblock %}

            {% block pageTitle %}{% endblock %}
            {% block main %}{% endblock %}

        {% block footer %}{% endblock %}

_layouts/main.twig

{% extends "_layouts/base" %}

{% block main %}

        {% block content %}{% endblock %}

{% endblock %}

posts/index.twig

{% extends "_layouts/main" %}
{% set title = 'My posts listing' %}

{% set entries = craft.entries... %}

{% block content %}
    {% paginate entries as pageInfo, pageEntries %}

            {% for entry in pageEntries %}

{{ entry.title }}

            {% endfor %}

        {% block pageTitle %}

{{ pageInfo.total }} entries found

        {% endblock %}

    {% endpaginate %}
{% endblock %}

I know this has to do with variable scopes, but how can I use the paginate information outside my content block? One solution I tried does indeed works, but do I really need to copy the {% paginate %} statement inside my pageTitle block to get this working? That seems to be very inefficient to me:

posts/index.twig

{% extends "_layouts/main" %}
{% set title = 'My posts listing' %}

{% set entries = craft.entries... %}

{% block content %}
    {% paginate entries as pageInfo, pageEntries %}

            {% for entry in pageEntries %}

{{ entry.title }}

            {% endfor %}

    {% endpaginate %}
{% endblock %}

{% block pageTitle %}
    {% paginate entries as pageInfo, pageEntries %}

{{ pageInfo.total }} entries found

    {% endpaginate %}
{% endblock %}

Hope you can help me out or point me in the right direction. Any tips regarding a better structure for the blocks are also welcome. Twig seems so popular, so you'd think it can't be that hard for such simple tasks? Maybe I'm using the whole block concept totally wrong in the first place.


texts: Is there a query parameter to get categories that are related to anything else?

texts:
I'm looking for a way to query all categories that have at least one relation.  I'm not looking for the relatedTo() parameter, which would give me categories related to something specific.

Basically, if we talk in Wordpress terms, I'm looking for hideEmpty = true.

Is there anything like that in Craft?

Something like: craft.categories.group('products').hasRelated()


texts: Craft 3.1: value of craft/web/Application::getIsLive() must be of type boolean, null returned

texts:
I tried upgrading a Craft 3.0 installation to 3.1, and got the following error:

  "value of craft/web/Application::getIsLive() must be of type boolean, null returned"

Has anyone else run into this?  Does anyone know a fix?


texts: Craft Commerce product item price showing incorrect

texts:
If I use the following format to show an item price:

.defaultVariant.salePrice|currency('GBP')

or

.defaultVariant.salePrice|commerceCurrency(cart.currency)

the website is returns as:

9,99 £

Instead of what is expected:

  £9.99

Has anyone ever seen this before?
I am using Craft CMS 3.28 and Commerce Pro 2.1.10.


texts: How can I make the redactor table plugin show extened options?

texts:
When I use the Redactor table plugin everything works but I can't seem to get any extended functions to work like cellpadding, cellspacing, table border color etc.

How do I do that?


texts: Installation stops halfway. Files not found and internal server error 500

texts:
I've installed craft on some terrible hoster (I know, under force). Because of that I had to install craft in the public folder, next to the index.php file. I've set the path to ./craft and activated the .htaccess file. Now it will show the installation page, but halfway stops
with the attached errors.

The odd thing is that it searches for /garnish-0.1.min.map in the site root, while it's in the app/resources etc folder?

(Click to enlarge)

EDIT: Placing the file garnish-0.1.min.map in the root removes the first error, apparently it's really looking for the files in that place?


texts: I'm converting a large EE site into Craft with the FeedMe plugin. So far it's working great. However, I've hit a speed bump. I need to import the SEO data attached to each article into Sprout SEO. When attempting to map the meta title, keyword and description data into the Sprout SEO field it only shows one destination field - the Meta:Basic field. Is it possible to import those 3 sets of data into the corresponding fields within Sprout SEO?


texts: nesting functionality missing in section type structure after feed-me import

texts:
i create an new section from type structure.
when i manually add the entries and nest it everything works as aspected.

after importing my entries with feed-me and the option create parents if not exist the nesting is gone and i cant set test as parent in Content-test. when i check the section.yaml its still of type structure.

there is for me no way to get the nesting back.
only option now is to recreate the section.
anyone although having this issue?


texts: How do I only display list of categories at certain level of parent category that have entries

texts:
I try to explain you semantically what I want to achieve here. I couldn't make it shorter. Sorry.

Navigation will be constructed from .level(1) categories.
At "site.com/firstLevelCat" I want to display list of populated .level(2) categories like this

site.com/firstLevelCat/secondLevelCat
site.com/firstLevelCat/secondLevelCat2
site.com/firstLevelCat/secondLevelCat3

At "site.com/firstLevelCat/secondLevelCat" I'd like to display list of .level(2) categories along with a list of .level(3) categories like this

site.com/firstLevelCat/secondLevelCat/thirdLevelCat
site.com/firstLevelCat/secondLevelCat2/thirdLevelCat
site.com/firstLevelCat/secondLevelCat3/thirdLevelCat

I intend to build it up to 4th level.


texts:
What is the preferred way of loading a third party library in a plugin? I'm trying to develop a plugin to extend SproutForms so that users get signed up to Campaign Monitor.

So far I've got an interface in the CP where users can provide their API keys and List ID's into the database, so now I just need to actually add the CM API library.

I know I can just require it, but I was wondering if there is a better way of doing this? Also where would I store the library, just in pluginname/lib/?


texts:
I need some direction in how to store (complex) data into users (best practice)

I'm working on a project for a fitness app. I created a structure with 2 levels for workouts where level 1 entries are skills and level 2 entries progressions for these skills, in the progressions I made a matrix containing a content field for an exercise, a table for data such as sets and reps and some practical information.

Now here is how it should work:

The user starts a workout, a workout contains 4 or more exercises to complete for the workout to be finished. Now when every set of an exercise is done, the user has to fill in a number of repetitions he/she did for every set. When the workout finishes I would like to save all this data in the user (Or should i make a section for this?)

The data looks something like this:

    "skillID": {
      "set1":"rep1"
      "set2":"rep2"
    }, etc

This data is important, the next time this user is logging in and starting a workout I want to retrieve this data to give the user overview of how he/she is progressing, so like comparing the workout data with the user data. Plus it should be some kind of history too. Here it gets a bit to complicated for me, but I want to learn this! My thoughts were this:

Option 1: I create a section, here I create user data entries (so they are related with the user who create them) I store the data somehow on these entries, with tables or something
Option 2: I store 2 JSON models into the user (if possible), 1 for writing and overwriting the progress of each workout (when doing the same workout it overwrites the existing data) and 1 for the history, were every date of doing a workout is a key and the value is the whole workout data provided by the users input.

What is the best way to go?


texts: Vanilla Forum Embedded SSO Export User Groups as Roles

texts:
I have implemented vanilla forums as a discussion solution for my website. I have made it embed into my parent site and also setup jsConnect to auto sign in the user if he/she is logged into my parent craft website.

I have used this tutorial to set things up:

http://blog.vanillaforums.com/jsconnect-technical-documentation-for-embedded-sso/

I can now sign in to vanilla forums using my craft user but next I also want to assign the group permissions to the user. I will define the roles in vanilla forum to match with the user groups in craft but I have no idea how to use jsConnect to assign user roles. Anybody have any experience with such a problem or can help in any way please do.

My Forum Page:

    {% extends "_layout" %}

    {% block content %}

    {% endblock %}

My Variable function (craft.myPlugin.authenticateUser()):

public function authenticateUser(){
        $userModel = craft()->userSession->getUser();
        $clientID = "[clientId]";
        $secret = "[secret]";

        if($userModel)
            $signedIn = true;

        $user = array();

        if($signedIn)
        {
            $user['uniqueid'] = $userModel->id;
            $user['name'] = $userModel->username;
            $user['email'] = $userModel->email;
            $user['photourl'] = $userModel->photo;
            $user['client_id'] = $clientID;
        }

        $user = json_encode($user);
        $signature_string = base64_encode($user);
        $signature_string = $this->getStr2Hex($signature_string);
        $timestamp = time();

        $signature = hash_hmac("sha1", "{$signature_string} {$timestamp}", $secret);

        $result = $signature_string." ".$signature." ".$timestamp." hmacsha1";

        return $result;
    }


texts: How can I convert a date format from my plugin so it saves correctly?

texts:
I have a plugin that includes a datepicker.

I initialize the datepicker like this

javascript

$('.datepicker').datepicker({
    'format': 'mm/dd/yyyy',
    'todayHighlight': true
});

I am saving the date from my plugin like this:

$myDate = craft()->request->getPost('myDate');
if ($myDate) {
    DateTime::createFromString($myDate, craft()->timezone);
}

$fieldsLocation = craft()->request->getParam('fieldsLocation', 'fields');
$entry->setContentFromPost($fieldsLocation);

Because I have designated this field to be required, I get an error back saying that the field cannot be blank. Even though I have chosen a date.

If I change my datepicker to use this format:

$('.datepicker').datepicker({
    'format': 'yyyy/mm/dd',
    'todayHighlight': true
});

Everything works.
I like how "human/U.S" friendly the top example is vs. yyyy-mm-dd.

Since I am populating the entry with this:

$entry->setContentFromPost($fieldsLocation);

Is there a way to convert what is passed in to the correct format Craft is looking for?

I've tried something like:

$date = date(str_replace('/', '-', craft()->request->getPost('myDate')));

$myDate = date('Y-m-d', strtotime($date));

But that is getting overwritten by this guy still:

entry->setContentFromPost($fieldsLocation);

Thank you for any suggestions!


texts: How can I efficiently show the number of total results per channel when retrieving search results?

texts:
I have a site with a few channels each with a lot of entries. When retrieving the results from a site search, I’d like to show a paginated list of entries from all sections by default, but then have filters in a sidebar which retrieve only entries from a certain channel, again in a paginated list.

How can I initially show the total number of entries in each channel for a particular search term, without having to actually construct a query for each channel individually which would be really slow?

The behaviour would be identical to the following example where it lists the number of entries for each ‘Material type’ http://explore.bl.uk/primo_library/libweb/action/search.do?dscnt=1&tab=website_tab&dstmp=1461161587439&vl(freeText0)=family&fn=search&vid=BLVU1&mode=Basic&fromLogin=true


texts:
Building further on this problem, I try to make a loop that exits when the next opening hours or in other case events are found.

There is an event on all days except monday. I added a couple of extra elseif statements in case they drop a couple of events.

I have the following code (based on the answer below I changed my code)

{% for entry in craft.entries.section('events').level(2) %}
  {% if entry.dayOfEvent == now|date("l") %}
    {{ entry.dayOfEvent }}
  {% elseif entry.dayOfEvent == now|date_modify("+1 day")|date("l") %}
    {{ entry.dayOfEvent }}
  {% elseif entry.dayOfEvent == now|date_modify("+2 days")|date("l") %}
    {{ entry.dayOfEvent }}
  {% elseif entry.dayOfEvent == now|date_modify("+3 days")|date("l") %}
    {{ entry.dayOfEvent }}
  {% else %}
{% endfor %}

But this doesn't seem to do it. It's probably basic stuff, but what am i doing wrong?

Update

Based on the answer below I changed my code

The output clearly gives me my days. But the {% elseif %} doesn't work, I just get the day outputted as well for all events in that range. Shouldn't it exit the loop as soon as the condition is met?


texts: Updating private repo plugins from admin?

texts: Is it possible to update private repo plugins from the admin at all? Would love that functionality, especially for smaller projects that are installed where there's no CLI access.


texts: filter entries by id retrieved from matrix block entry

texts:
I've searched around and other solutions don't seem to be working I must be missing something obvious

Here's what i'm doing

{% set myVar = '' %}
{% for block in entry.matrixComponent %}
     {% if block.type == "matixBlockType" %}
          {% set myVar = block.matrixBlockField.ids() %}
     {% endif %}
{% endfor %}

This seems to work when I dump myVar I get

array(1) {
  [0]=>
  string(5) "10032"

which is indeed the id I'm looking for. I then

{% if entry.id not in myVar %}
    <div> {{ entry.id }} {{ Title }} not in myVar </div>
{% else %}
    <div> {{ entry.id }} {{ Title }} is in myVar {{ myVar }} </div>
{% endif %}

It lists out my posts in the matrix component, and where the entry.id matches myVar it still says not in myVar even though it would seem to me that it should have excluded it.

I'm not sure why it is listing the entry that matches myVar's Id


texts: How can I use a double relation to include the currentUser as criteria?

texts:
I have a front-end form that allows registered users to edit content. In this case, it is a podcast. I have multiple podcasts that blog to different providers.

Here is how I am selecting the provider that belongs to the currentUser:

{% set provider = craft.entries()
    .section('provider').relatedTo({
        element: currentUser,
        field: 'contributors'
    }).one() %}

Works great. From there, here is how I am selecting the podcast that belongs to the current provider (selected above).

{% set podcast = craft.entries()
    .section('podcast').relatedTo({
        targetElement: provider,
        field: 'podcastProvider'
    }).one() %}

This works well, I am able to get the podcast and do whatever with it.

However, I'd also like to make a double check that this podcast belongs to the current provider - which belongs to the currentUser. Maybe that's overkill, I'd like to hear thoughts about that...

Here is what I am trying, but not having much luck.

{% set podcast = craft.entries()
    .section('podcast')
    .relatedTo(['and',
        {targetElement: provider, field: 'podcastProvider'},
        {targetElement: currentUser, field: 'provider.contributors'}
    ]).one() %}

currentUser is of course the user that is currently logged in. contributors is a users field that exists on the provider entry.

So, I was trying to make double-sure that the person who was logged in, not only belong to the provider, but the podcast they are editing belongs to the provider - that they (the currentUser) belongs to.

Or, is this completely overkill? Thank you for your suggestions!


texts:
I want to ensure that cache is set per domain at a config level. So rather than saying something like this in the template:

{% cache using key craft.config.getHostInfo ~ '.' ~ entry.slug ~ '.masterPrimaryNav' %}
    foo
{% endcache %}

I would like to set this in config so the cache key is prepended automatically. I had hoped that the general appId would help this on config, but I can't see that being set in the cache key when I set it: http://buildwithcraft.com/docs/config-settings#appId

Is there a way to do this?


texts: Craft Commerce - More detailed reporting

texts: I'm looking to get more detailed reporting from craft commerce. I would like to be able to see a breakdown of what we've sold in a set period of time (week, month etc) which details out products, revenue, and quantities. Right now I only have the option to see total revenue or top products


texts:
Does anyone know of a way to instruct PHPStorm to treat Craft templates as Twig files, without globally assigning all .html files to be interpreted as Twig? Since Craft templates don't use the .twig extension, PHPStorm thinks they're HTML.

On that note, why doesn't Craft use .twig extensions? I assume P&T doesn't want to scare away users who are comfortable with HTML but not Twig?


texts:
I am trying to use Twig methods/loops while working on a design/template. To avoid touching the CP or the DB i did set variables directly in the template, like :

{% set service =
  {
    'titel':
      [
        'Titel1',
        'Titel2'
      ],
  }
%}

{% for i in 0..1 %}

{{ service.headerQuote }}

{% endfor %}

It would be much better to be able to use the standard Craft methods, so if I move from templating/designing towards the DB i wouldn't have to touch the methods in my markup.  Unfortunately, I can't make it work... I tried:

{% set service = { titel:
                   [
                     'hallo',
                     'hallo2'
                    ]
                  }
                %}

{% for entry in craft.entries
      .section('service') %}

{{ entry.titel }}

{% endfor %}

I tried to set the service entry to craft.entries.section('service') but that doesn't work as well... what am I missing?

Is it even possible to overwrite Craft variables in the markup?


texts:
Wordpress has a great feature which allows visitors to sign up to receive email notifications whenever there's an update to the site. I'd like to emulate this functionality.

I'm aware of Postmaster, Brief, Sprout Forms, Sprout Emails, MailChimp Subscribe and have read through similar discussions and solutions here on the Craft SE - but nothing that would get me all the way there.

Requirements would be:

Ability to sign up per channel via email (a form per channel)
Confirm email address (double opt-in)
No (Craft member) registration necessary
Ability to unsubscribe
Auto send email notification when new entry is posted

Is there a current solution that could tick all these boxes? If not, would this a possible to build as a plugin?


texts: How to Generate Unique Slugs for a Section without ticking "Entries in this section have their own URLs"

texts:
I am working on a site that has an events calendar with Future, Current and Expired events being shown. Which is completely fine when I am on the index page and have "Entries in this section have their own URLs" checked for that section. The problem I run into then is that the permalink page will only show entries that the are live. Pending and Expired entries will never be shown (As mentioned in this questions and answer).

We have a lot of events that have similar or the same name that happen on a weekly or monthly basis. For example "Live Music at Blue Skies Winery" produces a slug of "ive-music-at-blue-skies-winery" when I had Entries in this section have their own URLs it would increment the slug like live-music-at-blue-skies-winery1 and the next one would be live-music-at-blue-skies-winery2.

So as a result I have disabled it for my event section but as a result now entries with the same title have the same slug of live-music-at-blue-skies-winery without being incremented.

Is there a way to force the slugs to be unique either by incrementing the slug like happens when I have Entries in this section have their own URLs checked or is it possible to prepend the entry date 03-01-2015 to the slug name?


texts: How do I limit entries retrieved except those with a sticky lightswitch on the entry?

texts:
I have a list of "meetings" as entries and I want to show only the last two ordered by meetingDate, and show any other meetings marked as sticky, without doubling up.

What I have so far is:

{% set stuck = craft.entries.section('meetings').relatedTo(subcategory).sticky('1').order('meetingDate desc').find() %}
{% set entries = craft.entries.section('meetings').relatedTo(subcategory).order('meetingDate desc').limit(2).find() %}
{% set entries = entries|merge(stuck) %}

Now this works except that if an entry marked as Sticky is one of the first two, then it shows twice. I understand it is bad practice to try and manipulate data using Twig, and that rather I should aim on getting the right data out of the entries first up.


texts: How do you reset a cart under Craft Commerce 2?

texts:
How do you reset or empty the cart, in Commerce 2? There is no mention of this in the documentation.

In Commerce 1, it was possible to issue a request to the commerce/cart/removeAllLineItems action to clear the cart, but this no longer works.


texts: I am using Solspace Calendar plugin where front end user can add/edit events. Is there any functionality so that user can delete an event from front-end?


texts: Image transformation of tif image does not work

texts:
I use craft transformations for resizing images. The transformation of jpg files works as exepted, but the transformation of a tif image does not work. Imagick is installed and in the backend it creats and shows thumbnails of the images. When i rename the image from .tif to .jpg it performs the transformation also.

The Twig code looks like this:

The output HTML Code of a tif image looks like this:

The output HTML Code of a jpg image looks like this:

Is this a bug or have i missed a config setting?

Here are some images for explanation:


texts:
I have two Craft websites running locally and they both have broken css on the backend due to the error below. Every time I update it is temporarily fixed but after a few clicks or refreshes it's back again. I've checked the permissions but the problem seems to be the location of the file.

Error: File to import not found or unreadable: ../../../../../lib/craftcms-sass/mixins

When opening the dashboard.scss I can see the path is incorrect but I'm very unsure what the proper path should be, and whether I should manually change it.

Is this a known problem? I hope someone here can help me out!


texts:
I've set up a site with SSL, and finally got everything to load over https as well in the CP. But now I'm getting an error when trying to log in. When I look at the logs it says that the username cannot be blank. Which is weird, since I filled it out.

I'm also seeing the insecure symbol on the login button. But not sure why it's there.


texts: How to restrict uploads to currently edited site

texts:
I've tried

/{{currentSite.handle}}/

but this uses current site handle, not the site I'm currently editing. Is there a way to dynamically set folder to currently edited site?


texts: Does Craft commerce support multiple delivery addresses / shipments on same order?

texts:
we have an ecommerce customer in the gifts market who currently have a custom built ecommerce website. Their USP is that you can order gifts for all your friends and family at once and they will be sent to different addresses on the right days throughout the year.

We are looking at moving them to Craft Commerce. Does anyone know if Craft supports multiple shipment addresses on the same order or any way this could work?

Thank you!


texts:
HTML Purifier is deleting a custom link attribute. As I understand the HTML Purifier docs, it should be possible to customize it to allow a defined attribute. Is there in Craft CMS a defined way for doing such a customizing (like the Redactor configuration)?

Thank you very much for your help!

Edit: Would probably possible in "RichTextFieldType.php" (Line 205ff)?


texts:
We're receiving the following error when uploading Assets:

  Upload failed for Michael-Mabry-COO-MOOYAH-executive.png. The error
  message was: “Error uploading the file: The file
  “/nfs/c12/h03/mnt/215595/domains/mooyah.com/html/craft/storage/runtime/temp/assets57c97ea812e213.88692692.png”
  does not appear to be an image.”

I assumed this was a case of the client formatting the images incorrectly, but I tried it myself and they are valid image files.

Anyone come across this before?


texts: What would be the best way of finding a sectionId by its slug within my plugin?


texts: Enupal Snapshot plugin on local windows environment - can't save path

texts:
Craft 3.3.20.1, Enupal Snapshot 1.2.7

Works on dev/live server but local can't find path to bins.

Downloaded MXE (MinGW-w64) from https://wkhtmltopdf.org/downloads.html and put in local working directory.

Tried D:\project\enupal-snapshot\wkhtmltox\bin\wkhtmltopdf.exe, without .exe and with slashes going the other way to be more unix-y.

Do I need to do something with the installer? Is the archive enough?


texts:
I've tried creating a contactform.php file with the P&T Contact Form plugin and using the code in the documentation to be able to programmatically add recipients. However, when I use this code:

<?php
    namespace Craft;

    $toEmail = craft()->request->getPost('toEmail');
    $toEmail = craft()->security->validateData($toEmail);

    return array(
        'toEmail' => ($toEmail ?: null),
        ...
    );

I end up getting a white screen of death and a 500 Internal Server Error. I don't know why it's doing this, I tried editing the permissions of my craft folder and the contactform.php file, but nothing has worked and I keep getting a white screen.

How can I fix this?
Thanks!


texts: Display tag related to entry in current locale

texts:
I've got this code snippet I'm working with and I can't get tags pulled out for related entry in current locale.

Maybe worth to mention, that tags is matrix field.

  {% set entries = craft.entries %}

  {% for entry in entries %}

{{ entry.title }}

  {% for tag in craft.tags.relatedTo({
          sourceElement: entries,
          sourceLocale: craft.locale
  }) %}

     { tag.title }}

     {% else %}

     No tags found

     {% endfor %}
     {% endfor %}


texts:
I have the following code where I'm pulling entries related to another entry which works fine. However I also want to limit the entries returned on a category page and thus am merging in a relatedTo: category

However on the category page it is returning all entries related to that category, not limited to the category AND the related entry

{% set myStation = getCookie('myStation') %}
{% set relatedStation = craft.entries.id(myStation) %}

{# set pagination/categories #}
{% set params = { section: 'blog', limit: 6, offset: 1, relatedTo: relatedStation } %}
{% if category is defined %}
  {% set params = params | merge({ relatedTo: category }) %}
{% endif %}

{% set entries = craft.entries(params) %}
{% paginate entries as pageInfo, pageEntries %}

I see the docs includes 'and' (bottom of the page) but I'm not sure how to get that in there using merge. Please advise.


texts: No assets found when searching in different locale

texts:
At the moment I'm working on my first Craft CMS project. There I have two different locales that share the same assets folder.

The assets can be seen and used between the different locales but when I try to search I only get results in one locale. This is strange because they show up in the full list when selecting that locale.

Any tips? Did I miss a certain setting?


texts: Session key not timing out when set in a plugin

texts:
Here's some relevant detail from my config file:

    'rememberUsernameDuration' => false,
    'rememberedUserSessionDuration' => false,
    'userSessionDuration' => 'PT30S'

I'm expecting to see sessions timing out after 30 seconds but they don't seem to be, and if I remove that they are still valid beyond the default time.

Now, one thing I'm doing is setting a session directly in a plugin:

craft()->httpSession->add('myKey', 'myData');

And retrieving:

craft()->httpSession->get('myKey');

Am I missing something here? The config file definitely affects the Craft CMS login session as with the config above I get constant warnings to keep my session open in the CMS.


texts:
I am considering using Craft to develop a website for a client.
One of the requirements is that members have access tot he backend to edit a single entry.

Here is the use case:

entry is created manually by admins, unpublished
members are in a group with "editEntries:[SectionID]" permission only (no create, delete and others)
members edit their entry and submit for review/approval
admins publish the entry
members come back and edit the entry if necessary and submit for review/approval of changes
admin reviews changes and amend or approves the changes

The question is what would be the best way to achieve the following:

When a member comes back, edits and submits the entry (step 5), it create a new revision for review/approval by admins (step 6), but keeps the current revision published in the frontend.

Any thoughts on how to achieve this?


texts:
I have set up a structure that allows me to display events with some information.  I'd like to know if there's a way that I can set a date that will automatically change certain  it's a text from being future tense to be in present tense during the event and past tense after the event i.e.  I'll be, I am, I was.

Thanks to everyone in advance!


texts: I'm working on a new build of a site with a new database, I think that copying the plugin folder will not carry over the analytics statistics, are there database entries that I need to copy over?


texts: Craft 3 Multi Site - Have a related entries field relate to another site, but respect localization

texts:
I am trying build a hub of sorts using Craft 3. I want the main site to be the hub which manages most of the data, and then subsequent sites are built on top of that, relating where necessary so as to normalize the core data. I do NOT want the entries to propagate from the core site to the sub sites. I want them to only exist in the Core Site and be related to.

Here is the basic site structure:

Core Site En (coresite.com)
Core Site Fr (coresite.com/fr)
Sub Site En (subsite.coresite.com)
Sub Site Fr (subsite.coresite.com/fr)

I then have an entry on Sub Site with a related Entries field. Since the entries do not propagate, when you try to select an entry, the list of options is empty. To fix this I check "Relate entries from a specific site?". The problem is I can only choose one site, forcing me to choose either the EN or FR version of the Core Site.

If I choose EN that works fine, but when I'm on Sub Site FR and access the related entry, it's in English and doesn't respect the translated version of it on Core Site FR.

This seems to be a big trade off in the decision to treat languages as sites.

Is there something I'm missing?


texts: Public profile page: requesting user ID with dynamic url routing

texts:
I've been referring to this question (can't comment as I don't have enough cred) — The most popular answer works, but I can't for the life of me figure out why Brad's version doesn't. When I try I get the following error:

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

{# Not Working (Brad's version) #}
{% set notWorkingUserId = craft.request.getSegment(2) %}
{% set notWorkingUser = craft.users.id(notWorkingUserId) %}

{# Working #}
{% set workingUser = craft.users.username( craft.request.segment(2) ).first() %}

{% block content %}

Not Working: {{ notWorkingUser.email }}

Working: {{ workingUser.email }}

    {{notWorkingUser}} {# Throws an error #}
    {{workingUser}}

{% endblock %}

I'm using the dynamic url routing mentioned in the most popular example, with the username. I also tried:

craft.users.username(notWorkingUserId)

Which throws the same error.

Now as far as I understand it (I've only been working with Craft for a short period), .first() is only required when it's an array. But Brad's version is passing the actual ID so shouldn't be required?

Can anyone explain this in simple terms? Craft is great, but for beginners it can get a bit confusing.


texts: Is there a way to speed up the CMS on UNIX server?

texts:
Just finished my first Craft CMS project. There have been some first hiccups but so far I've been really impressed!

There's one thing that I can't wrap my head around. It's a quite a massive website. This client wanted to be able to create different stories per project (loving the matrix here!!!) which got pretty large.

They're full of images and stuff but still the website is loading very quick. The only thing that feels slow (on and off) is the CMS itself. When looking at the different entries sometimes the system hangs and that's pure when looking at the overview of all the entries. Switching to a different entry type overview (page to structure for example) also feels sluggish.

Any tips how to speed things up? The site itself is perfect, it's just the CMS itself.

The server is running PHP 7.0 but has 128M. Not sure if upgrading it will give a performance boost to the CMS?


texts: Matrix-field with a category-field to output category-title on single entry page

texts:
Me and categories, always giving trouble :)

On blogs, we are using a matrix field and in one of the matrix-types, I have a category field.
This is to output the title of the category.

{% extends "matrix/default" %}
 {% block blockContent %}

    {% set merk = block.merkNaam %}
    {{ merk.title }}

{% endblock %}

The outcome is empty ...

What do I miss?


texts:
I'm trying to update an entry's field value from a Craft plugin. First I was trying to just update the attributes of the entry like so:

$entry->getContent()->setAttributes(array(
  'metaStatus' => 'Declined'
));

craft()->entries->saveEntry($entry);

But that wouldn't work because getContent doesn't return the data needed in order for the EntryModel to pass validation. The next solution was to loop through each of the fields and grab their field value like so:

$fields = array();

foreach($entry->getFieldLayout()->getFields() as $layout) {
  $handle = $layout->getField()->handle;

  $fields[$handle] = $entry->getFieldValue($handle);
}

$fields['metaStatus'] = 'Declined';

$entry->setContent($fields);

craft()->entries->saveEntry($entry); // FAIL

Now I'm having issues with matrix/asset fields validating since they come back as empty. Am I going to have to look for matrix/asset fields in my loop above and correctly format the data? There must be an easier way to do this.


texts: Get entries filtered by date fields, one of which might be empty (and paginate them)

texts:
I have an 'whatsOn' structure whose entries include two date fields: 'dateStart' and 'dateEnd'. The end date will be empty if the event is a one-dayer. I want to get all future events using the dateEnd (if not empty) or dateStart if not. So basically, all events that haven't ended yet. How do I add the 'dateEnd' bit to the following query:

{% set allEvents = craft.entries({
    section: 'whatsOn',
    limit: 20,
    level: 2,
    order: 'dateStart',
    dateStart: '>= ' ~ now
}) %}

Crucially, I'll be paginating them so I need this to return an ElementCriteriaModel, I can't just do the check inside a loop.

EDIT: I just noticed that date fields are just empty (not null/undefined) if you don't select or enter a date. Amended question to reflect this.


texts: Craft Commerce carts containing out-of-stock products

texts:
Customer 1 adds a product to their cart. Does not complete their order.
Customer 2 purchases the remaining stock of that product, completing their order.
Customer 1 returns to the store the next day, picking up where they left off.

What should happen in Craft Commerce? Will Customer 1 be allowed to purchase the now out-of-stock product?


texts: Generate previews of PDF files (Craft 3)

texts:
Is it possible to auto-generate PDF preview images with Craft 3 transforms?

Or are there any Craft 3 plugins that do this? I see a few Craft 2 versions.


texts: Solved: Unable to get composer running to install CraftCMS

texts:
for last weeks really I try to install composer, but it keeps complaining about SSL-problems. I searched everywhere on Google and found lots of people having the same problems, but for some reason they found solutions which don't work here.

I really need to install composer, 'cause I like to use Craft 3, but whatever I try, it's not working. There is no composer-forum, and I guess all you guys needed to use composer to install Craft 3 too, so I hope somebody here can help. I'm really out of ideas at the moment...

I tried this:

SETUP VIA WINDOWS INSTALLER

Download and run windows installer Composer 1.6.5: https://getcomposer.org/download/
I see the path is pointing to the right php.exe (and the same php I use on wamp server). I don't use a proxy.
Running composer after install shows me composer is installed.
Running composer diagnose however shows me a WARNING after https connectivity to packagist: The https://packagist.org/packages.json file could not be downloaded: SSL operation failed with code 1.
So in php I checked if php_openssl is enabled and it is.
I also have this in my php.ini file, pointing to a cacert.pem certificate, downloaded from http://curl.haxx.se/ca/cacert.pem :
openssl.cafile="C:\caCertificates\cacert.pem"
openssl.capath="C:\caCertificates\"
Running php --ini on cmdline I verified it's definitely the edited php.ini file that is active on command line/composer use (C:\wamp64\bin\php\php7.1.16)
I turned firewall off
I even uninstalled wamp-server with all php-stuff and installed a complete fresh, updated, install of Wamp server (3.1.3 64b)
But composer diagnose keeps throwing the warning, and composer is not working.

SETUP VIA PHP INSTALLER
Than I tried the php-install script I found on getcomposer.org and run this from command line:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
 - It returns with:
Installer verified. All settings correct for using Composer. Downloading...
Composer (version 1.6.5) successfully installed to: C:\proj-folder\test\composer.phar
 - But when I run composer diagnose in that test-folder it's still throwing the warning.

BTW I tried above with administrative rights too.

I understand this has something to do with SSLv3, but whatever I tried, nothing seems to fix the issue. And again I tried a lot of things that worked for other people having this issue.

I'm out of ideas and composer obviously is not really helpful in showing a clue to what's the problem here.

Is there anybody here that can help me with this, or give me some direction on where to look? This is taking a lot of time and effort last weeks without luck and I'd like to start building websites with Craft 3 using composer!! Thanks!


texts: Creating default object from empty value - Sprout Email

texts:
I've only recently started using Craft, so please excuse me if this is an obvious or silly question, but I've run into this problem when trying to create notifications on Sprout Emails (triggered by a Sprout Form).

The error is as follows:

PHP warning

Creating default object from empty value

/var/www/craft/plugins/sproutemail/services/SproutEmailService.php(506)

...
505         // Add a few additional variables to our info table
506         $event->params['variables']['info']->deliveryStatus = $deliveryStatus;
507         $event->params['variables']['info']->message        = $message;
...

I'm really not sure how to fix this - each form worked perfectly before, and it's only since I started using Sprout Email twenty minutes ago!

If I've not included enough code please tell me and I can include more!

Thank you


texts: How get the custom user fields in a plugin? I can get the normal fields like firstName like this craft()->userSession->user->firstName but how i can get a custom field i tried craft()->userSession->user->customfieldname but that doesn't work.


texts: Craft not generating language links correctly

texts:
{{siteUrl}}, {{category.url}}, {{product.url}}, etc. is not outputting any language.

The main language is Norwegian. I created a folder for English (/en/) with define('CRAFT_LOCALE', 'en_us');

Navigating to site.com/en works fine, and all the english content shows as expected. However any link generated by craft simply omits "/en/", thus throwing me back to Norwegian. I don't get it.

Anything in particular I should look into? Thanks a lot!


texts:
I'm trying to setup a product that has multiple variant groups that need to be simultaneously selectable and that have their own up-charges.

An example use-case: Say I have a digital product that I'm selling that has multiple license options as follows:

Standard vs Pro
Commercial vs Non-Commercial
License levels based on Users

Each of these items would need to be individually selectable, with appropriate up-charges.

Any ideas on how to approach this?

Thanks!


texts: Making an entry grid with Batch 2,3 (2 in row then 3 in row)

texts:
I'm trying to make a News item grid. I'm looking for a solution to output 2 type of "rows". One that shows 2 entries and the other shows 3 entries.
I tried playing around with batches already but can't really manage to get it working alright. Is batch the right filter to use? If not what should I try using?

It should look like this:

Twigless code looks like this:


texts: Point directly to a structure or channel with Entries field

texts:
I´m making a Slideshow section, where you create slides ( image, text.. ) and there is one field to specify where the slide links to. This link could be any section of the website. I use entries field to list all websites section, but I need to be able to point to structure or channel directly ( for example, I have a events channel and should be able to point directly to the events list instead of select one specific event).

Any help will be appreciated.


texts: Getting Store Currencies Using Element API and Craft 3

texts: How can I return the available store currencies using the Element API? I think it uses  craft\commerce\Plugin::getInstance()->getCurrencies();but unsure how to go about creating an endpoint for this?


texts:
I'm implementing a custom controller as part of a plugin I'm building. There's some set up work that I'd like to do in the controller's constructor. I created a __construct method, and it seems to work as expected.

My question: Is there some reason that I should call parent::__construct() inside of the constructor? It requires an argument, which looks like it should be an ID of some sort, but I'm not sure where I should get that.


texts:
Does Craft have an answer to ExpressionEngine's {switch} tag?

{switch="classOne|classTwo|classThree"}


texts: Cannot post data to a plugin controller action

texts:
I have a form in one of my templates

 <form method="post" action="" accept-charset="UTF-8">
    <input type="hidden" name="action" value="paypalPayments/payment/pay">

     [...]
 </form>

I also created a simple plugin like so:

//PaypalPaymentsPlugin.php
 <?php
 namespace Craft;
 class PaypalPaymentsPlugin extends BasePlugin {

    function getName() {
       return Craft::t('Paypal Payments');
     }

     function getVersion() {
       return '1.0';
     }

     function getDeveloper() {
       return 'Paul Timoce';
     }

     function getDeveloperUrl() {
       return "http://paultimoce.net";
     }
 }

And also a controller file inside a controller folder:

 //File PaypalPayments_PaymentController.php
 <?php

   namespace Craft;

   class PaypalPayments_PaymentController extends BaseController {

     public function actionPayWithPaypal()
     {
        echo "I'm in...";
     }
   }

All I want to do is post some variables through my form and process them with my plugin controller but every time I submit my form I hit the 404 page...

Do you guys have any idea as to why this is happening? I also installed and activated the sample cocktailRecipes plugin trying to do the same thing but unsuccessfully also... I tried to point my browser to /actions/paypalPayments/payment/pay and /actions/cocktailRecipes/ingredients/saveIngredient but also no luck... I always get redirected to the 404 page.

Can you help?


texts:
The list of entries I need to grab is available here:

http://arcresources.mediaroom.com/api/newsfeed_releases/list.php?format=json

Each individual entry is available at a unique URL, by adding an ID, like so:

http://arcresources.mediaroom.com/api/newsfeed_releases/get.php?format=json?id=n

Is there some way to get FeedMe to create entries for every ID from the list URL, using the get URL?


texts: Altering Structure order doesn't update cache

texts:
I have 2 structures that are used for Menus on the site. Each entry is a link to either an entry / asset or external URL. The hierarchy is used to generate a menu .

To save on page load time, the two menus are both wrapped up in {% cache globally %} tags which has worked really well to speed up things.

My problem is that when altering the position / hierarchy of the structure entries from Craft, the front-end doesn't update accordingly which I can only put down to the cache blocking the update, as the structure isn't re-triggering the cache update.

Any tips for long term maintenance on this site feature? Some of the content editors will want to alter this stuff, but without disabling the cache myself? The only user that can manually flush the template cache is myself, the admin.

Thanks in advance y'all!

Merry Christmas! :-)


texts: With a categories field, how do I query only the *selected* categories?

texts:
Suppose we have a category group that allows for any number of levels to its structure. We also have a category field that allows for choosing any number of categories from that group.

In our example, we want to select three categories: one is a level 1 category in that group, another is a direct child of a different level 1 category and the third is a level 4 category from another branch in the category group (all three are in different branches for this example).

The question is: How do we query the category field to only return the categories we selected—the categories we actually clicked on when selecting categories? (Craft 3)


texts:
I am trying to achieve the following markup for my categories navigation:

Top Category One

Sub Category One A

Sub Category One B

Sub Category One C

Top Category Two

Sub Category Two A

Sub Category Two B

Sub Category Two C

If have the following code which is nearly working:

{% set categories = craft.categories.group('projectType').all() %}
{% for category in categories %}
  {% if category.level == 1 %}

{{ category.title }}

  {% endif %}
  {% if category.level == 2 %}

{{ category.title }}

  {% endif %}
{% endfor %}

I am just missing the wrapping
 tags around the subcategory list items. Is there a way I can achieve this? The category group is limited to 2 levels so I can use the category.level if statements without a problem.

Thanks for any pointers!


texts:
I have a live entry with an 'eventTime' text field having the content '2pm'.

I also have an unpublished draft saved for that same entry with the 'eventTime' field having the content '3pm'.

I use the following code in my front end template to retrieve the draft for the entry:

{% set entry = craft.entries.section('events').type('ofs').status(null).limit(1).first() %}
{% if entry and entry.enabled %}
    {% set drafts = craft.entryRevisions.getDraftsByEntryId(entry.id) %}
    {% if drafts %}
        {% set entry = drafts[0] %}
    {% endif %}
{% endif %}

Yet the following tag in my template:

{{ entry.eventTime }}

Always displays '2pm' - even though I know the draft is being loaded, as:

{{ entry.draftId }}

Outputs the correct draft ID value.

How do I get it to display '3pm' - i.e. the correct content for the draft being loaded? I've noticed that draft data is stored differently in the database (shoved into a field called 'data' in the 'craft_entryDrafts' table). How do I get at it?


texts: Is there a way to prevent uploading assets into a parent level folder?

texts:
Say that I have a folder structure like this:

/images
  /products
  /employee-photos
  /user-photos
  /advertising

Is there a way that I could define the single asset source of /images while only allowing uploads to its children?

I would like to do this so that I could simply add new children w/o having to define them as assets sources separately.


texts: Freeform - disable success flash message

texts: Does anyone knows how to DISABLE flash messages of freeform plugin for specific form? I have ajax form, but i dont use freeform JS, u use my own script. After form is submitted, and later page is refreshed, flash messages appears.


texts: FeedMe - all sites get overwritten by other foreign sites import, even though fields are translatable per group

texts:
I have about 16 sites added to my Craft CMS install. They are grouped together by language, so for example, I have 6 sites in English, and 4 sites in Spanish, 2 in German, and then some individual ones.

I have set the Sections to "Propagate entries across all enabled sites?" because when we create a new site, or a new entry, say in Spanish, we would want all the same pages created and connected to other pages in other sites, and would be expecting the pages to be in the language of the group the site was in.

I have a matrix field in which I have set some fields to translate per site group, and others to be not-translatable.

If I import the main US site first, it goes well, then if I import say German next, it seems all sites content is updated to German. but all other sites are in a different group.

I am sure I did not have this issue before when importing.

Editing and saving an entry in German does not then change the US, so its just when importing.

I have previously read when importing Matrix it does not update fields within it, but deletes it and re-creates it. So is it doing this on all sites?

How can one set the main matrix field to be translatable per group so it does not get touched in other groups? The only option is "Manage blocks on a per-site basis" which we would not want, as it needs to be the same per group. I assume there should be a field "Manage blocks on a per-group basis"?

Thanks


texts: How to configure Craft From for a form roulet/carousel?

texts:
I'm making a website where the 1st submit of the form needs to be sent to 6 people on a list, the second submit of that same form needs to be send to the next 6 persons on the list, and so on.

I also would like to store the number of form submits every person in the list has received.

I was wondering if this is feasible with the Contact Form plugin.


texts: Has anyone out there found a way to do a fuzzy search in the Asset Library? Currently, search only seems to return results that match the exact search query. Any help or plugin link is greatly apprecitated!


texts:
Craft 101: I have entries with many different fields, so I'm doing something like this:

{% set var = craft.entries.section('foo').slug('bar').first() %}

{% if var %}
  {{ var.field1 }}
  {{ var.field2 }}
  {{ var.field3 }}
  etc...
{% endif %}

Does Craft fetch the entry only once or every time the variable is called? I'm guessing only once but I'm not too sure, and some entries have 50+ fields.


texts: How to remove relationships between entries

texts:
I have a channel called 'Activities' and a channel called 'Members'.
In 'Activities' I have a field called 'Accepted'. I want to be able to add and remove 'Members' to the field 'Accepted'.
I want to do this in a plugin that I am building. Is there a method to add or delete a single 'Member' to the 'Accepted' field of an 'Activity'?
Basically is should remove the relationship between the Activity and the Member, but it should not remove the Member itself.


texts:
I have a site where I need to paginate and filter a list of businesses by different criteria. In the business entry, I’m using the Reasons plugin tied to about 8 different lightswitches which, when activated, reveal different inputs that can be modified. For example, if it’s a restaurant, turning that lightswitch on reveals a toggle for if it’s local, and a channel of different types of restaurants to choose from. That business might also be a venue to host events, so activate Venue and you get a table input to add information about the rooms.

To view and sort all restaurants, In my template, I was pulling all businesses, looping through and if it’s a restaurant, create the list item. Filtering and pagination were then being handled by list.js. This allowed me to have two dropdowns — one for neighborhood and one for restaurant type. Simply select “Thai” and "Downtown" and the list updated instantly.

It all worked great when there were just a few items in the list. Now there are close to 500 businesses total and about 250 that are classified as restaurants. When I pull then entries, if there are north of 150 results that need to be listed, the page just becomes unresponsive.

I changed the way I was pulling the entries from pulling businesses and then filtering, to sending search criteria in the request, but that didn’t seem to help. The bottleneck seems to be in processing the list data and creating the list items to be paginated and searched. If I just list out the entry.title, it takes a bit but it works. If I  add the filtering data attributes, phone, address, etc to the list items, it chokes.

Is there is a way to have live sorting on a page with a large dataset? I’d like to avoid page refreshes if possible. Perhaps pull json data, sort, and then just display the items that need to be rendered on the screen? I’m having trouble finding examples for alternate filtering methods for Craft.

Thanks.


texts:
I'm using Craft with Gatsby. I'd like to query a featuredpost, and filter that in my entries.
I'm getting the featuredPost slug in gatsby-node, and passing that to createPage, to send a variable to my index template.
In the index template, I want to to filter my entries and remove that slug.


texts: Plugin development : from ExpressionEngine to Craft

texts:
Coming to Craft after years with EE, I feel like a newbie again.

I painfully managed to built and install a basic plugin for craft3 with composer, (with a little help from the docs and NYstudio107's tutorial).

For now, the plugin does nothing, and to keep going, I would need to understand how to translate a pattern commonly used in EE.
Get some data from a template, process it and return it.

Get tag data and parameters

$data_to_process = ee()->TMPL->tagdata;
$process_param = ee()->TMPL->fetch_param('parameter');

Output content to template

ee()->return_data = $processed_data;

Ho do you do such things in craft ?


texts: Charge: Update subscription card details

texts:
I am attempting to create a form where the user can update their subscription card details (with Stripe Elements).

From looking at the Charge plugin's source code, I believe the endpoint I need is charge/updateSubscription.

As with checkout I am creating an opts hidden input in my twig template like so:

{{
  craft.charge.setPaymentOptions({
    planAmount: currentSubscription.planAmount,
    planInterval: currentSubscription.planInterval,
    planIntervalCount: currentSubscription.planIntervalCount
  })
}}

And then making a POST request with Javascript to the endpoint:

getStripeToken(cardToken => {
  post({
    params: {
      action: 'charge/updateSubscription',
      opts,
      cardToken,
      subscriptionId
    },
    then: response => console.log(response)
    url: '/'
  })
})

Quite simply, this doesn't work. I receive a {success: true} response, but the Stripe card has not been updated.

Does anybody what I'm doing wrong, or even if this is possible?


texts: Craft 2 - Adding custom CSS classes to Sprout Form fields on a global basis

texts:
I'm reading the docs for the Sprout Form plugin and looking at how I can custom classes to the actual form elements i.e. <input>, <select> etc. I can see that there is the rendering options route, but I was hoping to achieve this on a global basis, rather than having to reference individual field handles due to multiple forms. I can add some custom classes through the custom template method, but it still doesn't give you full access to the actual form elements themselves.

I have form styling already, but it relies on CSS classes on the relative form elements, I can add CSS rules that also target the Sprout Forms HTML but I'd rather keep the class stuff consistent.

Would I need to write my own plugin for this? I've looked at the API and while it shows how to hook into the various field types. All seem to require using $renderingOptions. It looks like I could achieve this if I was outputting each field with displayField() manually, but I'm attempting to make this as user friendly as possible and trying to keep it in templates.

Because its Craft 2, I don't believe I can individually override any of the field types with my templates/_sproutforms/ folder, though in Craft 3 this does appear possible.

If I was just to write my own plugin that hooked into the various fields such as SproutFormsPlainTextField and added my own CSS class(es), would this be the best way? Testing this out, I modified the SproutFormsPlainTextField.php within the integrations folder at sproutforms\integrations\sproutforms\fields and added my own array for the class and it does work, but I'd imagine I'd need to do this as my own plugin, rather than modifying sproutforms directly. What's the best way to achieve this?

<?php
namespace Craft;

/**
 * Class SproutFormsPlainTextField
 *
 * @package Craft
 */
class SproutFormsPlainTextField extends SproutFormsBaseField
{
    /**
     * @return string
     */
    public function getType()
    {
        return 'PlainText';
    }

    /**
     * @param FieldModel $field
     * @param mixed      $value
     * @param array      $settings
     * @param array      $renderingOptions
     *
     * @return \Twig_Markup
     */
    public function getInputHtml($field, $value, $settings, array $renderingOptions = null)
    {
        // My own CSS classes required for CSS styling
        $renderingOptions = array(
            'class' => 'input text'
        );

        $this->beginRendering();

        $rendered = craft()->templates->render(
            'plaintext/input',
            array(
                'name'             => $field->handle,
                'value'            => $value,
                'field'            => $field,
                'settings'         => $settings,
                'renderingOptions' => $renderingOptions
            )
        );

        $this->endRendering();

        return TemplateHelper::getRaw($rendered);
    }

    /**
     * @return string
     */
    public function getTemplatesPath()
    {
        return craft()->path->getPluginsPath() . 'sproutforms/templates/_components/fields/';
    }
}

Would this be the best way?