EMC23's Code Snippets - Copy & Paste Code Library

As web developers, designers, and content managers, CTRL + C and CTRL + V are our most used keyboard shortcuts. This library is where we keep reusable code so we can save time, avoid typos and expand our development techniques by adding to, and refining our code over time.

  • Joomla extension-specific styles sets
  • HTML Layouts
  • CSS Libraries
  • PHP blocks
 

How to determine if the user is viewing the front page

<?php
$menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
        echo 'This is the front page';
}
?>
 

Centered Menu Demo

Courtesy of Matthew James Taylor

 

Centered Menu

#centeredmenu {
float:left;
width:100%;
border-bottom:4px solid red;
overflow:hidden;
position:relative;
}
#centeredmenu ul {
clear:left;
float:left;
list-style:none;
margin:0;
padding:0;
position:relative;
left:50%;
text-align:center;
}
#centeredmenu ul li {
display:block;
float:left;
list-style:none;
margin:0;
padding:0;
position:relative;
right:50%;
}
#centeredmenu ul li a {
display:block;
margin:0 0 0 1px;
padding:3px 10px;
background:#ddd;
color:#000;
text-decoration:none;
line-height:1.3em;
}
#centeredmenu ul li a:hover {
background:#369;
color:#fff;
}
#centeredmenu ul li a.active,
#centeredmenu ul li a.active:hover {
color:#fff;
background:red;
font-weight:bold;
}

 

Basic CSS3 features Demo

hello shadow

hello text shadow

hello rounded

hello gradient

 

Basic CSS3 features

  • -moz-border-radius = Firefox
  • -webkit-border-radius = Safari and Chrome
  • -khtml-border-radius = Linux browsers
  • border-radius = Generic

/* Drop Shadow */

.shadow {
box-shadow: 3px 3px 3px #000;
-moz-box-shadow: 3px 3px 3px #000;
-webkit-box-shadow: 3px 3px 3px #000;
}

/* Text Shadow */

.textshadow {
text-shadow: 3px 3px 3px #000;
}

/* Rounded Corners */

.rounded {
-moz-border-radius: 5px 5px 5px 5px;
-webkit-border-radius: 5px 5px 5px 5px;
border-radius: 5px 5px 5px 5px;
}

/* Gradient */

.gradient {
background: -moz-linear-gradient(top, red, blue);
background: -webkit-gradient(linear, 0 0, 0 100%, from(red), to(blue));
}

   

The Art of Dojogame

Our contribution to the CoderDojo movement - An online resource for web game creation. CoderDojo Kata