billythekid
  • Member for 7 years, 7 months
  • Last seen more than a month ago
Live Preview not working
6 votes

Another cause of Live Preview not working that can be a pain to debug, because there are no 'errors' as such is your .htaccess setup. For example, on one site we had the following .htaccess entry to ...

View answer
Activate Users - privilege
4 votes

I realise this is an old post but I wrote a plugin to handle exactly this, putting this as an answer instead of a comment since OP asks if there's an override: https://github.com/billythekid/...

View answer
How can I tell if a variable is an array or an entry/element query?
3 votes

you can use the instance of twig test here. You want to flip your logic, so test for Query object first else array stuff but this should work I think. To get the specific class just {% dd props....

View answer
Get entries related to tags with a score & order by
3 votes

You can add custom properties to elements using behaviors. In this case you want to add your 'getSearchScore()' logic. Here's a good article on how behaviors work in Craft CMS and a current PR on the ...

View answer
Custom navigation URLs?
3 votes

I think you're looking for entry types - when you open a new 'services' entry you could pick from "service" or "service-information" entry types. Each entry type has it's own field layouts. This ...

View answer
Matrix field alternative (or easier field grouping)
3 votes

Depending on the amount of data required (and if it makes logical sense to have the data separate from the entry) I'd probably set this up as a "Contact details" section itself, using the individual ...

View answer
No ordinary news post ordering
3 votes

I think I'd create a twig function or filter to create a custom sort (usort in php), pass the collection to the function so it's returned 'sorted'. Would be interested in seeing if anyone has a nice ...

View answer
Conditional for specific page
Accepted answer
2 votes

You could use either | last filter instead of first or, a combination of first and another conditional ( segments[1] is empty or similar)? {% set segments = craft.app.request.segments %} {% if ...

View answer
How to create a new Entry model in Craft 3?
2 votes

Just so there's an answer here. OP was using Craft 2 code in a Craft 3 environment. The code should be something like this in Craft 3: $entry = new Entry(); $entry->sectionId = $yourSectionId; $...

View answer
How to add content to pages using a plugin?
1 votes

You should be able to listen for the before render event on the view class.

View answer
Show only products in stock - one variant only
Accepted answer
1 votes

You're always using variants. Just that if you have no 'other' variants commerce hides that stuff away. But your product has a defaultVariant behind the scenes. Adding… .hasVariant({ hasStock: true }...

View answer
Global Site Variables (Static Page?)
Accepted answer
1 votes

Define "best". It's one way of doing it but has a couple of issues. They need to log in to see this (I presume, otherwise one issue is that there are public facing things on the website no actual ...

View answer
Search results home page title not showing properly but other pages do?
1 votes

Could the Google account holder for the domain have set the listing to use a different value than what's in the title element? Craft doesn't do anything like this out of the box and the SEO plugins ...

View answer
Encoding special characters even with the raw filter due to include
1 votes

As mentioned in the Discord you are probably looking for the source function. The reason the include doesn't work is covered in the old PR for (what eventually became) source. It's probably best I ...

View answer
Order grouped results by dropdown order
1 votes

You could wrap this in another for loop and put a condition on the inner fors, something like {% for option in myPositionDropdown %} <h2>{{ option.value }}</h2> {% for position, ...

View answer
FreeForm and Vue - Hidden Forms in Modal - Manually refresh the Craft CRSF token and Freeform JS Honeypot field
1 votes

Not sure if it's a good call or not but you could have an endpoint that just has the {{ craft.app.request.csrfToken }} outputting on it. Poll(GET) that using ajax (axios or whatever you're using in ...

View answer
Cart completed at gateway redirect issue
Accepted answer
1 votes

Just to update this with an answer, thanks very much to P&T's excellent dev team. The model implementing RequestResponseInterface returned from the gateway's authorize() method isSuccessful() ...

View answer
Add a user to a userfield when there's a pending user on there
Accepted answer
1 votes

To mark this as answered, my solution was to use this code to get the current employee IDs regardless of status. $employees = $currentUser->employees->status('*')->ids();

View answer
Frontend form to change Craft Commerce user's password?
-1 votes

I raised a PR for this last week but it was closed. Apparently you're not supposed to load those templates from the front end as those variables are not auto-populated by craft. (This code fixes the ...

View answer