Jump to content

wireRenderFile() inside wireRenderFile()


Tom.
 Share

Recommended Posts

Hello,

I'm currently using wireRenderFile() for all the code that is repeated in the site. To keep the code as clean as possible. I have a nice folder structure that has blocks, snippets and items. Blocks being quite a large set of code, snippets that are small things such as outputting a formatted date from two variables and items being things that's often used in repeaters. 

A block can contain things from a repeater, for example lets say we have a related content block. I would do:

<?=wireRenderFile('ui/blocks/related', array('tags' => $item->tags)?>

This will create all the wrapper html for the block which may be used on multiple pages. Inside this I want to use the related content item so inside ui/blocks/related.php I might have something like:

<?php $items = $pages->find("template=activity, tags=$tags"); ?>
<div class="related">
    <h1>Related Content</h1>
    <div class="uk-grid">
     <?php foreach($items as $item): ?>
         <div class="uk-width-large-1-2">
                <?=wireRenderFile('ui/items/activity', array('item' => $item)?>
         </div>
     <?php endforeach; ?>
     </div>
</div>

However it will throw an error saying the function wireRenderFile() doesn't exist. Is there anyway to stop this? I tried bootstrapping ProcessWire:

include "{$config->paths->root}index.php";

At the top of the file however this didn't work.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...