Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $emptyTextVue = $view->display_handler->get_option('empty');
- $emptyText = $view->display_handler->set_option('empty','<div class="ma-classe">Pas images.</div>');
- $handler->display->display_options['empty']['area']['content'] = 'Pas d'images à afficher.';
- // Load the view.
- $view = views_get_view('VIEW_NAME');
- // Set the options for the header text.
- // To get an idea of what options are available, set up a view with header text
- // and then use the devel module to print out the view definition.
- // For example, add a header text area field and print it with
- // dpm($view->header['area']); after you have loaded it with views_get_view().
- $header_options = array(
- 'label' => t('Header text'), // Administrative label. Not really needed here.
- 'content' => 'This is the header text content.', // Content of header text.
- 'format' => 'filtered_html', // Format of header text.
- 'empty' => 1, // Show even when there are no results. Set to zero otherwise.
- );
- // This adds a header handler for a text area. The table is views because it is not
- // a database field. The field is area because it is a text area.
- // The header_options are the settings.
- $view->add_item('DISPLAY_NAME', 'header', 'views', 'area', $header_options);
- // This is the preferred way to get the rendered view.
- $output = $view->preview('DISPLAY_NAME');
- // If you want you can check for results with this.
- if (!empty($view->result)) {
- // Do something if there are rows.
- }
- $view->add_item('DISPLAY_NAME', 'footer', 'views', 'area', $footer_options);
- $view->add_item('DISPLAY_NAME', 'empty', 'views', 'area', $empty_options);
- /**
- * Implementation of hook_views_pre_view().
- *
- * Change the set filter to be the current Quarter/Year set in the CCS admin area.
- */
- function courses_db_views_pre_view(&$view, &$display_id, &$args) {
- // This is /DEPT/courses
- #dpm($view);
- if ($view->name == 'departmental_courses') {
- $filter =& $view->filter;
- $fall_tid = 11;
- $year_2012_tid = 26;
- // We created these _tid variables so that we didn't have to look up the TID
- // on every page view by students.
- $q = variable_get('ccs_current_quarter_tid', $fall_tid);
- $y = variable_get('ccs_current_year_tid', $year_2012_tid);
- $view->display[$display_id]->handler->options['filters']['field_coursedb_quarter_tid']['value'] = $q;
- $view->display[$display_id]->handler->options['filters']['field_coursedb_year_tid']['value'] = $y;
- }
- if ($view->name == 'courses_for_instructor') {
- #dpm($view->display['block']->handler, 'handler');
- $quarter = variable_get('ccs_current_quarter', 'Fall');
- $year = variable_get('ccs_current_year', '2012');
- $view->display['block']->handler->options['title'] = t('@quarter @year Instructor of:', array('@quarter' => $quarter, '@year' => $year));
- $view->args[0] = $year;
- $view->args[1] = $quarter;
- #dpm($view->display['block']->handler, 'handler');
- }
- }
- /**
- * Implementation of hook_views_post_execute().
- *
- * For a view listing of migrated course data, show original legacy
- * data in the view header to allow auditing/verification of the
- * migrated data.
- */
- function courses_db_views_post_execute(&$view) {
- if ($view->name == 'migration_audits') { # Courses
- $drupal_nids = array();
- if (count($view->result)) {
- foreach ($view->result as $i => $node) {
- $drupal_nids []= $node->nid;
- }
- }
- $ccs_sql = <<<EOFSQL
- SELECT mccd.*
- FROM ccs_dump.mos_ccs_courses_db mccd
- LEFT JOIN ccs_dump.migrate_map_csscourse mmc ON mmc.sourceid1 = mccd.id
- WHERE mmc.destid1 IN (:drupal_nids)
- EOFSQL;
- $result = db_query($ccs_sql, array(':drupal_nids' => $drupal_nids));
- $output = '';
- foreach ($result as $course) {
- #dpm($course);
- $title = html_entity_decode($course->course_title, ENT_COMPAT, 'UTF-8');
- $instructors = html_entity_decode($course->instructor, ENT_COMPAT, 'UTF-8');
- $output .= "<div class="entry">$course->quarter $course->year - $title Instructors: $instructors</div>";
- }
- $ccs_values = "<style type="text/css">div.legacy_values { background-color: pink;} div.legacy_values div.entry { padding-bottom: 5px; }</style><div class="legacy_values">$output</div>";
- $view->display['page']->handler->handlers['header']['area_1']->options['content'] = $ccs_values;
- $view->display['page']->handler->handlers['header']['area_1']->options['empty'] = 0;
- }
- }
- $viewname_ag1 = 'Actualites_liste_globale';
- $view = views_get_view ($viewname_ag1);
- $viewdisplay_ag1 = $view->set_display('block_1');
- //$args_ldj1 = $view->set_arguments(array($node->nid));
- //$emptyTextVue = $view->display_handler->get_option('empty');
- $emptyText = $view->display_handler->set_option('empty','<div class="vue-txt-vide">Pas de contenu à afficher pour cette année.</div>');
- //Code change avec Views3
- $view->display['block_1']->handler->handlers['header']['area_1']->options['content'] = "texte header embed_views";
- //Exécution de le vue
- $view->pre_execute();
- $view->execute();
- if (!empty($view->result)) {
- // S'il y a un resultat on récupère le titre (ajoute tag h3, et le contenu)
- $output = '<div id="bloc_actus_globales"><h3 class="classe-h3">'.$view->get_title().'</h3>' .$view->preview($viewdisplay_ag1).'</div>';
- //Affiche la vue si contenu
- print $output;
- }
- //sinon affiche texte vide
- elseif (empty($view->result)) {
- //Formatage du texte vide,ajout du titre de la vue
- $outputEmpty = '<div id="bloc_actus_globales"><h3 class="classe-h3">'.$view->get_title().'</h3>'.$emptyText.'</div>';
- // $outputEmpty = '<div id="bloc_actus_globales"><h3 class="classe-h3">'.$view->get_title().'</h3>'.$emptyTextVue.'</div>';
- // drupal_set_message('$EmptyTextVue : '.$emptyTextVue.'status');
- //Affichage du texte vide
- print $outputEmpty;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement