1 / 16

Ubercart - немного примеров из жизни Moscow DrupalConf 2011

Ubercart - немного примеров из жизни Moscow DrupalConf 2011. Генеральный спонсор и организатор конференции DrupalConf 2011. При поддержке:. Спонсоры. Информационные спонсоры. Сайт конференции. дополнительные модули. Ordered Products Reports – отчёты по продуктам

salali
Download Presentation

Ubercart - немного примеров из жизни Moscow DrupalConf 2011

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ubercart - немного примеров из жизни Moscow DrupalConf 2011

  2. Генеральный спонсор и организатор конференции DrupalConf 2011 При поддержке:

  3. Спонсоры Информационные спонсоры Сайт конференции

  4. дополнительные модули • Ordered Products Reports – отчёты по продуктам • Product Power Tools – кастомизация формы добавления товара • Simple Shipping Quotes – кастомизация доставки • Ubercart Views – удобные отчёты • YML export – экспорт в Яндекс.Маркет • Views: IPP – параметрическая фильтрация View 4

  5. дополнительные модули 5

  6. чеки и квитанции 1. Ubercart -> uc_order -> uc_order.module -> function uc_order_actions, добавляем свою кнопку: if (user_access('view all orders')) { $alt = t('Распечатать квитанцию', $order_id); $actions[] = array( 'name' => t('View print kvit'), 'url' => 'admin/store/orders/kvit-ticket/'.$order->order_id, 'icon' => '<img src="'. base_path() . drupal_get_path('module', 'uc_store') .'/images/print-kvit.gif" alt="'. $alt .'" />', 'title' => 'Распечатать квитанцию', ); } 6

  7. чеки и квитанции 2. View -> страница -> admin/store/orders/kvit-ticket 7

  8. чеки и квитанции 3. views-view-field--ticket--page-1--title.tpl.php -> №, Наименование, Кол-во, Ед., Цена, руб., Сумма, руб. <?php $number_total = 0; $alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q'])); $class = explode('/', $alias); $total = db_query("SELECT title, qty, nid, price FROM d7gp1_uc_order_products WHERE order_id = ".$class[4]." ORDER BY order_product_id"); while ($row = db_fetch_object($total)) { print '<tr>'; $number_total = $number_total + 1; print '<td bgcolor="white">'.$number_total.'</td>'; print '<td bgcolor="white">'.$row->title.'</td>'; print '<td bgcolor="white">'.$row->qty.'</td>'; $ed_total = db_query("SELECT body FROM d7gp1_node_revisions WHERE nid = ".$row->nid); while ($ed_total_res = db_fetch_object($ed_total)) { print '<td bgcolor="white">'.$ed_total_res->body.'</td>'; } $price_total = $row->price; $price_total = explode('.', $price_total); print '<td bgcolor="white">'.$price_total[0].'</td>'; print '<td bgcolor="white">'.$row->qty * $row->price.'</td>'; print '</tr>'; } ?> 8

  9. чеки и квитанции 4. views-view-field--ticket--page-1--title.tpl.php -> Итого <?php $or_total = db_query("SELECT order_total FROM d7gp1_uc_orders WHERE order_id = ".$class[4]); while ($or_total_res = db_fetch_object($or_total)) { $or_total_print = $or_total_res->order_total; $or_total_print = explode('.', $or_total_print); print $or_total_print[0]; } ?> 9

  10. блок других форм данного товара <?php // Флаг типа вывода $my_print = false; if ($node = menu_get_object()) { // Устанавливаем ограничение на колличество выводимых сниппетом нод. $num_nodes = 10; // ID нужного словаря. $voc_id = 11; // 1 - нода опубликована, 0 - не опубликована. $status = 1; // Функция вызывает термины, относящиеся к конкретной ноде и определенному словарю. $terms = taxonomy_node_get_terms_by_vocabulary($node, $voc_id); // Если такие термины имеются foreach ($terms as $term) { $sql = "SELECT DISTINCT n.nid FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE n.status = %d AND tn.tid = %d AND n.nid <> %d ORDER BY n.created DESC"; // Получаем ID нод связанных с данными терминами $total = db_query_range(db_rewrite_sql($sql), $status, $term->tid, $node->nid, 0, $num_nodes); 10

  11. блок других форм данного товара print '<table><tr><td><div>Другие формы данного товара</div></td></tr><tr><td>'; // Перебираем возвращённые результаты с ID нод while ($row = db_fetch_object($total)) { // Загружаем представление $view = views_get_view('uc_products_block_upakovka'); // Передаём ему аргумент $view->args[0] = $row->nid; // Строим результат $view->execute_display('block_1'); // Офрмляем результат $output = '<table><tr><td><div>'; $output .= $view->render_field('title', 0).'<br><br>'; $output .= $view->render_field('sell_price', 0).'<br>'; $output .= $view->render_field('buyitnowbutton', 0); $output .= '</div></td><td>'; $output .= $view->render_field('field_image_cache_fid', 0); $output .= '</td></tr></table>'; // Выводим результат print $output; $my_print = true; } print '</td></tr></table>'; } } 11

  12. избавление от дублей страниц и правильная 404 страница Модуль - duplicate_pages_and_404_page: // Отсечение: NodeURL-крякозябры, NodeURL/кракозябры, NodeURL?кракозябры. // Отсечение: TaxonomyURL-крякозябры, TaxonomyURL/кракозябры, TaxonomyURL?кракозябры. // Отсечение: TaxonomyURL?page=1-крякозябры, TaxonomyURL?page=1/кракозябры, TaxonomyURL?page=1?кракозябры. // Отсечение: ViewURL-крякозябры, ViewURL/кракозябры, ViewURL?кракозябры. // Отсечение: ViewURL?page=1-крякозябры, ViewURL?page=1/кракозябры, ViewURL?page=1?кракозябры. // Включить: SustemURL, !!! SustemURL?переменная !!!, NodeMain, NodeMain?page=1, ViewMain, ViewMain?page=1, !!! если скобки в URL !!!.// Отсечение: /?кракозябры, /?page=1-крякозябры, /?page=1/кракозябры, /?page=1?кракозябры. // Исключить: taxonomy/term/741/0. 1. hook_init() – используемый хук. 2. $url_path = request_uri(); - URL views node. 3. $real_path = $_GET['q']; - Real URL node. 4. Pathauto – модуль хранящий URL нод сайта в специальной таблице. 5. drupal_not_found(); - выдаётся на все неподходящие адресса. 6. Customerror – модуль обрабатывающий drupal_not_found и в котором выставляется перенаправление на собственную 404. 12

  13. кастомизация формы создания товара /** * Реализация hook_form_alter(), позволяет вносить изменения в форму перед её показом. */ function delete_field_my_form_form_alter(&$form, &$form_state, $form_id){ // Если «$form_id» равен идентефикатору нужной формы. if ($form_id == 'product_node_form') { if (isset($form['body_field'])) { // Скрываем поле «Показывать анонс в полной версии» $form['body_field']['teaser_include']['#type'] = 'hidden'; // Изменяем размер поля «Описание» $form['body_field']['body']['#rows'] = 1; } } 13

  14. Спасибо за потраченное время Вячеслав E-mail: sonwol@yandex.ru 14

  15. Генеральный спонсор и организатор конференции DrupalConf 2011 При поддержке:

  16. Спонсоры Информационные спонсоры Сайт конференции

More Related