getgrav / grav-plugin-page-inject

Grav Page Inject Plugin
https://getgrav.org
MIT License
32 stars 6 forks source link

Custom template does not seem to be working #13

Closed paulhibbitts closed 5 years ago

paulhibbitts commented 6 years ago

I've been using Page Inject more and more (such a helpful plugin, thank you!) and for the first time I am trying to use it with a custom template - but this does not seem to work.

For the markdown page embedlycard.md the template embedlycard is usually used, but even when using the custom template option to use the alternative template embedlycardlinkonly this still seems to be the case, for example:

[plugin:page-inject](/required-readings/week-06?template=embedlycardlinkonly)

Thanks very much for looking into this issue. Paul

rhukster commented 6 years ago

11.page-inject-8.zip

I just tested with this, and I have a template located in my theme called templates/page-inject-test.html.twig

<div class="control" style="background: #fefefe;border: 1px solid #ccc;">
    <h2>{{header.variable1}}</h2>
    {% block control %}{{page.content}}{% endblock %}
</div>

Works fine.. However, you will probably need to clear your cache between test attempts as the results get cached into the top level page.

paulhibbitts commented 6 years ago

Thanks for looking into this @rhuk, I will re-test re: possible cache issue and let you know how things go.

paulhibbitts commented 6 years ago

Hi @rhukster , I think I finally tracked down a repeatable recipe!

The example you gave me, in a new Grav site worked. However, I could still not get my site to use the custom template option. After a lot of comparisons, it looks like if the ShortCode Core Plugin is active and installed the custom template feature of Page Inject is not recognized.

Can you repeat this on your install too?

Thanks very much, Paul

rhukster commented 6 years ago

Don’t think that’s it. I have shortcode core installed and it works fine.

The example you gave me, in a new Grav site worked. However, I could still not get my site to use the custom template option. After a lot of comparisons, it looks like if the ShortCode Core Plugin is active and installed the custom template feature of Page Inject is not recognized.

Can you repeat this on your install too?

Thanks very much, Paul

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub [https://github.com/getgrav/grav-plugin-page-inject/issues/13#issuecomment-350598067] , or mute the thread [https://github.com/notifications/unsubscribe-auth/ABCNGRcYCQzdemz1zBbU812hR9XywegIks5s_H7vgaJpZM4Q1CHu] .

paulhibbitts commented 6 years ago

Huh... I thought I had tracked it down. When I enable/disable ShortCodes on my site I can repeat the issue. Would it help if you had my user folder?

Thanks very much, Paul

paulhibbitts commented 6 years ago

If I can get another repeatable recipe I will let you know. For now disabling/removing the ShortCode Core Plugin seems to fix things for my current site.

paulhibbitts commented 6 years ago

Hi @rhukster , I think I've finally got a working example for you re: possible issue of custom templates with the Page Inject plugin.

Here is a Grav user folder ZIP file with a working site: https://www.dropbox.com/s/dkhp89ngtb7kl19/user.zip?dl=0

Looking at the homepage, you will see the Required Reading and Week 2 slides from the modular page file 'home/__class-preparations' use the default templates even though custom templates are defined:

##### Required Reading
[plugin:page-inject](/readings/week-02?template=embedlycardlinkonly)

[Practice Required Reading Quiz](https://canvas.sfu.ca/courses/38847/quizzes/71530?classes=btn,btn-primary)

##### Slides to be Discussed
[plugin:page-inject](/slides/week-02?template=swipedecktitleonly)

However, on the Schedule page the custom template (i.e. link only) displays as expected, here is an excerpt:

:fa-desktop: [plugin:page-inject](/slides/week-02?template=swipedecktitleonly)
:fa-book: [plugin:page-inject](/readings/week-02?template=embedlycardlinkonly) 

Any ideas why the custom template is not picked up on the Home page (class preparations) but is picked up on the Schedule page?

Thanks very much, Paul

paulhibbitts commented 5 years ago

It's been a while🙂, but I've finally figured out that by disabling the Twig cache (vs. Cache) on pages that use multiple templates I no longer have this issue🎉

bonnebulle commented 5 months ago

Hey there, sorry to reopen this issue On my Grav the injection works great with :

[content-inject path="/f/subject/" template="page-inject-test" /]
[plugin:page-inject](/f/subject/?template=page-inject-test)

( do the same ) but not using the given template named page-inject-test presents in /templates/page-inject-test.html.twig

What I do : disabel catche + twig cache templates not loading :( very sorry, it is a very powerfull plugin here thanks