½‚µ³€°†¸ ¯½´µ µ€²µ€

  • View
    6.152

  • Download
    10

Embed Size (px)

DESCRIPTION

Алексей МироновИнтеграция Яндекс Сервер

Text of ½‚µ³€°†¸ ¯½´µ...

  • 1. Drupal .= .;
    • DrupalConf. . 03.12.2011

2. ? 3. FreeBSD6.3, 7.0 (32/64) Linux2.6.x (32/64) Windows2000/XP/2003 (32/64) HTTP (ODBC) 4.

  • yandex.ru
  • , , (, )
  • .
  • HTTP. -
  • XML. C

5. (Linux) $sudodpkg -i Yandex_Server-2010.9.0-Linux-x86_64.deb $ cat /usr/local/etc/yandex/yandex.cfg $sudo/etc/init.d/yandex-server.shre start http://api.yandex.ru/server/doc/concepts/y-server-ee.xml#quickstart 6. http://help.yandex.ru/search/?id=1111313 http://api.yandex.ru/server/doc/concepts/query-zones-and-attributes-search.xml 7. 8. ... 9. ... yserver :http://drupal.org/sandbox/Mir/1343080 :http://drupal.org/project/yserver

  • (PHP):
  • PHP SimpleXML Extension
  • PHP cURL Extension
  • Drupal Search Module [Core]

10. http://your_drupal_site.ru / yserver-dump ? mode=force_new & type=strict http://your_drupal_site.ru/yserver-dump? mode=update & type=queue http://your_drupal_site.ru/yserver-dump? mode=force_new & type=queue Cron: */30 * * * * /usr/bin/wget -O - -q -t 1 http://your_drupal_.site.ru/yserver-dump?mode=update&type=queue && /path_to_yserver_script/yserver.sh reindex 11. 12. functionyour_module_init() { if (function_exists( 'yserver_remove_areas' )) { // // . yserver_remove_areas(); your_module_set_area( 'node' , array( 'your_module_get_node_ilist' ), array( 'yserver_get_node_idata' )); }} ... 13. functionyour_module_get_node_ilist() { $query=" SELECTnid, changedFROM{node} WHEREstatus = 1 " ; $result= db_query( $query ); $nids= array(); foreach( $result as $record ) { $nids [ $record ->nid] =$record ->changed; } return $nids ; } (id => ) 14. functionyour_module_get_node_idata ( $nid ) { $node= node_load( $nid ); $icontent=''.$node ->title .'' . render(node_view( $node ,'full' )); $ialias= drupal_get_path_alias('node/'.$nid ); return array( 'content'=>$icontent , 'attrs'=> array( 'ys_title'=>$node->title , 'ys_link' =>$ialias , )); } id 15. functionyour_module_form_search_block_form_alter(& $form , $form_state){ $form [ '#submit' ] = array( 'your_module_search_box_form_submit' ); } functionyour_module_search_box_form_submit( $form , & $form_state ){ $form_id=$form [ 'form_id' ][ '#value' ]; // . $keys=$form_state [ 'values' ][ $form_id ]; $path='search/yserver/' . trim( $keys.'@ysoutbox@ys_area:node_article' ); //$path .= ' ys_tag:football' ; $form_state [ 'redirect' ] =$path ; } URL ( ): http://your_drupal_site.ru/search/yserver/ @ysoutbox@ ys_area:node_article : 16. SERP template.php: functionyour_theme_preprocess_search_result(& $variables ) { dvm( $variables [ 'result' ][ 'ys_attrs' ]); } search-result.tpl.php: print$ys_attrs [ 'type' ] .', ' .$ys_attrs [ 'subtype' ] . ':::' .$ys_attrs [ 'address' ]; print$snippet ; 17. !