This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Show block on Taxonomy term listings | |
$make_block_visible = FALSE; | |
$vocab_id_to_trigger_show_block = 8; | |
if ((arg(0) == 'taxonomy') && (arg(1) == 'term')) { | |
$term_obj = taxonomy_get_term(arg(2)); | |
$vocab_id = $term_obj->vid; | |
if($vocab_id == $vocab_id_to_trigger_show_block){ | |
$make_block_visible = TRUE; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
htmlfile = File.new "output.html", "w" | |
csvfile = CSV.read "input.csv" | |
csvfile.each do |x,y| | |
htmlfile.puts "<h1>#{x}</h1>\n<p>#{y}</p>\n\n" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#views.py | |
def events_index(request, year): | |
selected_year = Year.objects.get(title=year) | |
events_list = Event.objects.filter(year = selected_year.id).order_by('category','start_date') | |
return render_to_response('events_list.html', {"events_list": events_list}) | |
#events_list.html | |
{% regroup events_list by category.title as events_list_by_category %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('mce_css', 'my_editor_style'); | |
function my_editor_style($url) { | |
if ( !empty($url) ) | |
$url .= ','; | |
// Change the path here if using sub-directory | |
$url .= trailingslashit( get_stylesheet_directory_uri() ) . 'editor-style.css'; | |
return $url; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Modifying TinyMCE editor to remove unused items. | |
*/ | |
function customformatTinyMCE($init) { | |
// Add block format elements you want to show in dropdown | |
$init['theme_advanced_blockformats'] = 'p,h1,h2,h3,h4,h5,h6,div'; | |
$init['theme_advanced_disable'] = 'justifyfull,pasteword'; | |
$init['theme_advanced_buttons2_add'] = 'styleselect'; | |
$init['theme_advanced_styles'] = 'Align Right=alignright, Align Left=alignleft'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function unhide_kitchensink( $args ) { | |
$args['wordpress_adv_hidden'] = false; | |
return $args; | |
} | |
add_filter( 'tiny_mce_before_init', 'unhide_kitchensink' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
function sidebarbrief_func($atts) { | |
extract(shortcode_atts(array('foo' => 'something'), $atts)); | |
global $more; // Declare global $more (before the loop). | |
$posts_query = new WP_Query( array( 'post_type' => array('brief'), 'tag_id' => 16, posts_per_page => 1 ) ); | |
$output = '<h1>News in Brief</h1>'; | |
while ( $posts_query->have_posts() ) : $posts_query->the_post(); | |
$more = 0; // Set (inside the loop) to display content above the more tag. | |
$output .= '<div class="brief">'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- formatting fun #1: tables! --> | |
<!-- use whitespace to mimic the layout you want. leave off optional end tags for readability --> | |
<table> | |
<caption>Selector engines, parse direction</caption> | |
<thead> | |
<tr><th>Left to right <th>Right to left | |
<tbody> | |
<tr><td>Mootools <td>Sizzle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 1. Put all timeline entries into array | |
$timeline_entries = array(); | |
// Retrieve entries sorted by date | |
$query = new WP_Query( array('post_type' => 'timeline-entry', 'posts_per_page' => -1, 'order' => 'ASC' , 'orderby' => 'meta_value', 'meta_key' => 'date' )); | |
if ($query->have_posts()): | |
while ( $query->have_posts() ): | |
$query->the_post(); | |
$date = get_custom_field('date'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Requires Content Type with image field with multiple images as described here: http://drupal.stackexchange.com/a/5901 | |
// Title is output as caption if there is title text | |
// Image size is determined by custom image style in Drupal admin named "gallery_thumb" | |
<?php | |
$gallery_images = $node->field_gallery_image['und']; | |
for($i = 0; $i < count($gallery_images); $i++) { | |
$image = $gallery_images[$i]; | |
$output = '<a href="' . file_create_url($image['uri']) . '">'; | |
$output .= '<img src="' . image_style_url("gallery_thumb", $image['uri']) . '">'; |
OlderNewer