Skip to content

Instantly share code, notes, and snippets.

@esedic
esedic / jdatabase_query.php
Created July 4, 2014 14:39
Joomla DB Query
<?php
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query
->select($db->quoteName(array('a.id')))
->from($db->quoteName('#__content', 'a'))
->join('INNER', $db->quoteName('#__categories', 'b') . ' ON (' . $db->quoteName('b.id') . ' = 38)');//static category id
$db->setQuery($query);
$results = $db->loadObjectList();
@esedic
esedic / htaccess_ssl
Last active October 28, 2020 08:16
Using .htaccess to Move Your Site to SSL
# Moving your whole site to SSL
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@esedic
esedic / responsive_modal.html
Created July 28, 2014 12:35
Make the Joomla Modal Popup Responsive
<!-- Make the Joomla Modal Popup Responsive -->
<!-- 1. Import following library at the start of the page. -->
<?php JHTML::_('behavior.modal', 'a.modal'); ?>
<!-- This ensures that the modal.js script and the modal.css style sheets are loaded, plus the mootools javascript framework which the script requires, and initialises the modal window. Note that from Joomla 3.3x onwards using JQuery might be a better idea. -->
<!-- 2. Add following function in javascript -->
@esedic
esedic / showmodule.php
Created August 27, 2014 12:53
Show Joomla module inside custom code
<?php
jimport('joomla.application.module.helper');
// this is where you want to load your module position
$modules = JModuleHelper::getModules('header');
foreach($modules as $module)
{
echo JModuleHelper::renderModule($module);
}
?>
@esedic
esedic / ie-html5-compatibility.php
Created September 2, 2014 07:55
Detect older IE with PHP and load HTML5 shiv library
<?php
//IE8 compatibility
if(preg_match('/(?i)msie [1-8]/',$_SERVER['HTTP_USER_AGENT']))
{
JFactory::getDocument()->addScript('https://html5shiv.googlecode.com/svn/trunk/html5.js');
}
?>
@esedic
esedic / jquery_cascading_dropdown.html
Last active August 29, 2015 14:06
jQuery Cascading Dropdown
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>jQuery Cascading Dropdown</title>
<script type='text/javascript' src='//code.jquery.com/jquery-1.10.1.js'></script>
</head>
<body>
<label class="page1">Country</label>
<div class="tooltips" title="Please select the country that the customer will primarily be served from">
@esedic
esedic / virtuealhost
Created October 30, 2014 14:28
Virtual Hosts on XAMPP
Find C:\xampp\apache\conf\extra\httpd-vhosts.conf
// Apache below 2.4
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/testsite"
ServerName testsite.dev
ServerAlias www.testsite.dev
<Directory "c:/xampp/htdocs/testsite">
Order allow,deny
@esedic
esedic / mod_k2_content_bootstrap_3
Created November 14, 2014 14:10
K2 content module with bootstrap 3 rows
<?php
// no direct access
defined('_JEXEC') or die;
/*
* Display K2 2 articles in 1 row (you can change to 3 or 4 or whatever - don't forget to change bootstrap col class)
*/
?>
@esedic
esedic / htaccess.txt
Created November 20, 2014 12:22
Cross-Origin Resource Sharing policy override with .htaccess
## Situation: you want to load web font or other asset from subdomain
# Because of the cross origin access policy, you get an error
# Put this is in .htaccess file inside your root folder and this limitation will be gone
##
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
@esedic
esedic / responsive_youtube_php.php
Created November 20, 2014 17:24
Responsive youtube video embed with PHP
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>Online PHP Script Execution</title>
<link href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css' rel='stylesheet' type='text/css'>
<style>
body {padding: 1em;}
.video-container {position: relative;padding-bottom: 56.25%;padding-top: 30px;height: 0;overflow: hidden;}