Skip to content

Instantly share code, notes, and snippets.

<?php
$header_data = array(
array(
'header_background' => 'background-image:url(../img/header/header_sun12.jpg)',
'header_elements' => array(
array(
'img_link' => "link1.php",
'img_title' => "Link Titel",
'img_pos_left' => 240,
'img_pos_top' => 10,
<?php
$smarty->assign('rh',$header_data);
?>
@steffenr
steffenr / mymodule.php
Created March 24, 2011 19:37
hook_form_alter to add items per page to exposed filter
<?php
function mymodule_views_query_alter(&$view, &$query)
{
if($view->name=='mitarbeiter') {
$itemsPerPage = intval( $view->exposed_input['items_per_page']); // Wert aus dem DropDown auslesen
if ($itemsPerPage == 0) {
$view->set_items_per_page(10); // Default Limit
}
else $view->set_items_per_page($itemsPerPage);
}
<?php
function mymodule_form_alter(&$form, &$form_state, $form_id)
{
if($form_id == 'views_exposed_form' && $form['#id']=='views-exposed-form-mitarbeiter-page-1' ) {
//Items per page
$form['#info']['filter-items_per_page']['operator']= 'items_per_page_op';
$form['#info']['filter-items_per_page']['value']= 'items_per_page';
$form['#info']['filter-items_per_page']['label']= t('Items per Page');
$items_per_page_ar = array ('10'=>'10','20'=>'20','30'=>'30','50'=>'50','100'=>'100',''=>'alle');
$form['items_per_page'] = array();
@steffenr
steffenr / template.php
Created April 8, 2011 11:01
HTTP_X_REQUESTED - new template file
<?php
function mytheme_preprocess_page(&$variables) {
// wurde die seite über AJAX request aufgerufen?
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) {
$variables['template_files'] = is_array($variables['template_files']) ? $variables['template_files'] : array();
// füge ein neues template hinzu
$variables['template_files'][] = 'page-xhttp';
}
}
?>
<?php print $content ?>
@steffenr
steffenr / template.php
Created April 11, 2011 07:10
template_preprocess_html / template_preprocess_page
<?php
function mytheme_preprocess_html(&$variables) {
// wurde die seite über AJAX request aufgerufen?
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ) {
$variables['theme_hook_suggestions'][] = 'html__sites__xhttp';
}
}
function mytheme_preprocess_page(&$variables, $hook) {
@steffenr
steffenr / .php
Created April 11, 2011 07:14
html--sites--xhttp.tpl.php / page--xhttp.tpl.php
// html--sites--xhttp.tpl.php
<?php
print $page;
?>
// page--xhttp.tpl.php
<?php
print render($page['content']);
?>
<?php
// embed HTML 5 Video Player
// Standbild
$file_poster['filename'] = 'startbild.png';
$file_poster['filepath'] = 'sites/default/files/startbild.png';
// Webkit browser & Flash
$file_mp4['filename'] ='film_2.mp4';
$file_mp4['filemime'] = 'video/mp4';
$file_mp4['filepath'] = 'sites/default/files/film_2.mp4';
@steffenr
steffenr / commerce_payment_bank_transfer
Created December 21, 2011 16:09
Rule - BankTransfer for File-Products only
{ "commerce_payment_bank_transfer" : {
"LABEL" : "Bank Transfer",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-1",
"REQUIRES" : [ "rules", "commerce_payment" ],
"ON" : [ "commerce_payment_methods" ],
"DO" : [
{ "LOOP" : {
"USING" : { "list" : [ "site:current-cart-order:commerce-line-items" ] },
"ITEM" : { "list_item" : "Current list item" },