Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [request]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
27 views

Calling Craft Console Commands from Plugin?

I am in the process of building a plugin that has a controller that accepts a HTTP request. If the token and request are valid, I would like to call a Craft Console Command from within the plugin (e.g....
0
votes
0answers
16 views

Calling unknown method: craft\console\Request::post() - Component.php: 300 When getting post variables using CLI

I have the following script which works fine when saving in the admin: /* * Update all slugs within the site group in case it changes */ Event::on( Elements::class,...
0
votes
0answers
19 views

Restricting Access Per User Posts

I'm looking to restrict access to users posts until another user follows for a development site I'm building out, but I can't get my head around how to sort the permissions. Here's the current ...
1
vote
1answer
185 views

How do I correctly send an external request to a module controller? runAction() is returning null

Craft 3.1.18 I have a simple controller VeteransController made using the updated Business Logic module. The purpose of this controller is to create a very simple endpoint for an external Vue ...
0
votes
1answer
505 views

craft 3 request

Can someone point me to the craft 3 docs where I can find informations about the request template function: craft.app.request.getSegment(2) I'm really struggling understanding the craft cms 3 docs.....
2
votes
1answer
522 views

From a Twig template, how to retrieve the content of a HTTP header in the current request?

I would like to detect if a header in the current request is present and obtain its value, directly within a Twig template. I know that craft.app.request gives access to a few variables like isAjax ...
0
votes
1answer
104 views

How should I fix an odd action URL? [closed]

I have a controller which is eventually going to be set up for POSTs and GETs, but the weird thing is I can only access it through localhost/index.php?p=actions/twoFA/get where twoFA is my plugin ...
1
vote
1answer
190 views

How to write a segment that is not two other segments

How can I write: is segment 3, and is not itemA and is not itemB? both itemA and itemB are segment 3 as well. {% if craft.app.request.getSegment(3) and craft.request.getSegment(3) !== 'itemA' and ...
2
votes
1answer
2k views

Set cookie and redirect back to referral URL

I'm setting up a site for a brewery that requires age verification. When a user visits the site, I check for the presence of a cookie (I'm using nystudio107's cookie plugin) and if it hasn't been set,...
1
vote
1answer
79 views

Use REQUEST variable as dynamic upload location

How can I use a request variable used in an upload form like this? <form method="post" accept-charset="UTF-8" enctype="multipart/form-data"> <input type="hidden" name="action" value="entries/...
1
vote
0answers
117 views

Submit Dropdown with ajax

This works for me, but i would like to solve this with ajax without reloading the page. Choosing the values from the Dropdowns and submit the data per POST Method, so i can return the value with "...
1
vote
1answer
456 views

How to get corresponding Post in Craft request?

I'm working on a Craft CMS plugin. I'm making a form that consists of multiple themes and questions. The structure is supposed to be as follows: • Form • Theme • Question • Question • ...
2
votes
1answer
857 views

Read POSTed JSON data from the request body

Is there a way with the request service to read POSTed JSON from php://input?
1
vote
1answer
180 views

Multiple dropdown filters interfering with each other

I have a multiple dropdown filters that lets users pick the category that they want to display results for below. See my previous question Search entries by location or name for screenshot. So I have ...
0
votes
1answer
300 views

CloudFlare Shared SSL certificate forbids CraftCMS control panel sign in

I am running a site using CraftCMS and have a shared CloudFlare SSL certificate in place. Based on my understanding, the content source (i.e. my website) is not safe, while the content delivered to ...
2
votes
1answer
604 views

Bad Request with weird params

I just installed Craft fresh, there's almost nothing in my DB as I'm just beginning to develop a plugin. All I want is to save a new entry from the frontend of my website. I've done this before in ...
0
votes
1answer
144 views

Force Download a file using an Ajax request or Task

The following code doesn't seem to work when called using an Ajax or Task but it does work otherwise: craft()->request->sendFile($file, IOHelper::getFileContents($file), array('forceDownload' =&...
2
votes
1answer
140 views

How can I force a request type (HttpRequestService::isCpRequest vs. HttpRequestService::isSiteRequest)?

Is there a way to force a request type (HttpRequestService::isCpRequest vs. HttpRequestService::isSiteRequest)? In my case I'm generating some indexing data on entries.onSaveEntry. I'm trying to use ...
1
vote
1answer
1k views

Ajax Function on a search form not working in Safari & IE

I made an ajax function so my page wont refresh and my search window wont disappear on form submit. It works fine in all browsers but it keeps refreshing on Safari. Here is my code: {% if not craft....
2
votes
1answer
131 views

Retrieving an entry based on the request URI in a plugin controller

I'm working a plugin and part of the task is to grab the entry based on the current URI using craft()->request->getRequestUri(). Is there a way to grab the entry based on the URI from the ...
2
votes
1answer
94 views

Spitting out the URL of the entry

Bear with me. Shortly changing a site to run over https vs http - the issue is though that we need to maintain the Facebook open graph share data. Facebook makes distinction between https and http. ...
2
votes
1answer
743 views

Empty .getParam() does not return an array with dump()

craft.request.getQuery() returns: array (size=5) 'tags' => string 'anxiety' (length=7) 'maxPrice' => string '' (length=0) 'sessions' => array (size=4) 0 => string 'email' ...
3
votes
1answer
1k views

Can you get the HTTP status code in twig templates?

I need a nice way to determine whether I'm on a 200 page. Basically anything other than a status page (404, 500, 403) in twig templates. I thought I could do something like craft.request.getStatus or ...
0
votes
1answer
171 views

Why does craft.request.getQueryStringWithoutPath return an empty string? [closed]

I'm trying to use craft.request.getQueryStringWithoutPath() to handle query strings on pagination, but for some reason it always seems to return an empty string. If I try craft.request.getQueryString()...
2
votes
1answer
2k views

Redirect user to the page they wanted after login

I have some pages that require login from the user. What I'd like is for the user to get redirected to the page that they wanted after they've logged in rather than sent to the page that they were on ...
1
vote
1answer
447 views

Twig's 'start with' conditional returns 500 error

The following is within the index template on a site in production: {% set domain = craft.request.getServerName() %} {% if domain starts with 'subdomain' %} {% include 'subdomain/index' %} {% ...
3
votes
1answer
828 views

Translated entry page can not be found (404)

I have installed and built a website using Craft CMS (with latest updates). I'm running this Craft installation on a Homestead virtual machine. When I enabled localization and translated entries in ...
1
vote
1answer
946 views

Plugin Controller Ajax Request

I've got a custom controller in my plugin that checks whether or not the request is ajax or not, using craft()->request->isAjaxRequest() In the event that it is, I just want it to return a ...
2
votes
2answers
5k views

Get query string param that has no value

Is it possible to determine whether or not a query string has a param with no value. For example http://www.test.com?myparam Technically that's a valid url but the craft.request object doesn't ...
1
vote
1answer
148 views

Public profile page: requesting user ID with dynamic url routing

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 ...
1
vote
1answer
1k views

Unable to retrieve a cookie set by another application on the same domain

We have a Laravel app that sets a cookie: public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true) { list($path, $domain) = $this->...
4
votes
1answer
513 views

How can I time-profile the page load for a Craft request?

I would like to see how long plugins take to load, as well as other aspects of the page (loops and database requests). My webpage can take ~2-3 seconds to return the initial request. It seems high ...
3
votes
1answer
2k views

Get parameters from referrer

Is there a way to get the parameters from the referrer url? I've tried this: {{ craft.request.urlReferrer.getQuery }} but that’s not working.
3
votes
1answer
2k views

Update and add POST URL parameters

How do you add extra parameters or update a parameter to an exiting POST URL? ADD EXTRA PARAMETER For example, I have a page at this address: http://localhost/shop/?color=red&order=title And ...
3
votes
1answer
618 views

Compose URL POST parameters to filter entries by category?

How do you update an URL with new params? I'm working on a search / filter entries page. I have multiple menu lists with categories in it. Like this: Size: Small Medium Large Color: Blue Red White ...
1
vote
2answers
699 views

Undefined property: Craft\WebApp::$request

What could cause Craft to not define the request object? I have a local site that recently stopped loading (front-end and back-end) The error is happening in WebApp.php (line 630) when $this->...
3
votes
2answers
2k views

Access POST data to conditionally display form

I'm working with the contact form plugin and would like to test for post data to see if the form was just submitted. It seems this code always throws a template error. Variable "test" does not exist ...