11
votes
Accepted
How can I use operators within Twig hashes?
That's what you are after:
startDateTime : 'and', '>= ' ~ now, '<= ' ~ now | date_modify('+5 days')
5
votes
Accepted
Importing members from EE without password reset
It would be possible to write a plugin that provides an alternative login controller action, based on UsersController::actionLogin(). The difference would be that, if normal login fails, it could try ...
4
votes
Accepted
Craft or Twig filter for MD5 or SHA3 hash creation?
sounds like a simple plugin will do the trick for you. You will need to set up your main plugin class and a variable class.
Your variable class will look something like this:
<?php
namespace ...
4
votes
Accepted
How can I convert a dropdown field value to an integer within a hash?
Give this a shot:
{% set cacheTime = sidebarBlock.twitterFeedCacheTime.value %}
4
votes
Accepted
How can I import existing users with passwords stored in a different format than Craft's hash format?
Short answer, it can't be done. Possibly with some extensive hacking, but I would highly caution against that.
Directly importing passwords isn't really possible, since the original passwords are ...
3
votes
Encrypt ID on front-end and decrypt on back-end
<input type="hidden" name="foo" value="{{ 'bar'|hash }}">
and then in your controller:
if (($foo = craft()->request->getPost('foo')) !== null)
{
$foo = craft()->security->...
3
votes
How can I import existing users with passwords stored in a different format than Craft's hash format?
The Legacy Login plugin handles authentication from legacy systems such as ExpressionEngine and BigCommerce. It works by intercepting the login, and if the given credentials fail to authenticate with ...
2
votes
How can I import existing users with passwords stored in a different format than Craft's hash format?
Your way sounds possible.
You'd need to write a Craft plugin that listened for the onBeforeLogin event. Only the username is passed in as a parameter, but you can grab the submitted password though ...
2
votes
Importing members from EE without password reset
Check out the Legacy Login plugin...
https://github.com/TopShelfCraft/Legacy-Login
It's designed to handle a migration of users between EE and Craft.
2
votes
Problem with data hash only storing last entry in loop
For the hash key to be dynamic, you must wrap it in parentheses:
(i): {
2
votes
Accepted
Getting "Invalid verification code." on password reset
In case anyone makes the same silly mistake I did, I had a conditional on the sign-in page that redirected folks to the page they were on before signing in.
After a password reset, it was trying to ...
2
votes
Accepted
Using a variable for a hash key
Your example isn't working because block.type is actually a shorthand for block.type.handle. Use the latter instead and it should work. You can tell this is the case by dumping out block.type - it's ...
2
votes
DOM hash url in entry slug
This is impossible (not only in Craft, but in general) because the fragment (hash, the part after the #) is only used on the client-side. This is by design, it's part of the spec that the fragment is ...
2
votes
Setting numerical key values in a hash
The answer is to prepend a letter to the numerical key…
{% for entry in entries %}
{% set eId = "e#{entry.id}" %} {# interpolation* #}
{% set value = entry.intro %}
{% set ...
1
vote
Using a variable for a hash key
Thanks @james smith, that did the trick!
Revised code:
{% set buttonText = {
"video" : "Watch the Video",
"podcast" : "Listen Now",
"...
1
vote
Get a hash’s key name
There's an example of this in the Twig documentation: https://twig.symfony.com/doc/3.x/tags/for.html#iterating-over-keys-and-values
In your example, it would be:
{% for key, value in hash %}
<...
1
vote
Accepted
How does "hash" work in the context of the Contact Form?
In the context of the Contact Form plugin, the |hash filter is only necessary if you want to dynamically add recipients to the submission.
It is there to ensure that data isn't tampered with between ...
1
vote
Encrypt ID on front-end and decrypt on back-end
I've used hashids successfully before, then create a small plugin helper with a twig filter that transforms the id into a hash that also decrypts it. you can include composer to craft plugins by just ...
1
vote
Craft or Twig filter for MD5 or SHA3 hash creation?
Hope this helps:
I needed a hash that only changed if the resource file is modified thus allowing reliable caching.
Usage:
<img src="{{ hash('/images/my_image.jpg') }}"
Can be used for ...
Only top scored, non community-wiki answers of a minimum length are eligible