Skip to content

Instantly share code, notes, and snippets.

View heyjoecampbell's full-sized avatar

Joe Campbell heyjoecampbell

View GitHub Profile
@heyjoecampbell
heyjoecampbell / joomlak2-extrafields-meta
Last active August 29, 2015 14:21
Use Joomla K2 ExtraFields for Meta Data (Replace Single & Double Quotes with HTML Entity)
// remove single and double quotes - place at top of item override file
<?php
$safe = array("&#39;", "&#34;");
$nonsafe = array("'", "\"");
?>
// code to generate meta data (change ExtrafieldAlias) - place after above code
<?php $doc->addCustomTag('<meta property="anything" content="'.str_replace($nonsafe, $safe, $this->item->extraFields->ExtrafieldAlias->value).'" />'); ?>
@heyjoecampbell
heyjoecampbell / gist:a3181beec8116ccd4fee
Last active May 7, 2016 08:34
AddThis Non-JavaScript Social Share (@heyjoecampbell)
// Produce and size pop-up
<script>
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
</script>
<a rel="nofollow" href="javascript:void(0);" onclick="PopupCenter('http://api.addthis.com/oexchange/0.8/forward/facebook/offer?url=<?php echo $this->item->absoluteURL; ?>&amp;pubid=ra-XXXXXX', 'FacebookShare',650,400);" title="Facebook Share">Facebook</a>
<-- Replace sample data -->
<-- Append '&is_video=true' for video (YouTube & Vimeo) and audio pins (Soundcloud)
http://api.addthis.com/oexchange/0.8/forward/pinterest_share/offer?url=http://domain.com&title=Sample Title&screenshot=http://placehold.it/350x550&description=Sample Description&pubid=XYZ
@heyjoecampbell
heyjoecampbell / unset-scripts.php
Last active November 7, 2016 23:26
Unset Joomla! Scripts from Template
// Unset unwanted Scripts - by name
$unset_script = array('k2');
foreach($this->_scripts as $name=>$script)
{
foreach($unset_script as $script)
{
if (strpos($name,$script) !== false)
{
unset($this->_scripts[$name]);
@heyjoecampbell
heyjoecampbell / Remove .php File Extension and Force Trailing Slash (perfect for static Bootstrap websites)
Created January 5, 2018 19:23
Remove .php File Extension and Force Trailing Slash (perfect for static Bootstrap websites)
## Remove .php -and- Force Trailing Slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(([^/]+/)*[^./]+)/$ $1.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
@heyjoecampbell
heyjoecampbell / Youtube Responsive Video and Play Button Placeholder CSS
Created January 9, 2018 22:27
Youtube Responsive Video and Play Button Placeholder CSS
.video-container {
position: relative;
padding-bottom: 56.25%;
height: 0; overflow: hidden;
max-width: 100%;
margin: 2.5rem 0;
border: 1px solid #5b5b5b;
background: #eee;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEQAAAAwCAMAAACffixXAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyNpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQwIDc5LjE2MDQ1MSwgMjAxNy8wNS8wNi0wMTowODoyMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjQ2NTBGNjVFRUQxQzExRTd