Skip to content

Instantly share code, notes, and snippets.

View kahlil's full-sized avatar

Kahlil Lechelt kahlil

View GitHub Profile
@kahlil
kahlil / config.php
Created May 27, 2010 19:08
PHP: Implementation for Contao CMS hooks to change various URLs
<?php if (!defined('TL_ROOT')) die('You can not access this file directly!');
$GLOBALS['TL_HOOKS']['generateFrontendUrl'][] = array('RDKHooks', 'myGenerateFrontendUrl');
$GLOBALS['TL_HOOKS']['getPageIdFromUrl'][] = array('RDKHooks', 'myGetPageIdFromUrl');
@kahlil
kahlil / shorten_strings.php
Created June 29, 2010 13:43
Shorten Strings and leave the last word complete
<?php
function shorten_string ($string, $string_max_length = 150)
{
if (empty($string) == true)
{
return('Es wurde kein String an die Function: shorten_string() übergeben!');
}
else
{
@kahlil
kahlil / ajaxifyTabs.js
Created June 30, 2010 09:08
Ajaxify a tab navigation
// Dann im Javascript sieht’s so aus:
// hier erst mal initialisiert und definiert:
var AjaxContent = function(){
var container_div = '';
var content_div = '';
return {
getContent : function(url){
$(container_div).html('<br><br><br><center><p><img src="/img/loader_big_fl.gif" /></p></center>').animate({opacity:0.2}, //Turn the opacity to 0
@kahlil
kahlil / detectIE.js
Created August 19, 2010 09:58
The easiest way to detect IE in JavaScript
/*
From: http://devoracles.com/the-best-method-to-check-for-internet-explorer-in-javascript
"I declared a new variable, called IE, which has the value a comment block followed by ‘false‘.
The above variable will be understood by IE: var IE = !false, because Internet Explorer uses
JScript — a Javascript-like dialect of the standard ECMAScript — instead of Javascript which is
used by all the other browsers. JScript can parse the comments, just like Internet Explorer (see
conditional HTML comments post). This is a unique feature of IE, none of the other browsers can do it,
so Firefox, Chrome, Safari, Opera, all will understand the above declaration as IE = false."
*/
@kahlil
kahlil / vibrate.js
Created September 13, 2010 15:31
Make an element vibrate
/* from http://prashant.es/labs/vibrating-notices/ */
/* Github Project: http://github.com/phused/Vibrating-Notices */
<script src="/path/to/jquery.min.js"></script>
<script src="/path/to/jquery.vibrating-notices.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('a.vibrate').bind('click', function() {
$('#message').vibrate('x', 10, 4, 85);
@kahlil
kahlil / gradient-triangles.css
Created September 16, 2010 10:09
Ingenius solution to create a CSS triangle with a gradient.
/* Code is by A.J. Cates (http://ajcates.com). Find his post here: http://forr.st/~XGU */
#gradient-triangle {
width: 60px;
height: 60px;
position: absolute;
top: 3em;
left: -30px;
clip: rect(auto 30px 60px auto);
}
@kahlil
kahlil / elliptical.css
Created September 16, 2010 10:34
CSS circle
#circle {
display: block;
width: 10px;
height: 144px;
background: #333;
border-radius: 10px 0 0 0 / 144px 0 0 0;
-moz-border-radius: 10px 0 0 0 / 144px 0 0 0;
-webkit-border-radius: 10px 0 0 0 / 144px 0 0 0;
margin:100px auto;
}
/* From http://social.msdn.microsoft.com/forums/en-US/iewebdevelopment/thread/e153eeef-e93f-42e5-a21c-8096bf209688/
For my website I created a "hack" which still has the desired functionality, that is, links are still followed if Javascript is unavailable or disabled and not if javascript does work: */
function myfalse (el) {
if ( navigator.appVersion.match("MSIE 7") ) {
el.href = "java"+"script:;";
}
return false;
}
@kahlil
kahlil / get Frontenduser date in Contao.php
Created October 4, 2010 14:53
Contao: get frontend user data
<?php
if (FE_USER_LOGGED_IN)
{
$this->import('FrontendUser', 'User');
$userid = $this->User->id;
$membername = $this->User->firstname;
$lastname = $this->User->lastname;
echo "The user id is " .$userid. " and the user id is also " . $this->User->id;
@kahlil
kahlil / access page data in Contao.php
Created October 4, 2010 14:53
Contao: get global page vars
<?php
global objPage;
print_r($objPage);