Skip to content

Instantly share code, notes, and snippets.

View fidlerryan's full-sized avatar

Ryan Fidler fidlerryan

View GitHub Profile
@fidlerryan
fidlerryan / gist:88b6adfa0a2fde01ee7f
Last active August 29, 2015 14:21
Remove repeated breadcrumbs generated by Joomla
function cleanArray ($a) {
$names = array();
$b = array();
foreach ($a as $v) {
$name = $v->name;
if (!array_key_exists ($name, $names)) {
$names [$name] = 1;
array_push ($b, $v);
}
@fidlerryan
fidlerryan / gist:7f6d1c5a0887c7733a60
Created May 20, 2015 14:10
Add Touch Navigation to Joomla's Vinaora Nivo Slider
jQuery('#vt_nivo_slider<?php echo $module_id; ?>').bind('swipeleft', function(e){
jQuery('a.nivo-nextNav').trigger('click');
e.stopImmediatePropagation();
return false;
});
jQuery('#vt_nivo_slider<?php echo $module_id; ?>').bind('swiperight', function(e){
jQuery('a.nivo-prevNav').trigger('click');
e.stopImmediatePropagation();
return false;
});
@fidlerryan
fidlerryan / gist:d3ffceee60072ba8c999
Created May 20, 2015 14:17
PHP example for Accessing the Joomla Framework via an AJAX Call
if (empty($_POST["catid"])){
$return["error"] = true;
$return["msg"] = "Unidentified category ID.";
} else {
$return["error"] = false;
$db->setQuery('SELECT title FROM #__categories WHERE id='.$_POST["catid"]);
$category = $db->loadRow();
if (is_array($category)){
if ($category[0] == "Portfolio"){
$category[0] = "Project Study";
@fidlerryan
fidlerryan / gist:91068e5751c3466f7c25
Created May 20, 2015 14:19
jQuery example for Accessing the Joomla Framework via an AJAX Call
$.ajax({
type: 'POST',
url: '/path/to/PHP/file',
dataType: 'json',
data: { catid: $("#catid").val() },
success: function(data){
$('.item-page').prepend(
$('<h2>').append(
$('<span>')
.addClass('subheading-category')
@fidlerryan
fidlerryan / gist:84bf345556e0d13119cf
Created May 20, 2015 14:33
Javascript Multidimensional Arrays
var objectname = {
'key_one': {
'parameter_one': 'value_one',
'parameter_two': 'value_two',
'parameter_three': 'value_three'
},
'key_two': {
'parameter_one': 'value_one',
'parameter_two': 'value_two',
'parameter_three': 'value_three'
@fidlerryan
fidlerryan / gist:e94f2225c6aa4866fd61
Created May 20, 2015 15:13
Accessing the Joomla Framework via an AJAX Call
define( '_JEXEC', 1 );
define( ' _VALID_MOS', 1 );
define( 'JPATH_BASE', '/path/to/Joomla/installation');
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
@fidlerryan
fidlerryan / gist:093729fed9da416f8fa4
Last active October 14, 2015 02:06
Creating a Joomla Plugin for Specific Modules
class PlgContentContentSpan extends JPlugin
{
/**
* Plugin that converts:
* <p>
* <img src="/images/EDPS-ABOVE-CONTENT-optimized.jpg" alt="" width="689" height="327">
* <img src="/images/JW-ABOVE-CONTENT-optimized.jpg" alt="" width="315" height="327">
* </p>
*
* To:
@fidlerryan
fidlerryan / gist:7448a3841705aa68c331
Last active November 13, 2015 13:02
SAO Office Phone List
<table>
<thead>
<tr>
<th>Name</th>
<th data-hide="phone,tablet">Division</th>
<th>Phone</th>
<th data-hide="phone">Email</th>
<th data-hide="phone,tablet">Location</th>
</tr>
</thead>
@fidlerryan
fidlerryan / gist:09f8121594674508c86e
Last active January 4, 2016 15:20
Copy to Clipboard from input
document.addEventListener('DOMContentLoaded', function() {
var copybtn = document.getElementById('copybtn');
var authcode = document.getElementById('authcode');
copybtn.addEventListener('click', function() {
// select the authorization code value
authcode.setSelectionRange(0, authcode.value.length);
try{
// with text selected, execute the copy command
var successful = document.execCommand('copy');
@fidlerryan
fidlerryan / gist:e56c7b157d5ae07d4ce3
Created January 4, 2016 15:21
Copy to Clipboard from paragraph
document.addEventListener('DOMContentLoaded', function() {
var copybtn = document.getElementById('copybtn');
var authcode = document.getElementById('authcode');
copybtn.addEventListener('click', function() {
// select the authorization code text
var range = document.createRange();
range.selectNode(authcode);
window.getSelection().addRange(range);
try{