Tag Archive for theme

wordpress – automatically create Greybox imageset from images attached to post

<!--Automatic Greybox-->
<?php
//Die zum Post gehoerenden Bilder ins Array $images schreiben
//Put images from post in to array $images. Order by menu order defined in post gallery
$images = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );

//Pruefen, ob dem Beitrag Bilder angehaengt wurden.
//check if there are any images attached to the post
if (isset($images))
{
//Den Zaehler auf 0 setzen
//set counter to 0
$count=0;
//Alle Bilder im Array $images nacheinander durchlaufen
//go through all images in array $images
foreach( $images as $image )
{
$imageID = $image->ID;
//fuer jedes Bild im Array die URL von sowohl der Mittleren, als auch der grossen Groesse ermitteln.
//get medium and large image url for image
$medImageSrc = wp_get_attachment_image_src($imageID, $size='medium', $icon = false);
$largeImageSrc = wp_get_attachment_image_src($imageID, $size='large', $icon = false);

//Wenn es sich um das erste Bild im Array handelt...
//If it's the first image in the array
if ($count==0)
{
//Den Greybox-Code mit einem Vorschaubild ausgeben
//output Greybox Code with medium size preview
echo"<a href='$largeImageSrc[0]' rel='shadowbox[Bilder]'><img src='$medImageSrc[0]' border='0'></a>";
}
//alle Bilder ,die nach dem erstern Bild kommen
//this is for all the images that come after the first one
else
{
//unsichtbare Greybox-Verknuepfung darstellen.
//create invisible Greybox-Links without preview image
echo"<a href='$largeImageSrc[0]' rel='shadowbox[Bilder]'></a>";
}
//Zaehler erhoehen.
//increase counter
$count++;

} //foreach
}

?>

<!--ENDE Automatic Greybox -->

source

WordPress – Get current category name and / or ID

<?php
//AKTUELLE Post-KATEGORIE-ID ermitteln
foreach((get_the_category()) as $category)
{
$postcat= $category->cat_ID;
$catname =$category->cat_name;
//echo $postcat;
}
?>

source

WordPress display content of a category on a page

<?php if (is_page('pagename')) { query_posts('cat=yx') } ?>

<!--or use query_posts like this:(full loop)-->

<?php
$displayposts = new WP_Query();
$displayposts->query('cat=5');
while ($displayposts->have_posts()) : $displayposts->the_post();
?>
<?php the_content('read more...'); ?>
<?php edit_post_link('edit', '', ''); ?>

<?php endwhile; ?>

source

WordPress theme directory

<?php bloginfo('template_directory'); ?>/

source

Developer only stylesheet

<?php if ($GLOBALS['user']->uid == 1): ?>
<style type="text/css" media="screen">
@import  url(/<?php print $directory ?>/style-dev.css);
</style>
<?php endif ?>

source

Theme the Drupal attachments table

<?php
/**
* Themed attachments table
*/
$header = array(t('File name'), t('Size'));
$rows = array();
foreach ($files as $file) {
if ($file->list) {
$type = explode('/', $file->filemime);
// Quick fix. Should use some kind of make_safe_for_css() function.
$type = str_replace('.', '-'. $type[1]);
$href = check_url(($file->fid ? file_create_url($file->filepath) : url(file_create_filename($file->filename, file_create_path()))));
/* To do:
if (!empty($file->description)) {
$text = check_plain($file->description) . '<br /><span class="filename">'.$file->filename.'</span>';
}
else {
$text = check_plain($file->filename);
}
*/
$text = check_plain($file->description ? $file->description : $file->filename);
// Because the drupal format_size function doesn't round far enough to be smooth.
$size = $file->filesize;
$suffix = t('bytes');
if ($size >= 1024) {
$size = round($size / 1024, 0);
$suffix = t('KB');
}
if ($size >= 1024) {
$size = round($size / 1024, 0);
$suffix = t('MB');
}

$size = array('data' => t('%size %suffix', array('%size' => $size, '%suffix' => $suffix)), 'class' => 'size');

if ($type == 'jpeg' ) {
$text = array('data' => l($text, $href, array('title' => 'Right click to download', 'class' => 'thickbox'), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = TRUE), 'class' => $type);
}
else {
$text = array('data' => l($text, $href, array('title' => 'Right click to download'), $query = NULL, $fragment = NULL, $absolute = FALSE, $html = TRUE), 'class' => $type);
}
$rows[] = array($text, $size);
}
}

if (count($rows)) {
print '<div class="attachments">'. theme('table', $header, $rows, array('class' => 'attachments'), 'Downloadable files') .'</div>';
}

source

Drupal custom styles for upload attachments table

/* @group Attachments table */
table.attachments caption {
display: none;
}
table.attachments {
border-color: #CCC;
border-width: 1px;
border-style: solid none none solid;
width: auto;
}
table.attachments thead { border: 1px solid #CCC }
table.attachments td {
line-height: 24px; padding: 0;
border-right: 1px solid #CCC;
border-bottom: 1px solid #CCC;
}
table.attachments tr {
border-right: 1px solid #CCC;
}
table.attachments td a {
line-height: 24px;
padding: 0 26px;
background-position: 5px;
background-repeat: no-repeat;
}
table.attachments th {
background-color: #F2F2F2;
font-weight: normal;
font-family: Arial, Helvetica, "Lucida Grande", "Lucida Sans Unicode", Verdana, sans-serif;
font-size: 77%;
}
table.attachments td.size {
padding: 0 5px;
font-family: Arial, Helvetica, "Lucida Grande", "Lucida Sans Unicode", Verdana, sans-serif;
font-size: 77%;
color: #404040;
font-style: normal;
}
/* @end */
/* @group Mime-type icons */
.pdf a, .application-pdf a {
background-image: url(images/icon-pdf.gif); }
.jpeg a, .jpg a, .png a, .gif a {
background-image: url(images/icon-image.png); }
.eps a, .application-postscript a {
background-image: url(images/icon-postscript.png); }
.html a, .text-html a {
background-image: url(images/icon-html.gif); }
.qt a, .video-quicktime a {
background-image: url(images/icon-quicktime.gif); }
.ical a, .text-calendar a {
background-image: url(images/icon-ical.gif); }
.dl a {
background-image: url(images/icon-download.gif); }
.dmg a, .application-x-diskcopy a {
background-image: url(images/icon-dmg.gif); }
.zip a, .application-zip a {
background-image: url(images/icon-zip.gif); }
.audio a, .audio-mpeg a {
background-image: url(images/icon-audio.gif); }
.website a {
background: url(images/icon-website.gif) left center no-repeat;
margin: 0; padding: 2px 0 2px 25px; line-height: 25px; }
.doc a, .msword a {
background-image: url(images/icon-doc.png); }
.txt a  {
background-image: url(images/icon-txt.gif); }
/* @end */

source

Drupal breadcrumb override

/**
* Make breadcrumbs include the current page as an inactive crumb
* Also, remove the top level for image_galleries.
*/
function phptemplate_breadcrumb($breadcrumb) {
if (!empty($breadcrumb)) {
$breadcrumb_new = array();
// Create new breadcrumb array without the top level image gallery link
foreach ($breadcrumb as $crumb) {
if (strstr($crumb, '<a href="/image">') != TRUE) {
$breadcrumb_new[] = $crumb;
}
}
$breadcrumb_new[] = '<span class="active">'. drupal_get_title() .'</span>';
return '<div class="breadcrumb">'. implode(' » ', $breadcrumb_new) .'</div>';
}
}

source

Drupal primary links

<?php
/**
* Option 1
*******************************************************/ ?>

<?php if (isset($primary_links)) : ?>
<?php print theme('links', $primary_links, array('class' => 'links primary-links clear-block')) ?>
<?php endif; ?>

<?php if (isset($secondary_links)) : ?>
<?php print theme('links', $secondary_links, array('class' => 'links secondary-links clear-block')) ?>
<?php endif; ?>

<?php
/**
* Option 2
*******************************************************/ ?>

<?php if (isset($primary_links)) { ?>
<div id="primary-links">
<?php print theme('menu_tree',variable_get('menu_primary_menu',0)); ?>
</div>
<?php } ?>

<?php
/**
* Option 3
*******************************************************/ ?>

<?php if (isset($primary_links)) {
print theme('links', $primary_links, array('class' => 'links primary-links clear-block'));
} ?>

source

Angel LMS Course Title Image Replacement

#bannerSection h1 {
background: black url( your-image-url ) no-repeat;
height:100px; /* height of your image */
margin:0.5em auto 0 0.8em;
padding:0.4em 0 0.4em 25px;
text-indent:-9999px;
width:auto;
}

source