Skip to content

Data source type #1672

Answered by ArnaudLigny
aiamk asked this question in Q&A
Apr 15, 2023 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

Yes, if you needs to create a collection of pages you can do it from a custom generator.

SQLite example:

<?php
namespace Cecil\Generator;

use Cecil\Collection\Page\Page;
use Cecil\Collection\Page\Type;

class MyGenerator extends AbstractGenerator implements GeneratorInterface
{
    public function generate(): void
    {
        $db = new SQLite3('database.sqlite');
		$statement = $db->prepare('SELECT ...');
		$result = $statement->execute();

		while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
			$page = (new Page($row['page-id']))
	        	->setType(Type::PAGE)
	          	->setPath($row['path'])
	          	->setBodyHtml($row['html'])
	          	->setVariable('title', $row['title']…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ArnaudLigny
Comment options

Answer selected by aiamk
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants