Jump to content

Search the Community

Showing results for tags 'partial'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 3 results

  1. Can you confirm that the function renderField for fieldset fields, even having the file /site/templates/fields/fieldName.php or /site/templates/fields/fieldName/$file.php (using $file argument), does not render anything as expected? $page->renderField('fieldsetName') // returns nothing ... or am I wrong on something?
  2. Hi, I'm working on a homepage template where I loop over some pages, check if they have children, and print their children; if not, print the page itself where I employ page->render function. Inside template files of these parent pages, I use $config->scripts->[foot|head]->add() to enqueue scripts and and when creating markup I print the contents of these FilenameArrays using simple foreach loops. With parents that have children, which don't require rendering a part of page (as opposed to rendering whole html document), there's no problem using $config->scripts, using PHPStorm's debugger I can track the scripts up until where the execution comes to parents with no children. When used with $parentPage->render(array('renderPartial' => true)) these pages get rendered from beginning using their own context, completely ignoring the previous one, and resulting in flushing $config->scripts->[foot|head].After many hours of fiddling with here and there, I'm lost and I don't know how else I can tackle with this problem. The question I have is if there's a way to manually render a page without losing the context? Or, in which variable I can store FilenameArrays? // The code I have can be paraphrased as // Homepage sections foreach $section as $parent if $parent->hasChildren foreach $children as $child renderChild() else $parent->render(partial=true) // In each parent's template $config->scripts->head->add("head.js") $config->scripts->foot->add("foot.js") // both foot and head initialized at _init.php // After using $parent->render(partial=true) // $config->scripts gets flushed loop_over_and_write_scripts('foot') // returns nothing, $config->scripts->foot is empty Thanks in advance.
  3. Hi, I'm working on a custom contact form and I want to create an HTML markup for email body. After tedious and long searches I've found wireRenderFile function that does exactly what I need. Pass in template file and variables to use, it returns the output. Except that it doesn't. It simply returns an empty string. I tested the same template using wireIncludeFile, it echoes the output perfectly. (I'm using the latest 2.6.16 DEV version of ProcessWire) Here's what I did: Got and processed user inputs Created a simple partial template file at templates/partials/_email.php with contents <?php if (isset($vars)): ?> <div class="meta"> From: <b><?= $vars["name"] ?></b><br> Email: <?= $vars["email"] ?><br> sent this at <?= $vars["date"] ?> </div> <hr> <div class="message"> <?= $vars["body"] ?> </div> <?php endif; ?> Prepare mail data and send it $mail = wireMail(); ... ... $bodyHTML = wireRenderFile("partials/_email.php", array( "name" => $name, "body" => $body, "email" => $email, "date" => date("r"), )); ... ... ... if ($mail->testConnection()) { $mail->sendSingle(true) ... ->bodyHTML($bodyHTML) ->send(); } The $bodyHTML variable gets an empty string from wireRenderFile function. When I replace it with wireIncludeFile $bodyHTML = wireIncludeFile("partials/_email.php", array(<data>)); The template is rendered correctly, but echoed instead of returned (it returns boolean anyway). I think I can collect the output using ob_start() and ob_get_contents(), but the code above should work correctly and I dont want to use a hack for it, yet. Thanks in advance for any help. --- EDIT: I solved it. wireRenderFile function imports given data in $vars variable as separate entities as in // Second argument is $vars $bodyHTML = wireRenderFile("partials/_email.php", array( "name" => $name, "body" => $body, "email" => $email, "date" => date("r"), )); // $vars variable is included in template file as in $name = $vars["name"] ... // etc. There's no need (can't) to access to $vars variable. I was able to output the data with this modified template file. Notice the if (isset($vars)) is removed since $vars variable doesnt exist in that context. <div class="meta"> From: <b><?= $name ?></b><br> Email: <?= $email ?><br> sent this at <?= $date ?> </div> <hr> <div class="message"> <?= $body ?> </div>
  • Create New...