PHP code example of tomk79 / px2-publish-for-multi-device

1. Go to this page and download the library: Download tomk79/px2-publish-for-multi-device library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tomk79 / px2-publish-for-multi-device example snippets



	/* 中略 */

	/**
	 * funcs: Before content
	 *
	 * サイトマップ読み込みの後、コンテンツ実行の前に実行するプラグインを設定します。
	 */
	$conf->funcs->before_content = array(
		// PX=api
		'picklesFramework2\commands\api::register' ,

		// PX=publish
		'tomk79\pickles2\publishForMultiDevice\publish::register('.json_encode(array(
			'devices'=>array(
				array(
					'user_agent'=>'iPhone',
					'path_publish_dir'=>'./px-files/dist_smt/',
				),
				array(
					'user_agent'=>'iPad',
					'path_publish_dir'=>'./px-files/dist_tab/',
				),
			)
		)).')' ,
	);


	$conf->funcs->before_content = array(
		// PX=api
		'picklesFramework2\commands\api::register' ,

		// PX=publish
		'tomk79\pickles2\publishForMultiDevice\publish::register('.json_encode(array(
			// ↓パブリッシュするデバイスの情報を設定する。
			'devices'=>array(
				array(
					'user_agent'=>'iPhone', // USER_AGENT 文字列
					'path_publish_dir'=>'./px-files/dist_smt/', // このデバイス向けのパブリッシュ先ディレクトリ
					'path_rewrite_rule'=>'functionNameOf::rewrite_smt', // パスの書き換えロジック
				),
				array(
					'user_agent'=>'iPad',
					'path_publish_dir'=>'./px-files/dist_tab/',
					'path_rewrite_rule'=>'functionNameOf::rewriter_tab',
				),
				/* ...以下同様... */
			)
		)).')' ,
	);
bash
$ php .px_execute.php /?PX=publish.run