snipt

Ctrl+h for KB shortcuts
#57485

Text only

Drupal 7: Field redirection ajax issue (autocomplete input) - Entity Reference

1
2
3
If you have an error in your autocomplete inputs and if you have enabled the "Field redirection" module, you may take a look at your content type manage display screen.

If you're as dumb as I am you may have set the redirect field on the default display instead of the full content one. So when the autocomplete searches for the entity it is automatically redirected.
https://snipt.net/embed/a8b469681b2460a3852619eeee0c6341/
https://snipt.net/raw/a8b469681b2460a3852619eeee0c6341/
a8b469681b2460a3852619eeee0c6341
text
Text only
3
2014-04-20T01:37:43
True
True
Mar 12, 2013 at 11:22 AM
/api/public/snipt/57485/
drupal-7-field-redirection-ajax-issue-autocomplete-input-entity-reference
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>If you have an error in your autocomplete inputs and if you have enabled the &quot;Field redirection&quot; module, you may take a look at your content type manage display screen. </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>If you&#39;re as dumb as I am you may have set the redirect field on the default display instead of the full content one. So when the autocomplete searches for the entity it is automatically redirected. </span></pre></div> </td></tr></table>
"drupal 7", "entity reference", "field redirection", ajax
#48576

JavaScript

jQuery : Bind an event on an ajax reloaded DOM

1
2
3
4
5
6
7
$('body').on("click", "#select-status a", function(e){
    e.preventDefault();
    // My actions
});

// You have to bind the event on a part of the DOM which is not reloaded by the ajax call.
// Then you can write your real selector in the parameters
https://snipt.net/embed/94314a16cbd8aecb23f43f01a6165516/
https://snipt.net/raw/94314a16cbd8aecb23f43f01a6165516/
94314a16cbd8aecb23f43f01a6165516
js
JavaScript
7
2014-04-17T15:55:08
True
True
Oct 15, 2012 at 06:07 AM
/api/public/snipt/48576/
jquery-bind-an-event-on-an-ajax-reloaded-dom
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;body&#39;</span><span class="p">).</span><span class="nx">on</span><span class="p">(</span><span class="s2">&quot;click&quot;</span><span class="p">,</span> <span class="s2">&quot;#select-status a&quot;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span> </span><span id="L-2"><a name="L-2"></a> <span class="nx">e</span><span class="p">.</span><span class="nx">preventDefault</span><span class="p">();</span> </span><span id="L-3"><a name="L-3"></a> <span class="c1">// My actions</span> </span><span id="L-4"><a name="L-4"></a><span class="p">});</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="c1">// You have to bind the event on a part of the DOM which is not reloaded by the ajax call.</span> </span><span id="L-7"><a name="L-7"></a><span class="c1">// Then you can write your real selector in the parameters</span> </span></pre></div> </td></tr></table>
ajax, bind, jquery, live, on
#46343

Text only

Prevent External POST or GET requests

1
2
3
4
//check to see if a HTTP_REFERER is set and if it is that it is equal to your website
if( !isset( $_SERVER['HTTP_REFERER']) || !strpos($_SERVER['HTTP_REFERER'],'example.com')) {
	exit;
}
https://snipt.net/embed/1f4ef70fd3177c7df7fd1f3677fd942f/
https://snipt.net/raw/1f4ef70fd3177c7df7fd1f3677fd942f/
1f4ef70fd3177c7df7fd1f3677fd942f
text
Text only
4
2014-04-20T13:17:41
True
False
Aug 27, 2012 at 12:45 PM
/api/public/snipt/46343/
prevent-external-post-or-get-requests
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>//check to see if a HTTP_REFERER is set and if it is that it is equal to your website </span><span id="L-2"><a name="L-2"></a>if( !isset( $_SERVER[&#39;HTTP_REFERER&#39;]) || !strpos($_SERVER[&#39;HTTP_REFERER&#39;],&#39;example.com&#39;)) { </span><span id="L-3"><a name="L-3"></a> exit; </span><span id="L-4"><a name="L-4"></a>} </span></pre></div> </td></tr></table>
XSS, ajax, php, security