Skip to content

Instantly share code, notes, and snippets.


Jason Glisson jasonglisson

View GitHub Profile
View dump_keys.php
{% for key, value in _context %}
<li>{{ key }}</li>
{% endfor %}
Or you can use:
{{ dump(_context|keys) }}
jasonglisson / add_to_menu.php
Last active Sep 14, 2017
Wordpress - Append this to the end of the main menu
View add_to_menu.php
function add_last_nav_item($items) {
return $items .= '<li><a href="#myModal" role="button" data-toggle="modal">Contact</a></li>';
jasonglisson / new_gist_file_0
Last active Sep 14, 2017
Disable all non-core modules
View new_gist_file_0
drush pml --no-core --type=module --status=enabled --pipe | xargs drush -y dis
jasonglisson / new_gist_file_0
Last active Sep 14, 2017
Wordpress - Print out content in a page template
View new_gist_file_0
while ( have_posts() ) : the_post(); ?> <!--Because the_content() works only inside a WP Loop -->
<div class="entry-content-page">
<?php the_content(); ?> <!-- Page Content -->
</div><!-- .entry-content-page -->
endwhile; //resetting the page loop
wp_reset_query(); //resetting the page query
jasonglisson / menu-depth
Last active Sep 14, 2017
Drupal 7: Embed menu with particular depth
View menu-depth
$menu_depth = 1;
print drupal_render(menu_tree_output(menu_tree_all_data('my-custom-menu', null, $menu_depth)));
View new_gist_file_0
Sync DB between two boxes - drush sql-sync @dev @jasons
Sync files between two boxes - drush rsync @dev:%files @jasons:%files
jasonglisson / strong-passwords.php
Created Jun 27, 2016 — forked from tylerhall/strong-passwords.php
A user friendly, strong password generator PHP function.
View strong-passwords.php
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
// Note: the $add_dashes option will increase the length of the password by
jasonglisson / views_template_module.php
Last active Sep 14, 2017
Drupal 7 - Have module load in views templates
View views_template_module.php
function NAME_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'NAME'),
'template path' => drupal_get_path('module', 'NAME'),
This will tell Views to look in the root directory of your module. I personally am a fan of adding a subdirectory to the module to hold template files. To do this append the directory name to the end of the template path, eg:
'template path' => drupal_get_path('module', 'NAME') . '/templates',
jasonglisson / table_render.php
Last active Sep 14, 2017
Render table in PHP
View table_render.php
$rows = 1;
if (($handle = fopen("<path to csv file>", "r")) !== FALSE) {
echo '<table class="table table-bordered toggle-square-filled default breakpoint footable">';
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
if ($rows == 1) {
echo '<thead><tr>';