Hot answers tagged

11

That's what you are after: startDateTime : 'and', '>= ' ~ now, '<= ' ~ now | date_modify('+5 days')


5

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 checking the old ExpressionEngine database to see if the user exists there, and if so, it could hash up the password in the same way EE does it, and see if it ...


4

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 Craft; class YourPluginNameVariable { public function makeHash($string) { $hashed = md5($string); return $hashed; } } You can call ...


4

Give this a shot: {% set cacheTime = sidebarBlock.twitterFeedCacheTime.value %}


4

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 unknown. Adding a custom password column to the database is a bad idea, since Craft user/password management is pretty deeply embedded within the system. Here's ...


3

<input type="hidden" name="foo" value="{{ 'bar'|hash }}"> and then in your controller: if (($foo = craft()->request->getPost('foo')) !== null) { $foo = craft()->security->validateData($foo); } at which point $foo will either be null (not present), false (present but tampered with), or a string (present and valid)


3

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 a native user, it tries authenticating a legacy user using the legacy system's particular hashing method. You could add another driver by copying the existing ...


2

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 POST with craft()->request->getPost('password'). Your plugin would have a record that has two columns. One is the SHA1 hash from the old system and the ...


2

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

For the hash key to be dynamic, you must wrap it in parentheses: (i): {


2

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 redirect back to the Set Password screen with the reset token, resulting in the error. I just adjusted the conditional so it ignored the referrer URL if it was ...


2

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 not a simple string, it's a great big object. buttonText[block.type.handle]


2

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 myHash = myHash|merge({ (eId) : { intro : value } }) %} {% endfor %} Now the hash stores the custom key as a string… array(10) { ["e1234"]=...


1

Thanks @james smith, that did the trick! Revised code: {% set buttonText = { "video" : "Watch the Video", "podcast" : "Listen Now", "externalLink" : "Visit Site", } %} {# resource is a Matrix fieldtye #} {% set resources = entry.resource.all() %} {% for block in ...


1

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 %} <span class="{{ key }}">{{ value }}</span> {% endfor %}


1

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 the time it is submitted and the time that it hits Craft. Contact Form cares about this so malicious people/scripts don't turn your Craft install into an email ...


1

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 updating your composer file and adding hashids to it.


1

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 javascript, css or an image resource. // src/Twig/appExtension.php namespace App\Twig; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; class ...


Only top voted, non community-wiki answers of a minimum length are eligible