When trying to get page url with
URL::current();
it's ignore the pagination.
For example:
current url is www.google.com/searc?page=2
dd(URL::current());
gives us www.google.com/search. Using default pagination.
My question is: Any function for get url with paginations?
Simply use :
\URL::full();
It will give the url along with query string.
You will need the full URL, not just the URL. Try this:
\URL::full();
As described in the docs of Laraval. You can use URL::full()
Accessing The Current URL
If no path is provided to the url helper, a
Illuminate\Routing\UrlGenerator instance is returned, allowing you to
access information about the current URL:
// Get the current URL without the query string...
echo url()->current();
// Get the current URL including the query string...
echo url()->full();
// Get the full URL for the previous request...
echo url()->previous();
Each of these methods may also be accessed via the URL facade:
use Illuminate\Support\Facades\URL;
echo URL::current();
Related
i'm trying to redirect to a URL from a ajax success function, but the parameter xd_co_f is appended to the query of the URL when redirected. How do I remove the unwanted parameter?
I tried to hardcode the URL to anchor tag i did not face this issue only when redirecting from ajax success function.
Please check whether your site uses Oracle infinity analytics.
xd_co_f is appended to your URL if you use Oracle infinity for analytics.
I am using laravel 5 and I am trying to get my full url which is
/faq#manual
However I can only get /faq
when I call the function
Request::url() or Request::fullUrl()
is there any way I can get the full url
with #manual?
It is impossible to get the fragment from a URL with Standard HTTP. So using variables like $_SERVER or $_GET can't help you. Actually, the server never knows about this value because the browser won't even send a request with a fragment part.
If you want to have the fragment value in the server side, you should get the value by javascript first then pass it as a URL parameter and get it by $_GET in your server side.
That's not possible in http or php however you can use javascript to get the full url including the hash.
var url = document.URL;
or
var url = window.location.href;
Hope this helps.
I'm using angular-ui-router, when browsing on my app, on URL
http://localhost:8080/referential/browse.action#/referential/collectivity/38470/181/services
I can call
$state.href(COLLECTIVITY_STATE, {collectivityId: collectivityId})
and I get
#/referential/collectivity/38470/181/services
That's fine but I want a full URL (ready to bookmark or send by email), according to the documentation, i add a parameter to href call:
$state.href(COLLECTIVITY_STATE, {collectivityId: collectivityId}, {absolute: true})
but what I get is
http://localhost:8080/#/referential/collectivity/38470/121/services
which is not the expected first URL: the path is lacking. How should I get the full URL?
You can use:
$location.absUrl();
to return the absolute URL (which includes the domain and protocol).
Be sure to include $location in your controller or factory dependency list.
app.factory("test", function($location)
{
console.log($location.absURL());
});
I have an url with query args:
var url = 'http://example.com/ajax.php?action=update_count&product=1234'
So, all query args I need to send for ajax request is already in URL, I tried this:
$.post( url, '', callback, 'json');
But, it won't send POST data.
So, I want to ask shall I do ajax/post request without data object/string, as query args are already in url.
Thanks.
If you put a parameter in the URL, it's treated like a GET parameter, not a POST parameter. You need to use whatever server-side mechanism is normally used for getting URL parameters. For instance, in PHP it would be $_GET['action'] and$_GET['product']`.
If you want to be able to send a parameter in either GET or POST, you can use PHP's $_REQUEST variable. It merges both sets of parameters.
I have the following code:
<div><strong>Name: </strong><?php echo anchor('http://'.$link, $row->Name); ?></div>
Which takes a users input for a link ($link) and puts the url into an anchor tag. It, however, is not redirecting to the external link but simply amending the base url for the site with the stored URL. I attempted to add 'http://' to the beginning of the submitted link which works unless the user has already supplied http in the link input. Any advice on how to overcome this would be amazing.
Yes, per the documentation, anchor() creates links based on your site's URL.
If things are working as expected when URL's are prefixed with http://, but you're having trouble with users sometimes adding http:// and sometimes not, you could simply check the link to determine whether it's ok, or if you need to prefix it. Here's a basic example using strpos:
if(strpos($link, 'http') === FALSE){
// link needs a prefix...
$link = 'http://' . link;
} else {
// link is ok!
}
...use CodeIgniter's prep_url() function (thanks to #cchana for reminding me of it!):
This function will add http:// in the event that a scheme is missing from a URL. Pass the URL string to the function like this:
$url = "example.com";
$url = prep_url($url);