Skip to content

Instantly share code, notes, and snippets.

@2dpi
2dpi / W3_Labels
Last active August 29, 2015 13:56
HTML: W3 Lables
<!--
LABEL > set style (warning, success, info, errro, add)
EXPAND with float, inline, outline_, grad, in_ or out_ etc..
-->
<span class="inline in_tighter outline_round label_warning">Label</span>
<span class="inline in_tighter outline_round label_success">Label</span>
<span class="inline in_tighter outline_round label_info">Label</span>
<span class="inline in_tighter outline_round label_error">Label</span>
<span class="inline in_tighter outline_round label_add">Label</span>
@2dpi
2dpi / gist:a540527a64f9f0093392
Created May 13, 2014 08:32
JOOMLA: truncate text blocks over the specified character limit (ie. word trim)
<?php
///////////////////////////////////////////////////////////////////////////////////
// ADD TEXT TO BE TRIMMED, SET TRIM LENGTH IN CHARACTERS, BREAK WORD, STRIP HTML //
// http://api.joomla.org/cms-3/classes/JHtmlString.html //
///////////////////////////////////////////////////////////////////////////////////
echo JHTML::_('string.truncate', $text, $length, true, false );
?>
@2dpi
2dpi / gist:bb5a06812bab0cb11b1b
Created May 20, 2014 10:25
SQL: copy column value from one table to another
UPDATE table1 INNER JOIN table2 ON table1.field_name = table2.field_name SET table1.field_name = table2.field_name
@2dpi
2dpi / gist:6a82181a4b223be7ecb4
Created June 10, 2014 09:58
PHP: array reset key values and filter empty
<?php
// RESET KEY VALUES TO START FORM 0 AND REMOVE EMPTY/NULL ENTRIES
$array =array_values(array_filter($array));
?>
@2dpi
2dpi / gist:b7969592177bfaca51e4
Created June 16, 2015 13:42
JOOMLA - Add Style Declaration
<?php if (!empty($attribs->select_banner_image)) {
$style = 'html {
background-image: url('.$attribs->select_banner_image.') !important;
background-size: contain;
background-repeat: no-repeat;
background-position: center top;
}';
$doc->addStyleDeclaration( $style );
} ?>
@2dpi
2dpi / joomla_setMetaData.php
Created June 11, 2012 07:15
joomla - setMetaData
<?php
// http://docs.joomla.org/JDocument/setMetaData
$doc =& JFactory::getDocument();
$doc->setMetaData( 'tag-name', 'tag-content', true );
/*
*<meta name="tag-name" content="tag-content" />
*/
?>
@2dpi
2dpi / module_chrome.php
Created June 13, 2012 11:42
Joomla - add module count to module chrome
<?php
// useful for multi-column layouts
$modulecount = count(JModuleHelper::getModules($attribs['name']));
echo $modulecount;
?>
@2dpi
2dpi / htaccess_vary.txt
Created June 17, 2012 14:34
HTACCESS - Add vary based on user agent
online tools:
http://web-sniffer.net/
http://www.stepforth.com/resources/server-header-checker-tool/#.T93mC7UtgZl
http://www.rexswain.com/httpview.html
http://webtools.live2support.com/header.php
articles:
http://www.seomoz.org/ugc/responsive-web-design-the-ultimate-guide-for-online-marketers
HTACCESS >> add following line
@2dpi
2dpi / seblod_image_upload.php
Created June 20, 2012 14:45
Seblod - Image output for upload image field
<?php
/*
* Output for image upload field (original + thumbs x 5)
*
*/
?>
<img src="<?php echo $cck->getValue('fieldname');?>" title="" alt="" />
<img src="<?php echo $cck->getThumb1('fieldname');?>" title="" alt="" />
@2dpi
2dpi / mod_login_redirect.php
Created June 21, 2012 08:39
Joomla - Redirect to same page after login
<?php
// redirect to same page
$uri = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$uri = base64_encode($uri);
// replace $return with $uri
<input type="hidden" name="return" value="<?php echo $uri; ?>" />
?>