Questions tagged [request]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
33 views

Disable template cache globally based on condition

I'm looking for a way to disable the template cache ({% cache %} tags) for the entire request based on a specific condition (not just based on the current environment). In this case, the condition is ...
user avatar
  • 6,350
1 vote
1 answer
79 views

How does Craft CMS gets data from a 3rd part API?

I have an event page for viewing movies showtime and i want to connect to a 3rd party api to get the movie's info ( show time, cinema name,...etc ) how to do it? can i do this without having to create ...
user avatar
  • 115
0 votes
0 answers
48 views

Need help: multiple request throttling

I have an issue in the CraftCMS back office when I try to export all entries. When I try to export all the entries in expanded mode it takes ~1min but every minute the back office send another ...
user avatar
1 vote
1 answer
233 views

how to get request url?

I'm trying to get url from request, {{ craft.app.request.url }} but the uri is chinese, like "localhost/測試", it print out "http://localhost/����" did i miss some setting in craft ...
user avatar
  • 11
1 vote
2 answers
269 views

What is the best way to handle HTTP requests within a plugin using Yii or Craft?

I have a custom module which is moderating content before entry save, I am looking to use a Microsoft Azure API to handle the moderation, in their documentation they use a HTTP library to make the ...
user avatar
  • 419
1 vote
1 answer
53 views

Show a list of pages but hide the current page from the list

My setup I'd like to show a navigation menu listing all my page entries. In my layout file, I include a template for the navigation: _layout.twig: <main> <section id="nav"> ...
user avatar
  • 123
1 vote
1 answer
28 views

List products related to currently active category (url)

My URL: http://localhost/product-family/compressors How can I list the related products? I don't understand how to get access to the compressors (a category entry of the product-family category type)...
user avatar
  • 617
1 vote
0 answers
139 views

What's left to troubleshoot this quirky "Unable to verify your data submission" behavior?

I have a frontend login form that sends a request to Craft's own actions/users/login action. I've used this same process in another project and it works there, but not here, and I can't figure out ...
user avatar
1 vote
1 answer
690 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....
user avatar
1 vote
1 answer
1k 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 ...
user avatar
0 votes
1 answer
1k 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.....
user avatar
3 votes
2 answers
2k 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 ...
user avatar
  • 496
0 votes
1 answer
159 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 ...
user avatar
  • 1
1 vote
1 answer
335 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 ...
user avatar
  • 284
2 votes
1 answer
4k 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,...
user avatar
  • 960
1 vote
1 answer
112 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/...
user avatar
  • 213
1 vote
0 answers
169 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 "...
user avatar
  • 213
1 vote
1 answer
575 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 • ...
user avatar
2 votes
1 answer
1k views

Read POSTed JSON data from the request body

Is there a way with the request service to read POSTed JSON from php://input?
user avatar
  • 2,957
1 vote
1 answer
317 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 ...
user avatar
  • 543
0 votes
1 answer
433 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 ...
user avatar
2 votes
1 answer
876 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 ...
user avatar
  • 1,456
0 votes
1 answer
187 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' =&...
user avatar
  • 15
2 votes
1 answer
238 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 ...
user avatar
  • 3,061
1 vote
1 answer
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....
user avatar
2 votes
1 answer
168 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 ...
user avatar
2 votes
1 answer
124 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. ...
user avatar
  • 1,793
2 votes
1 answer
972 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' ...
user avatar
  • 865
4 votes
2 answers
2k 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 ...
user avatar
  • 4,519
0 votes
1 answer
210 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()...
user avatar
  • 1,215
2 votes
1 answer
3k 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 ...
user avatar
  • 231
1 vote
1 answer
473 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' %} {% ...
user avatar
3 votes
1 answer
936 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 ...
user avatar
  • 163
1 vote
1 answer
1k 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 ...
user avatar
2 votes
2 answers
7k 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 ...
user avatar
1 vote
1 answer
162 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 ...
user avatar
  • 865
1 vote
1 answer
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->...
user avatar
  • 1,503
4 votes
1 answer
536 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 ...
user avatar
  • 1,132
3 votes
1 answer
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.
user avatar
  • 674
3 votes
1 answer
3k 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 ...
user avatar
3 votes
1 answer
696 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 ...
user avatar
1 vote
2 answers
852 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->...
user avatar
  • 13.2k
4 votes
2 answers
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 ...
user avatar
  • 1,385