Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append template render to page variables #44

Closed
nunocodex opened this issue Sep 4, 2014 · 2 comments
Closed

Append template render to page variables #44

nunocodex opened this issue Sep 4, 2014 · 2 comments
Labels

Comments

@nunocodex
Copy link
Contributor

I thinking to add on my first plugin the option for auto-render the comments after page.content directly without theme editing, is possible?

Thanks.

@rhukster
Copy link
Member

rhukster commented Sep 4, 2014

You can append data to the page in theonPageInitialized() event. You owuld just need to do something like:

$page = $this->grav['page'];
$content = $page->content();
$content .= '<p>Something under the page..</p>';
$page->content($content);

@nunocodex
Copy link
Contributor Author

I used this way:

/* save current content */
$old_content = $page->content();

/* parse disqus comments template */
$content = $this->grav['twig']->twig()->render('disqus_comments.html.twig', ['page' => $page]);

/* update page with new content */
$page->content($old_content . $content);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants