Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Share DrupalCon Copenhagen/title>
<meta name="title" content="Drupalcon Copenhagen" />
<meta name="description" content="Join us.." />
<link rel="image_src" href="http://port11.de/files/cph_logo_0.png" />
</head>
<meta name="title" content="The Title Of The Link" />
<meta name="description" content="A description of the link would go here." />
<link rel="image_src" type="image/jpeg" href="http://www.domain.com/path/my_picture.jpg" />
<?php
require_once 'File/CSV/DataSource.php';
$path = "my_csv.txt";
$csv = new File_CSV_DataSource;
$csv->settings = array(
delimiter' => '|',
'eol' => ";",
'length' => 999999,
'escape' => '"'
);
<?php
if (isset($_GET["file"])) {
$file_name = $_GET["file"];
if (file_exists($file_name)) {
header(”Content-type: application/x-download”);
header(”Content-Disposition: attachment; filename=$file_name”);
header(”Content-Transfer-Encoding: binary”);
header(’Content-Length: ‘ . filesize($file_name));
ob_clean();
flush();
@steffenr
steffenr / cakephp.php
Created February 28, 2011 08:26
cakephp recursive
<?php
$this->Hour->Job->bindModel(array('hasOne' => array('UsersJob')));
$jobs = $this->Hour->Job->find('all', array(
'fields' => array('Job.id', 'Job.title', 'Job.description'),
'conditions' => array('UsersJob.user_id' => $this->user_id, 'Job.deleted' => 0),
'recursive' => 0
));
?>
@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) {