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 | |
/* | |
* Check if URL is YouTube | |
*/ | |
function _is_youtube($url) | |
{ | |
return (preg_match('/youtu\.be/i', $url) || preg_match('/youtube\.com\/watch/i', $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
$view = new view(); | |
$view->name = 'user_s_comissions'; | |
$view->description = ''; | |
$view->tag = 'default'; | |
$view->base_table = 'commerce_affiliate_commission'; | |
$view->human_name = 'User\'s Comissions'; | |
$view->core = 7; | |
$view->api_version = '3.0'; | |
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ |
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 mymodule_form_alter(&$form, &$form_state, $form_id) { | |
switch($form_id){ | |
case 'views_exposed_form': | |
foreach ($form['field_marka_prochnosti_tid']['#options'] as $tid => &$value) { | |
$query = db_select('field_data_field_marka_prochnosti', 'f') | |
->condition('f.field_marka_prochnosti_tid', $tid); | |
$query->addExpression('COUNT(*)'); | |
$count = $query->execute()->fetchField(); | |
$value = $value . ' (' . $count . ')'; |
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
/* Working with template suggestions */ | |
https://www.drupal.org/node/1089656 | |
/* Overview of theme files */ | |
https://www.drupal.org/node/171194 |
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 | |
/** | |
* Implements hook_permission(). | |
*/ | |
function YOUR_MODULE_permission() { | |
return array( | |
'YOUR MODULE article unpublish articles' => array( | |
'title' => t('YOUR MODULE Article Unpublish'), | |
), | |
); |
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 | |
print views_embed_view('VIEWS_MACHINE_NAME', 'DISPLAY_ID', $view_arg); | |
$view = views_get_view('VIEWS_MACHINE_NAME'); | |
$view->set_display('DISPLAY_ID'); | |
print $view->get_title(); | |
print $view->preview('DISPLAY_ID'); | |
?> |
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. | |
// Create your view the regular way. | |
// 2. | |
// Define your views api version and path for files that include views hooks. | |
/** | |
* Implementation of hook_views_api(). | |
*/ | |
function HOOK_views_api() { |
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 | |
/* | |
CREATE TABLE example_table ( | |
nid INT(11) NOT NULL, | |
plain_text_field VARCHAR(32, | |
numeric_field INT(11), | |
boolean_field INT(1), | |
timestamp_field INT(8), | |
PRIMARY KEY(nid) |
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 MYMODULE_cron() { | |
$query = new EntityFieldQuery; | |
$result = $query->entityCondition('entity_type', 'node') | |
->propertyCondition('type', 'YOUR-CONTENT-TYPE') | |
->execute(); | |
if (isset($result['node']) && count($result['node'])) { | |
$node_ids = array_keys($result['node']); |
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 mytheme_preprocess_page(&$variables) { | |
if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2))) { | |
//kiểm tra + thêm điều kiện khi mình muốn load suggestion cho term hoặc vocalbulary nào | |
$variables['theme_hook_suggestions'][] = 'page__taxonomy_term'; | |
} | |
} | |
// Vào thư mục 'templates' tạo file page--taxnomy_term.tpl.php ..overwrite page |
OlderNewer