1

I am trying to build a basic plugin, when installed has a single nav bar item, and of course a twig template which shows up on clicking on that navbar item.

I have used the basic template to extend to make my page:

{% extends "_layouts/cp" %}
{% set title = "Page Title"|t('plugin-handle') %}

{% block content %}
    <p>Page content goes here</p>
{% endblock %}

The resulting page for the plugin looks like shown in the screenshot attached below:

Screenshot of basic template

Now I am trying to add content in the content section, but I am not sure how to add my assets

<img src="/resources/img/poptinlogo.png"/>

This won't work, and I am guessing I need to get the paths using some variable in the twig templating system, but I am not sure how. And the documentation is not clear on this part, or maybe I don't know where to look right away.

How to include my assets on the page, like images, js and css files?

2

You need to register asset bundles in your plugin, see the Craft docs -> https://docs.craftcms.com/v3/extend/asset-bundles.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.