mcsodbrenner/googlecms

一个使用 Google Spreadsheets 作为 CMS 的 PHP 类。

1.0.1 2016-01-20 15:43 UTC

This package is auto-updated.

Last update: 2024-09-08 19:23:23 UTC


README

一个使用 Google Spreadsheets 作为 CMS 的 PHP 类。

使用此电子表格作为示例,了解如何构建电子表格: https://docs.google.com/spreadsheets/d/1LNvJWag9RNHiF6dtKSFVgYhbK_y7jFa4C3UTI-RUiO0/edit#gid=0

查看上述示例电子表格的解析结果。

用法

// Extract this id from the URL of your spreadsheet
$spreadsheet_id = '1LNvJWag9RNHiF6dtKSFVgYhbK_y7jFa4C3UTI-RUiO0';

// With the Google Data API it is only possible to get one spreadsheet per request
// So we request all sheets in parallel
// Because Google prevents request flooding we build blocks of 10 requests that are excecuted in parallel.
// This parameter is optional (default = 10)
$request_block_size = 10;

include('src/GoogleCMS.php');
$cms = new McSodbrenner\GoogleCMS\GoogleCMS($spreadsheet_id, $request_block_size);


// Now we get the data. It is possible to build keys like "content1.subkey1" or "content1|subkey1" that are transformed into an array.
// This parameter is optional (default = '.')
$array_divider = '.';

$data = $cms->getData($array_divider);

print_r($data);

提示

  • 如果你必须使用相同名称的内容 ID,则内容将被放入数组中。
  • 在表名前使用 [IGNORE] 来忽略结果中的该表。