Skip to content

Instantly share code, notes, and snippets.

View frankyonnetti's full-sized avatar

Frank Yonnetti frankyonnetti

View GitHub Profile
@frankyonnetti
frankyonnetti / drupal7-taxonomy-in-nodes.php
Last active February 17, 2021 03:43
Drupal 7 - taxonomy term names in nodes #drupal #d7 #taxonomy
<?php // http://drupal.org/node/224171
$nodeterms = array();
foreach($node->taxonomy as $nodeterm) {
$nodeterms[] = $nodeterm->name;
} if (in_array('TERM-NAME', $nodeterms)): ?>
Do something...
<?php endif; ?>
@frankyonnetti
frankyonnetti / drupal7-mod-date.php
Last active February 17, 2021 03:42
Drupal 7 - display last modification date #drupal #d7
<?php // http://drupal.org/node/43512
print date('j F Y - g:ia', $node->changed);
?>
<?php // if checked in content-type edit
if ($submitted) {
echo 'This page was last modified on ' . date( "F j, Y",$node->changed);
};
?>
@frankyonnetti
frankyonnetti / drupal6-submitted.php
Last active February 17, 2021 03:42
Drupal 6 - change submitted format #drupal #d6
<?php
/*
* Drupal 6 - zen theme
*/
print t('@date', array(
'@date' => format_date($node->created, 'custom', 'l, F j, Y'),
'!username' => theme('username', $node)
));
?>
@frankyonnetti
frankyonnetti / css-resize-textarea.css
Last active February 17, 2021 03:41
CSS - resizable text area #css
textarea {
-moz-resize: vertical;
-webkit-resize: vertical;
resize: vertical;
}
@frankyonnetti
frankyonnetti / drupal7-replace.php
Last active February 17, 2021 03:41
Drupal 7 - replace spaces with dashes #drupal #d7 #php
<?php
$match=strtolower($node->title); print $node_field[0]['value'] = str_replace(' ', '-', $match);
?>
@frankyonnetti
frankyonnetti / drupal-content-type-view.php
Last active February 17, 2021 03:38
Drupal - if content type in views block tpl or node #drupal
<?php //set var to identify content type
$node_type = $row->_field_data['nid']['entity']->type;
?>
<?php //check for content types
if ($node_type == 'CT_NAME' || $node_type == 'CT_NAME_OTHER'):
?>
Do something...
<?php endif; ?>
@frankyonnetti
frankyonnetti / drupal7-print-view.tpl.php
Last active February 17, 2021 03:37
Drupal 7 - print view #drupal #d7
<?php
/*
* http://robotlikehuman.com/web/how-print-view-drupal-7-and-drupal-6
* Replace VIEW_NAME with the exact machine_name of the View.
*/
$viewName = 'VIEW_NAME';
print views_embed_view($viewName);
?>
@frankyonnetti
frankyonnetti / drupal7-content-types.php
Last active May 22, 2021 19:22
Drupal 7 - print content type fields #drupal #d7
// default field output
<?php print render($content['field_EXAMPLE']); ?>
<?php print render($content['body']); ?>
// striped output only
<?php print render($content['field_EXAMPLE']['und'][0]['value']); ?>
<?php print render($content['field_EXAMPLE']['und'][0]['url']); ?>
<?php print render($content['field_EXAMPLE']['und'][0]['email']); ?>
// make sure field isn't empty
@frankyonnetti
frankyonnetti / drupal6-comments-remove-homepage.php
Last active February 17, 2021 03:36
Drupal 6 - remove homepage field #drupal #d6
/**
* First register the override in your template.php file (my example uses a zen subtheme)
* http://drupal.org/node/147502#comment-1654954
*/
<?php
/**
* Implementation of zen HOOK_theme().
*/
function YOUR-THEME-NAME_theme(&$existing, $type, $theme, $path) {
@frankyonnetti
frankyonnetti / drupal6-submitted.php
Last active February 17, 2021 03:35
Drupal 6 - comment submitted by #drupal #d6
<?php
/**
* Change the output for submmited by in comments
*/
function rrm_comment_submitted($comment) {
return t('Posted by !username at @time', array(
'!username' => theme('username', $comment),
'@date' => format_date($comment->timestamp, 'custom', 'd M Y'),
'@time' => format_date($comment->timestamp, 'custom', 'g:i a')
));