Questions tagged [request]
The request tag has no usage guidance.
45
questions
1
vote
1
answer
24
views
Is there a way to determine an element by its path or full url instead of the uri?
I'm using Craft in headless mode. It's a multisite setup different languages. I know that's it's possible to query an element by it's uri. Is there a way to check if a full path or an absolute url ...
0
votes
1
answer
122
views
request (Get and Post) problems
Craft 4. On environment=dev, it works just fine, but as soon as I set it to staging or Prod, any parameter passed either in url (get) or on the form (POST) can't be retrieve. The url shows the ...
2
votes
1
answer
144
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 ...
1
vote
1
answer
293
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 ...
0
votes
0
answers
70
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 ...
1
vote
1
answer
900
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 ...
1
vote
2
answers
409
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 ...
1
vote
1
answer
115
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">
...
1
vote
1
answer
30
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)...
1
vote
0
answers
287
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 ...
2
votes
1
answer
1k
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....
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 ...
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.....
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 ...
0
votes
1
answer
162
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
1
answer
350
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
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,...
1
vote
1
answer
113
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
0
answers
173
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
1
answer
623
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
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?
1
vote
1
answer
329
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
1
answer
467
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
1
answer
924
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
1
answer
211
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
1
answer
264
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
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....
2
votes
1
answer
187
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
1
answer
128
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
1
answer
1k
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' ...
4
votes
2
answers
3k
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
1
answer
212
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
1
answer
4k
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
1
answer
480
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
1
answer
958
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
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 ...
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 ...
1
vote
1
answer
170
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
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->...
4
votes
1
answer
539
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
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.
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 ...
3
votes
1
answer
706
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
2
answers
900
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->...
4
votes
2
answers
3k
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
...