Last active
December 17, 2015 22:48
-
-
Save ruizfrontend/5684241 to your computer and use it in GitHub Desktop.
Drupal 7 common theme functions
This file contains hidden or 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
// _-______Basic translatable string_______________________________ | |
<?php print t('STRING !VARIABLE1 @VARIABLE2 %VARIABLE3', array( | |
'@VARIABLE2' => 'VALUE ESCAPED & FORMATED', | |
'%VARIABLE3' => 'VALUE ESCAPED', | |
'!VARIABLE1' => 'VALUE AS IS', | |
)); ?> | |
// _-______string translatable with link_______ | |
// _-______Basic link_______________________________ | |
<?php print l(t('TEXT'), 'URL', | |
array('fragment' => 'VALUE' //#VALUE | |
'query' => array('QUERY' => 'VALUE') | |
'attributes' => array( | |
'id' => 'ID', | |
'class' => 'CLASS', | |
'target' => '_blank' | |
), | |
); | |
); ?> | |
// _-______Print fields with multiple values_______________________________ | |
<?php if(isset($content['FIELD'])): ?> | |
<?php foreach($content['FIELD']['#items'] as $key => $item): ?> | |
<?php print $content['FIELD']; ?> | |
<?php endforeach; ?> | |
<?php endif; ?> | |
// _-______print a simple image inside the preivious loop_______________________________ | |
<? print theme('image', array( | |
'path' => $item['uri'], | |
'alt' => $item['alt'], | |
'attributes' => array('class' => 'img-'.$key), | |
)); ?> | |
// _-______print a image with image styles inside the preivious loop_______________________________ | |
<? print theme('image_style', array( | |
'path' => $item['uri'], | |
'alt' => $item['alt'], | |
'attributes' => array('class' => 'img-'.$key), | |
'style_name' => '480x350', | |
)); ?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some Drupal theming snippets I use too often