I am new to Sammy and I would like to know if there is a way to block Sammy from redirecting to a specific route or URL.
There is a method called "setLocation" that is called everytime a redirection is needed. I would like to block the acces to one or more URL.
Can Sammy do it ???
Thanks in advance
Sammy can only do this on known routes buy using the 'before' method on the sammy object (see the sammy docs). In the before you can check if navigation is enabled
Any other url (www.google.com, www.yourdomain/sammysinglepageapp2 etc) cannot be blocked
Consider using Sammy.around(callback) as defined here:
Sammy.js docs: Sammy.Application around(callback)
For a more detailed response, see Cancel route using Sammy.js without affecting history
Related
I'm creating an affiliate tracking system with some custom affiliate links. These links trigger a controller function to store some metrics in the database then redirect to the actual page the user intended.
My desired function is this: insert affiliate link into webpage->user clicks->controller fires/data stored->redirect to intended page. One of the pieces of data I want to store is the originating site the user clicked on the link. But because I'm calling the controller with a URL, url()->previous() gets my affiliate link that fired the controller instead of the originating site that has the link embedded.
I'm not sure if "previous()" can accept parameters but i tried "previous(2)" and that obviously didn't work.
$url = url()->previous();
$click->came_from = $url;
Using the code above, if my link was hosted on www.w3schools.com and my affiliate link is myurl/affiliatelink/2, I would want "www.w3schools.com" to be inserted into my database, but i'm getting "myurl/affiliatelink/2" inserted instead. Can anyone help me figure out a way around this?
The previous() method returns the user's last location within the app, not the last URL the browser accessed.
To do that, in Laravel, you can try Request::server('HTTP_REFERER'), or in plain PHP, $_SERVER['HTTP_REFERER'].
That said, be aware that HTTP_REFERER is not exactly the most reliable value. It can be spoofed (faked) easily or not provided at all, so test accordingly.
If possible, the best option would be to add a GET parameter to the link present in the remote site, so that when you receive the request in your Controller, you have the means to identify where the user is coming from.
You can simply get and store the previous url with the parameter in a variable($url) from your blade file, then pass the variable to your anchor tag as shown below:
#php
$url= url()->previous();
#endphp
href="{{url($url)}}"
This works very fine.
I am using the Salesforce Sites URL rewriting feature, and need to retrieve the 'friendly' URL from the browser bar for some other processing. Is there any way I can retrieve this from within either one of the sites pages (so I can pass into a component as an attribute) or from a component controller directly?
To explain further, I am seeing a url in browser presently of 'site.force.com/examplesite/amazingpage' but if I try to retrieve $CurrentPage.url to pass into a component, or use Url.getCurrentRequestUrl() from within a component controller the result is a typical salesforce url ie. 'site.force.com/vfpage?id=123456789'.
Any suggestions most appreciated.
Cheers,
CH
Sorted.
Was obvious in the end - just added an additional method to the url rewriter class that allowed me to pass in a single url for rewriting, rather than trying to retrieve the re-written url from the view.
Cheers,
CH
I am using knockout and sammy together. I have a mobile page where i declared
$.sammy('#portal', function(){.....}).
outside '#portal' I have a regular anchor
friends.
The issue is that when i click the anchor the url is updated but the page stays at the original page where i have sammy loaded....I thought that sammy will only trigger if the event was coming from '#portal'. Does someone knows why the page is being locked and not redirecting?
Try using '/' instead of '' for your sammy default route.
I have an http handler which picks up all requests for my custom extension .page . This works fine with old fashion asp.net where I simply do a Server.Transfer to the aspx file of choice.
However, I would like to move this to MVC and instead reroute to either a Controller or a View. Doesn't matter which though I would prefer to a Controller.
Any help on this subject is appreciated.
Thanks!
I'd go about adding a new entry in the RouteTable.Routes ignored routes:
routes.Ignore("{*allcustomextension}",
new {
allcustomextension = #".*\.ext(/.*)?"
});
This will allow the handler to be invoked as a physical resource.
To redirect from the handler context to a View use:
System.Web.Mvc.UrlHelper.Action("ViewName", "ControllerName");
Firstly, you should redirect only to a controller which will select the view to render but think that you don't need that custom handler. Try something like that (you should change it somehow to match the url format you have)
routes.MapRoute("page", "{controller}/{action}.page");
If that doesn't work and you really want to redirect from your handler, combine the ignoring route from Xander with
Response.Redirect(System.Web.Mvc.UrlHelper.Action("ActionName", "ControllerName"));
Afaik, Server.Transfer works only with asp.net classic so your only option is a redirect.
I want to call AJAX Request from one subdomain to other.
Say I want to request http://subdomain2.site.com/ajax/handler.ashx from a ASPX page on other subdomain http://subdomain1.site.com/Default.aspx
Any IDEA how to do this?
According to https://developer.mozilla.org/en/Same_origin_policy_for_JavaScript, you can set document.domain to a suffix of the domain, so
document.domain='example.com'
However, I have not tested this.
have you taken a look at JSONP?