Drupal commerce get cart ajax have 302 code

function custom_ajax_cart_form_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'views_form_commerce_cart_block_default') {
    if (!empty($form['edit_delete'])) {
      foreach ($form['edit_delete'] as &$delete_button) {
        $delete_button['#ajax'] = array(
          'callback' => '_custom_ajax_cart_block_ajax_remove_cart_line_item_callback'
        );
      }
    }
  }
}

// remove block cart callback. wrapper cart block.
function _custom_ajax_cart_block_ajax_remove_cart_line_item_callback($form, &$form_state) {
  // views_form_views_form_submit($form, $form_state);
  // commerce_line_item_line_item_views_delete_form_submit($form, $form_state);
  // commerce_cart_line_item_delete_form_submit($form, $form_state);
  $res = _custom_ajax_cart_form_ajax_cart_reload(); //Retrieve the new cart view
  $commands = array();
  $commands[] = ajax_command_replace("#block-commerce-cart-cart .cart-empty-block", "
"); $commands[] = ajax_command_html('#block-commerce-cart-cart .cart-contents', $res); // my custom html id $commands[] = ajax_command_html('#cart-i', $res); $commands[] = ajax_command_invoke(".cart-i-c", 'fadeIn'); return array('#type' => 'ajax', '#commands' => $commands); } function _custom_ajax_cart_form_ajax_cart_reload() { global $user; // The name of the view we are going to load. // Array of arguments we set for the view. Only one argument in our example. // your actual view may require additional arguments which you may need to set. $view_name = 'commerce_cart_block'; $args = array(commerce_cart_order_id($user->uid)); // The display id of for the view. $displayId = 'default'; // Call the views_embed_view function to returned themed view output $res = views_embed_view($view_name, $displayId, $args); return $res; }

c

Ubuntu Install redmine

安装redmine分为两个步奏
1. 下载redmine 并且. 导入数据库到你的表,一切根据这里来执行, 到Step 9 – Test the installation停止.
提示:如果你的命令执行不成功请一定要在下载的redmine目录下面执行

下载.

$cd /usr/local/share/
$git clone https://github.com/redmine/redmine.git
$cd redmine

http://www.redmine.org/projects/redmine/wiki/RedmineInstall

2. 安装支持apache
http://www.modrails.com/documentation/Users%20guide%20Apache.html#install_on_debian_ubuntu
Run:
passenger-install-apache2-module
当命令运行完成以后会返回这样的字符串:

--------------------------------------------
The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-4.0.10/buildout/apache2/mod_passenger.so
   PassengerRoot /var/lib/gems/1.8/gems/passenger-4.0.10
   PassengerDefaultRuby /usr/bin/ruby1.8

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!

Press ENTER to continue.


--------------------------------------------
Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere. Add a virtual host to your
Apache configuration file and set its DocumentRoot to /somewhere/public:
   
      ServerName www.yourhost.com
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /somewhere/public    
      
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
      
   

And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:

然后我们来增加一个apache 的模块. 因为我的ubuntu分别把模块的 load 和 conf 文件分开,所以我需要创建两个文件.

$vim /etc/apache2/mods-available/passenger.load

//write.
LoadModule passenger_module /var/lib/gems/1.8/gems/passenger-4.0.10/buildout/apache2/mod_passenger.so

$vim /etc/apache2/mods-available/passenger.conf

PassengerRoot /var/lib/gems/1.8/gems/passenger-4.0.10
PassengerDefaultRuby /usr/bin/ruby1.8

来配置apache, 其实就增加了这么一段代码 Options -MultiViews

$vim /etc/apache2/sites-available/redmine


        ServerName redmine.example.com
        DocumentRoot /usr/local/share/redmine/public
        
                Options FollowSymLinks
                AllowOverride All
        
        
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                AllowOverride all
                # MultiViews must be turned off.
                Options -MultiViews
                allow from all

        


// enable site
sudo a2ensite redmine

Centos + Nginx + Readmine + Passenger
http://passenger.stealthymonkeys.com/

为Node 添加一个contextual 链接/ hook_contextual_links_view_alter()

安装了nodequeue模块,但是在一个node block中却没有这个快捷的链接. 现在手动加这个链接到contextual.
查看更多: hook_contextual_links_view_alter() API

相关模块 CCL

/**
 * Implements hook_contextual_links_view_alter().
 */
function mymodule_contextual_links_view_alter(&$element, $items) {
  if (isset($element['#element']['#node']) && isset($element['#element']['#bundle']) && $element['#element']['#bundle'] == 'wine_product') {
    $links = &$element['#links'];
    $links['node-add-to-queue'] = array(
      'title' => t('Add to queue'),
      'href' => 'node/' . $element['#element']['#node']->nid . '/nodequeue',
    );
  }
}

Ubuntu Gnome经常死机,清空默认的配置


#!/bin/sh
rm -rvf ~/.compiz-1/
rm -rvf ~/.cache/compizconfig-1/
rm -rvf ~/.cache/dconf/
rm -rvf ~/.cache/unity/
rm -vf ~/.cache/unity-lens-video
rm -rvf ~/.config/compiz-1/
rm -rvf ~/.config/dconf/
rm -rvf ~/.config/gnome-control-center/
rm -rvf ~/.config/gnome-session/
rm -rvf ~/.gconf/
rm -rvf ~/.gnome2/
rm -rvf ~/.gnome2_private/
rm -rvf ~/.gvfs/
rm -rvf ~/.local/
rm -rvf ~/.config/nautilus/

laravel 4 #1 实现简单登陆

先获取源代码:

$git clone https://github.com/laravel/laravel.git
$git branch develop  //创建自己的开发分支
$git checkout develop  //切换到开发分支

安装Composer, windows安装, 官方文档

$ php composer.phar install
OR 
$ composer install
OR
$ curl -sS https://getcomposer.org/installer | php

下载所需的库:

$cd laravel
$composer install  //执行安装所需扩展

第一个功能创建admin登陆

创建基本配置的config文件:
app/config/base.php

 'admin'
);

提交文件

$git add app/config/base.php
$git commit -m "添加基本配置文件"

创建自己的数据库laravel, 配置你的数据库链接配置, 编辑 app/config/database.php

'mysql' => array(
  'driver'    => 'mysql',
  'host'      => 'localhost',
  'database'  => 'laravel',
  'username'  => 'root',
  'password'  => 'root',
  'charset'   => 'utf8',
  'collation' => 'utf8_unicode_ci',
  'prefix'    => 'cm_',
),

进行第一次提交:

$git add app/config/database.php
$git commit -m "配置数据库连接"

用Artisan的命令行工具安装Laravel的迁移, 迁移的文件放在app/database/migrations。主要用来进行数据库升级之类的操作:

$php artisan migrate:install

创建user表, 其实就是创建一个文件来创建user表,这是会发现有这样一个文件
app/database/migrations/2013_07_11_064145_create_users_table.php
可能文件名不一样,是根据日期生成的:

$php artisan migrate:make create_users_table

创建users表的代码并且执行升级, 编辑app/database/migrations/2013_07_11_064145_create_users_table.php

  public function up() {
    Schema::create('users', function($table)
    {
        $table->increments('id');
        $table->string('email')->unique();
        $table->string('username')->unique();
        $table->string('password');
        $table->timestamps();
    });
  }

执行升级, 这时就可以看到cm_users表已经创建成功了, 更多看官方文档: http://laravel.com/docs/quick

$php artisan migrate
Migrated: 2013_07_11_064145_create_users_table

提交文件:

$git add app/database/migrations/2013_07_11_064145_create_users_table.php
$git commit -m "创建users表"

现在,我们将创建一个用户,我们可以用它来测试验证过程。编辑laravel/app/database/seeds/DatabaseSeeder.php

call('UserTableSeeder');  // 执行我们定义的类名.
  }

}

class UserTableSeeder extends Seeder {

  public function run() {
    User::create(array(
      'username' => 'admin',
      'password' => Hash::make('admin'),   // 生成密码.
      'email' => 'zhouitpro@gmail.com'
    ));
  }

}

执行数据添加,提交

$php artisan db:seed
$git add app/database/seeds/DatabaseSeeder.php
$git commit -m "添加一个用户来进行测试"

添加路由, 编辑 app/routers.php

before('guest');

// 登陆提交.
Route::post('login', function () {});

// 检查权限. 没有权限就跳转到 login页面
Route::filter($admin_dir, function() {
  if (Auth::guest()) {
      return Redirect::to('login')->with('flash_error', 'You must be logged in to view this page!');
   }
});

/*
 * 当执行一下的页面的时候,执行权限检查. 执行admin路由.
 */
Route::when($admin_dir . '/*', 'admin');
Route::when($admin_dir, 'admin');

提交数据

$git add app/routes.php
$git commit -m "定义一个简单的路由"

分别创建两个模板. 必须是 .blade.php这样的后缀,否则无法解析模板.
app/views/home.blade.php
app/views/login.blade.php
app/views/admin_main.blade.php

#app/views/home.blade.php html
@if(Auth::check()) 

Welcome "{{ Auth::user()->username }}"

@else

Welcome

@endif #app/views/login.blade.php html #app/views/admin_main.blade.php html

ADMIN

实现登陆. 编辑app/routers.php

Route::post('login', function () {}

TO:

// 登陆提交.
Route::post('login', function () {
   $user = array(
      'username' => trim(Input::get('username')),
      'password' => trim(Input::get('password'))
   );
   if(Auth::attempt($user)) {
     return Redirect::to('admin');
   } else {
     return Redirect::to('login');
   }
});

提交数据

$git add app/
$git commit -m "实现一个简单的登陆"

关于alipay create_forex_trade 接口类型(境外收单接口)

这个资料下载官方也没有,只有找 旺旺:夏一希,或者,旺旺:玉蕾这些人要。我要了一份

境外收单接口(forex_trade)

参数:

$parameter = array(
  "service" => "create_forex_trade", //this is the service name
  "partner" =>$partner,
  "return_url" =>$return_url,
  "notify_url" =>$notify_url,
  "_input_charset" => $_input_charset,
  "subject" => "subject", //subject is the name of the product, you'd better change it
  "body" => "body",  //body is the description of the product , you'd beeter change it
  "out_trade_no" => time() ,
  "total_fee" => "10", //the price of products
  "currency"=>"USD", // change it as the currency which you used on your website
);

drupal 7 Ctools Ajax

首先载入必须的Ajax裤

ctools_include('ajax');
ctools_include('modal');
ctools_modal_add_js();

ajax跳转

print ajax_render(array(ctools_ajax_command_redirect('checkout/123080/review')));

Ajax页面重载

print ajax_render(array(ctools_ajax_command_reload()));