Skip to content

Instantly share code, notes, and snippets.

View hans2103's full-sized avatar
🏠
Working from home

Hans Kuijpers hans2103

🏠
Working from home
View GitHub Profile
@hans2103
hans2103 / display-one-sticky.php
Last active November 16, 2015 16:42
WordPress - display first (sticky or not) post and then the rest of all posts (sticky or not).
if ( is_home() && !is_paged() ) :
$args = array (
// display the first sticky post, if none return the last post published
'posts_per_page' => 1,
'post__in' => get_option( 'sticky_posts' ),
'ignore_sticky_posts' => 1,
);
$query = new WP_Query( $args );
while ($query->have_posts()) : $query->the_post();
@hans2103
hans2103 / error.php
Created November 17, 2015 10:51
show content of given Joomla article on 404 page.
<?php
/**
*/
defined('_JEXEC') or die;
if (($this->error->getCode()) == '404') {
header("HTTP/1.0 404 Not Found");
echo file_get_contents(JURI::root().'index.php?option=com_content&view=article&id=44&Itemid=584');
exit;
}
@hans2103
hans2103 / price.phtml M1.7
Last active December 17, 2015 15:59
Implementation of structured data itemprop=price on app/design/frontend/<your_package>/<your_theme>/template/catalog/product/price.phtml - Magento 1.7.0.2 - http://schema.org/Offer- more information: http://www.byte.nl/blog/magento-rich-snippets-made-easy/
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
@hans2103
hans2103 / dynamical-set-radio-button-in-RSForm
Created July 22, 2013 10:40
This piece of code can be used in Joomla extension RSForms! Pro. This piece of code will dynamical check a radio button depending on the last part of the URL you visit. Place this snippet in the field "items" of a Form Field type = "Radio Group". Example according to this snippet: visit URL http://example.com/path/to/last/element/product1 and it…
//<code>
$url = $_SERVER["REQUEST_URI"];
$tokens = explode('/', strtok($url, '?'));
$last_element = end(array_values($tokens));
$le = $last_element;
switch ($le) {
case 'product1':
$items = "item1[c]\nitem2\nitem3\nitem4\nitem5";
break;
@hans2103
hans2103 / agenda.php
Created July 24, 2013 09:42
Joomla layout override for menu item type = Category Blog. I'm using com_content as an event calendar showing the items grouped by month and by day. It's a copy from blog.php and on line 47 the override starts. A new array has been created to be able to group the items. (Thanks to @yireo for helping me with the creation of the new array) Using t…
<?php
/**
* @package Joomla.Site
* @subpackage com_content
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// no direct access
defined('_JEXEC') or die;
@hans2103
hans2103 / bundle-price.phtml M1.7
Last active December 23, 2015 04:09
Implementation of structured data itemprop=price on app/design/frontend/<your_package>/<your_theme>/template/bundle/catalog/product/price.phtml - Magento 1.7.0.2 - http://schema.org/Offer - more information: http://www.byte.nl/blog/magento-rich-snippets-made-easy/
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
@hans2103
hans2103 / noindex.xml
Created October 21, 2013 10:45
Reduce Magento resources using meta tag robots. Copy to your version of local.xml
<!--
SET META ROBOTS
-->
<!--
Search pages
-->
<catalogsearch_result_index>
<reference name="head">
<action method="setRobots"><meta>NOINDEX,NOFOLLOW</meta></action>
</reference>
@hans2103
hans2103 / price.phtml M1.8
Last active December 29, 2015 02:49
Implementation of structured data itemprop=price on app/design/frontend/<your_package>/<your_theme>/template/catalog/product/price.phtml - Magento 1.8.0.0 - http://schema.org/Offer - more information: http://www.byte.nl/blog/magento-rich-snippets-made-easy/
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
@hans2103
hans2103 / bundle-price.phtml M1.8
Last active December 29, 2015 07:49
Implementation of structured data itemprop=price on app/design/frontend/<your_package>/<your_theme>/template/bundle/catalog/product/price.phtml - Magento 1.8.1.0 - http://schema.org/Offer - more information: http://www.byte.nl/blog/magento-rich-snippets-made-easy/
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
@hans2103
hans2103 / .gitconfig
Last active December 30, 2015 18:49
my .gitconfig
[color]
status = auto
diff = auto
branch = auto
interactive = auto
ui = true
[alias]
amend = !"git commit --amend -C HEAD"
st = status
ci = commit