Tom. Posted January 29, 2016 Share Posted January 29, 2016 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 More sharing options...
tpr Posted January 29, 2016 Share Posted January 29, 2016 Is it namespaced PW? (3.05) If so, try ProcessWire\wireRenderFile... 4 Link to comment Share on other sites More sharing options...
Tom. Posted January 29, 2016 Author Share Posted January 29, 2016 Is it namespaced PW? (3.05) If so, try ProcessWire\wireRenderFile... adding namespace ProcessWire; at the top of the file fixed this. Thank you very much tpr! Link to comment Share on other sites More sharing options...
tpr Posted January 29, 2016 Share Posted January 29, 2016 My pleasure. I also had a few headaches with devns in my latest project but finally all seem to work fine. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now