Widget file naming?

  • I'm having a problem with getting my widget to show on my page. I can enable it however it then doesn't seem to render. I think this has to do with pointing to the correct files.

    So to start off my theme's template.php contains

    1. <?php if ($view->position()->exists('bloglinks')) : ?>
    2. <?= $view->position('bloglinks', 'bloglinks.php') ?>
    3. <?php endif; ?>

    And then the theme's /view/bloglinks.php conaints

    1. <section class="blog-links">
    2. <?php foreach ($widgets as $widget) : ?>
    3. <?= $widget->get('result') ?>
    4. <?php endforeach ?>
    5. </section>

    Then my widget folder got an index.php with

    and in the widgets folder there's blogposts.php with

    and finally in the widget views folder there's another blogposts.php containing

    1. IT'S WORKING!

    So my directory tree looks like this: (Only relevant parts)

    I can assign the widget to the position, and the position can render with a normal text widget. However when I only have my widget in the position the

    1. <?php if ($view->position()->exists('bloglinks')) : ?>

    in template.php seems to fail as I'm not even seeing the <section> html tags.

    When I looked at other widgets like from Bixie the file pointing didn't seem to make any sense. Like not actually pointing to the view folder for a view and stuff. Can anyone see what I'm doing wrong?

  • Just to be sure I understand you correctly: You are rendering a widget statically? So you include it into your template and you do not use the backend to place the widgets?

    I think Tobbe 's Widget-including-plugin could help you out here. As far as I remember he renderes the widget this way.