contentful / rich-text.php

Utilities for the Contentful Rich Text
https://www.contentful.com
MIT License
12 stars 9 forks source link

[Question] using rich-text.php with PHP5.6 #52

Closed kossa closed 4 years ago

kossa commented 4 years ago

Hello,

We are working on old code base using codeigniter2 and PHP5.6, no composer, I just want to retrieve the modules as HTML, I did not find old version of this package, the current API return a lot of nodes that I cannot parse to HTML.

Any suggestion ?

pgrigoruta commented 4 years ago

@kossa I am not sure I understand your question... Do you want to download the libraries, like rich text or contentful-management? If so, just download them from Github, try to make them work. I am not sure how well they perform on such old PHP versions, the oldest we support is PHP 7.2. But I guess it's worth a shot.

As for how to parse rich text to HTML, the examples in the readme at should help - https://github.com/contentful/rich-text.php .

Here is a simplified example that would output a rich text node as HTML:

$options = \Contentful\Delivery\ClientOptions::create();

$entry = $client->getEntry('ID');
$node = $entry->getContent();

$parser = new Contentful\RichText\Parser(new \Contentful\Delivery\LinkResolver($client,
    Contentful\Delivery\ResourcePool\Factory::create($client,$options) ));
$renderer = new Contentful\RichText\Renderer();
$output = $renderer->render($node);

Feel free to reopen if you need more help/I did not answer the right question.

kossa commented 4 years ago

Finally I created my own parser, As I said the apps works on PHP5.6, no composer

Thank you very much