Jump to content

Search the Community

Showing results for tags 'wirerenderfile'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 3 results

  1. It took me a while to figure out what causes wireRenderFile() to fail processing its second (optional) parameter in ProcessWire 3.0.3, but finally I could pass those variables to the template file by using the "Yes (template file only)" option of "Use Compiled File?" setting in the admin panel. The default setting is "Yes (and included files)", but with this setting selected, wireRenderFile() cannot receive its optional array parameters. Is it a bug or a feature? I also tried to switch to "No", but this option cannot be saved, after saving the template it switches back to "Yes (and included files)". Again, bug or feature? All my template files begin with <?php namespace ProcessWire; so in this case is this automatic namespace updating necessary at all? I don't know how this compiling thingy works, so I do not know what the right answer to this "Use Compiled File?" question should be. Is it ok to use "Yes (and included files)"? Or should I use "No" (if it was possible)? Or "Yes (and includes files)" which renders wireRenderFile() sort of useless? Any help is appreciated!
  2. I have a strange problem and I don't know if it's bug or I'm just not quite understanding something right. I'm using ProcessWire 3.0.34. I have a search box fragment (the HTML) in a separate template which I 'include' via wireRenderFile() because I'm using the delayed output method for my templates. It works perfectly well, and shows the form. However, on the search results page, I also want to show the keywords that were entered in the search text input. This should be easy, my search function sanitises the user input (the search form uses GET) as a selectorValue and saves it to the $input->whitelist. This is where it gets weird. On the search results page itself I can spit out the whitelisted variable ok for the "you searched for 'blah'" text, but it doesn't get passed to the file included by wireRenderFile to show in the search form text input. I thought all PW API variables (in this case $input) were available to included files and that only custom variables had to be passed as an array? My first thought was that there is a context issue, so I tried wire('input') instead, but that didn't work either (and it didn't show an error), so my second thought was that maybe $input is not passed automatically and only the $page object is ($page->whatever does work), so I tried to pass the value I wanted as a custom variable: $page_body .= wireRenderFile("includes/comic-search-form", array( 'search_keywords' => $input->whitelist->search_keywords )); // Note the variable works perfectly elsewhere on the template calling wireRenderFile: $page_body .= "You searched for: {$input->whitelist->search_keywords}"; // WORKS! In the included file, I then used: <input type="search" name="search_keywords" id="search_keywords" size="30" placeholder="Enter keywords" value="<?php echo $search_keywords; ?>"> <!-- note, when working, the code will check the $search_keywords actually has content before echoing --> However, it still came out blank! So I did some more tests passing other variables and also used Tracy Debugger to var dump: bd($input->whitelist->search_keywords, 'Before'); $page_body .= wireRenderFile("includes/comic-search-form", array( 'test_a' => $page_summary, // another custom variable from the template 'test_b' => 'This is a test', // a direct string 'search_keywords' => $input->whitelist->search_keywords )); // On the incude file itself, I did the following bd(array($test_a, $test_b, $search_keywords), 'Inside wireRenderFile()'); echo "<pre> Test A (variable): $test_a Test B (string): $test_b Search Keywords: $search_keywords </pre>"; In the Tracy output and the directly printed output the $test_a and $test_b variables worked perfectly as expected, but the $search_keywords was always blank (null)! Weirdly, in the output on the template calling the wireRenderFile ("Before"), the Tracy output for $input->whitelist->search_keywords was also blank!? If I can echo out the $input->whitelist->search_keywords value on the template it is called on, why can I not then save it as a variable to be passed to wireRenderFile ? Is there something I am overlooking or not understanding?
  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...