Hot answers tagged

8

I think you want this: {% set success = craft.request.getPost('test') %} {% if success %}form was just submitted{% endif %} Pass a string to getPost()


5

If you just want to test if something is in POST, and don't care what it is, then this should work: {% set success = craft.request.getPost() | length %} {% if success %} form was just submitted {% endif %}


4

I'd split the parameter string into an array and then loop through the categories and use a conditional to check if the value already exists in the parameter. It's not so easy to describe in detail, that's why I added lots of comments to the code (untested!). To work in your other parameters (size, etc.), simply add them to your links exactly how craft....


4

TL;DR: Turns out this was an issue with my apache config on the Craft instance. Explanation: I did a little digging around the GuestEntriesController.php file and noticed that Craft was not picking up that my POST was coming from an ajax request. After looking into that more I manually added the ajax header to my post request: $.ajax({ url: config....


3

I think you could also use Twig's join filter instead of the for loop: {{ object.category | join('/') }}


2

When you use the single brace tag syntax within your URL Format field: {category.first().title} that’s actually a shortcut for this: {{ object.category.first().title }} So, object is the actual variable name that you can use to refer to your entry, when you want to use the normal Twig tags {{ ... }} and {% ... %}. {% for categoryList in object.category %...


2

I've managed to fix the issue. Originally I was converting the Blob to a File, but this was causing the upload to silently fail. So, when Craft tried to create the relation between the asset field and the image, it threw the error above. Now, instead of converting to a file, I'm leaving the Blob as is but adding additional metadata (Last modified data & ...


2

If you're using phpmail or sendmail under Settings->Email in the control panel, they are notoriously unreliable at delivering emails consistently. Try using a proper SMTP relay or a transactional email provider like Mandrill.


2

Form elements need to have a name attribute. <select name="submission" id="submission"> <option value="view">View</option> <option value="submit">Submit</option> </select> <textarea name="content" rows="9" cols="80" id="content"></textarea> That should do the trick!


2

You would need to set this up using a plugin. The plugin would, at a minimum, contain a controller, with an 'action' method designed to handle the url request and generate an entry; using 'post' or 'get' to pass parameters to the controller action. public function actionAddEntry() { // retrieve parameters $title = craft()->request->...


2

By putting the webhook URL in the action field, you're completely bypassing the Contact Form's processing of the POST request and getting back a JSON response from Zapier. I believe the correct way to do this would be to write your own custom Craft plugin that listens to Contact Form's beforeSend event. When that event gets fired, you can make an AJAX ...


2

Hyperlink styles are defined in you stylesheet (CSS). Applying the underline text-decoration property like so: text-decoration: underline;


2

If you don't want to get into plugin controllers and actions you can replicate this format here: https://craftcms.com/docs/templating/entry-form And trick Craft into believing your data comes from an entry form.


2

I believe you are overwriting the log variable you are sending back to the template when you set log equal to the response of getPost. From what I can see of your code, when you return variables to your template via setRouteVariables, you should be providing the variables you define in that array to your template, without having to take a second step and ...


2

You'd normally use a front-end form to create users on a Craft site. You can add fields to this form to submit more than the standard set of fields. I believe you could use the same form within your Express app. You are just sending the data via a POST request. Check the documentation for an example.


2

It is to generate an HTML input tag with type of hidden. This will not appear on the screen like a normal input does. For more information related to input type hidden, you can refer to this. enabled means that the entry will be saved with its status toggle set to the “enabled” (green) position.


1

You're close. Just a couple minor syntax things: remove the colon (:) before :data-fileID $.post has 4 parameters, the dataType (in this case 'json') goes as the last parameter. Set the url parameter to the action. This worked for me: <div class="deleteAsset" data-fileID="20031">Delete</div> <script> $('.deleteAsset').click(function() ...


1

This might not be the perfect solution, but I think it's the way craft itself handles it: I was recently digging through the edit template of the categories section. Craft has only one template here _edit, they therefore do the same thing as you want to: Use one template for both actions. In their template, they simply use a category object, either an empty ...


1

This may not be possible but can you not just make your form itself an include and have a "create" template and another "edit" template which have their own logic but include the same base form?


1

Although your question is lacking in detail, here is a shot at helping you track down the issue. The fact that GET requests are working but POST requests are not, your form is likely missing a CSRF token. You can add it to your form using the following twig code: <form method="post" action=""> {{ csrfInput() }} If your POST request is coming ...


1

I'm not exactly sure how this plugin works, but in general the best way to do this is to rely on Webhooks. You can listen for charge.succeeded events and send an email when those occur. If you're not a programmer, you can always use something like Zapier or IFTTT to do this too. :) Hope that helps!


1

Doing it through a plugin would be the easiest way. https://docs.craftcms.com/v3/extend/plugin-guide.html Your plugin would have a controller that the form would post to, then you'd grab the data from POST and do whatever you want with it. A good example of this you can look at is the Guest Entries plugin, that allows "anonymous" front-end entry ...


1

You can disable the token for a certain controller via use Craft; ... Yii::$app->controller->enableCsrfValidation = false; or inside a Controller for a certain request /** * @inheritdoc */ public function beforeAction($action) { if ($action->id == 'my-method') { $this->enableCsrfValidation = false; } return ...


1

Allright, after a lot of digging into my code I finally found out what went wrong. I used this code to clear the placeholder in my input when clicking inside them: $(".some-class input").val(""); But .some-class was the parent class of my form, which means I probably erased all values of hidden fields that Craft adds on runtime too. Fields such as <...


1

If you're looking for an "audit trail" of pages a user has visited, then a plugin will be the way to go. You'd want to track a user by something like their PHP session ID. And for every request grab that session ID and the URI and save that in a your plugin's dedicated audit table in the database (no need to use entries for this). When the user goes to ...


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