snipt

Ctrl+h for KB shortcuts

PHP

Inject data into a module position

1
2
3
4
5
<?php
// Inject data from your component into the right module position
JFactory::getDocument()->setBuffer($data, 'modules', 'right');

// Note: Data will not be shown unless there are "real" modules present in position right
https://snipt.net/embed/130d081d59867fbbba5a542407fc5b69/
/raw/130d081d59867fbbba5a542407fc5b69/
130d081d59867fbbba5a542407fc5b69
php
PHP
5
2019-08-23T09:27:27
True
False
False
Apr 01, 2014 at 11:55 AM
/api/public/snipt/126514/
inject-data-into-a-module-position-1
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">// Inject data from your component into the right module position</span> </span><span id="L-3"><a name="L-3"></a><span class="nx">JFactory</span><span class="o">::</span><span class="na">getDocument</span><span class="p">()</span><span class="o">-&gt;</span><span class="na">setBuffer</span><span class="p">(</span><span class="nv">$data</span><span class="p">,</span> <span class="s1">&#39;modules&#39;</span><span class="p">,</span> <span class="s1">&#39;right&#39;</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="c1">// Note: Data will not be shown unless there are &quot;real&quot; modules present in position right</span> </span></pre></div> </td></tr></table>
joomla, module, position

Text only

Rewrite Xmap URL

1
2
3
4
5
6
RewriteCond %{REQUEST_URI} ^/es/sitemap.xml
RewriteRule .* /es/index.php?option=com_xmap&view=xml&tmpl=component&id=1
RewriteCond %{REQUEST_URI} ^/en/sitemap.xml
RewriteRule .* /en/index.php?option=com_xmap&view=xml&tmpl=component&id=2
RewriteCond %{REQUEST_URI} ^/pt/sitemap.xml
RewriteRule .* /pt/index.php?option=com_xmap&view=xml&tmpl=component&id=3
https://snipt.net/embed/29b62e0c11755e05065242cf9fcd3991/
/raw/29b62e0c11755e05065242cf9fcd3991/
29b62e0c11755e05065242cf9fcd3991
text
Text only
6
2019-08-21T06:25:10
True
False
False
Apr 01, 2014 at 11:48 AM
/api/public/snipt/126512/
rewrite-xmap-url
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>RewriteCond %{REQUEST_URI} ^/es/sitemap.xml </span><span id="L-2"><a name="L-2"></a>RewriteRule .* /es/index.php?option=com_xmap&amp;view=xml&amp;tmpl=component&amp;id=1 </span><span id="L-3"><a name="L-3"></a>RewriteCond %{REQUEST_URI} ^/en/sitemap.xml </span><span id="L-4"><a name="L-4"></a>RewriteRule .* /en/index.php?option=com_xmap&amp;view=xml&amp;tmpl=component&amp;id=2 </span><span id="L-5"><a name="L-5"></a>RewriteCond %{REQUEST_URI} ^/pt/sitemap.xml </span><span id="L-6"><a name="L-6"></a>RewriteRule .* /pt/index.php?option=com_xmap&amp;view=xml&amp;tmpl=component&amp;id=3 </span></pre></div> </td></tr></table>
htaccess, joomla, rewrite, sitemap, xmap

Text only

Remove HTML comments with ReReplacer

1
2
3
4
5
Removes all 
<!--.*?-->

Leaves conditional comments, i.e. <!--[if IE]>
<!--(?!\[).*?(?!<\])-->
https://snipt.net/embed/d2d5b8370adba9bf0da63435963bc70d/
/raw/d2d5b8370adba9bf0da63435963bc70d/
d2d5b8370adba9bf0da63435963bc70d
text
Text only
5
2019-08-21T12:05:00
True
False
False
/api/public/snipt/118677/
remove-html-comments-with-rereplacer
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>Removes all </span><span id="L-2"><a name="L-2"></a>&lt;!--.*?--&gt; </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a>Leaves conditional comments, i.e. &lt;!--[if IE]&gt; </span><span id="L-5"><a name="L-5"></a>&lt;!--(?!\[).*?(?!&lt;\])--&gt; </span></pre></div> </td></tr></table>
"html comments", joomla, reprelacer

JavaScript

Add viewport tag to head with jQuery

//useful for jsfiddle
$('head').append('<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" />');
https://snipt.net/embed/436b83cbffb758473413035d5f34ed3b/
/raw/436b83cbffb758473413035d5f34ed3b/
436b83cbffb758473413035d5f34ed3b
js
JavaScript
2
2019-08-22T13:33:26
True
False
False
Feb 18, 2014 at 11:15 AM
/api/public/snipt/114793/
add-viewport-tag-to-head-with-jquery
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">//useful for jsfiddle</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;head&#39;</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="s1">&#39;&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1&quot; /&gt;&#39;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
head, javascript, jquery, viewport