Skip to content

Instantly share code, notes, and snippets.

@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 / vimeo_image_embed.php
Created June 20, 2012 14:20
Vimeo image embedding
<?php // USE TO CALL VIMEO IMAGES
$imgid = '30725341';
$hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/$imgid.php"));
echo '<img src="'.$hash[0]['user_portrait_huge'].'"/>';
/*
* thumbnail_large
* thumbnail_medium
* thumbnail_small
* user_portrait_huge
* user_portrait_large
@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; ?>" />
?>
@2dpi
2dpi / php_odd_even.php
Created July 13, 2012 07:49
PHP: array odd and even
<?php
/* add a class to define odd and even output from an array */
echo ($key%2) ? " even" : " odd";
?>
@2dpi
2dpi / php_first_last.php
Created July 13, 2012 07:51
PHP array first / last
<?php
/* define the first or last element in an array */
if($key == "0") echo ' first';
if(count($myVar)==$key+1) echo ' last';
?>
@2dpi
2dpi / Joomla_load_module_position.php
Last active October 7, 2015 06:47
JOOMLA: load module position
<?php if(count(JModuleHelper::getModules('module_position_here'))) :?>
<!-- only show if modules assigned -->
<?php
// define module position
jimport( 'joomla.application.module.helper' );
$modules = &JModuleHelper::getModules( 'module_position_here' );
foreach ($modules as $module) { //loop through the array and render their output
$_options = array( 'style' => 'raw' );
echo JModuleHelper::renderModule( $module,$_options );
}
@2dpi
2dpi / joomla_load_module.php
Last active October 7, 2015 06:47
JOOMLA: load module
<?php
// define module by type / name
jimport( 'joomla.application.module.helper' );
$module = JModuleHelper::getModule( 'menu', 'Main' );
$_options = array( 'style' => 'module' );
echo JModuleHelper::renderModule( $module,$_options );
?>
OR USE NO-NUMBER PLUGIN - e.g. {module xxx|module}