Search the Community
Showing results for tags 'includes'.
Found 4 results
I have a page which sends out an email based on queries in the url <?php // event ID $eventID = $input->get('eventID','int'); $event = $pages->get($eventID); // config $adminEmail = "firstname.lastname@example.org"; $fromEmail = "email@example.com"; $fromName = "test"; $emailSubject = "Test Email"; // HTML BODY $emailBody = ""; // HOW TO ??? … // send mail $m = new WireMail(); $m->to($adminEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->send(); ?> The email body is a bit complex: standard html/css tables and some php (pw variables). I put my emailbody (html) in a seperate file emailbody.inc but don't know how to include it?
I originally created my template files thinking I'd only ever need 3 and not worrying about if I repeated bunches of common code there (yes, bad practice, I know). I figured I'd just manually/copy-paste to change any common code in all 3 as needed. So of course, fast-forward awhile, and I'm now up to 6 template files with possibly a few more to come, and decided it was high time I made the switch to keep the common parts in their own unique files for ease of editing. So I therefore went back and read Ryan Cramer's tutorial "How to Structure Your Template Files". OK. I tried out the "includes" command mentioned in the tutorial on a test template. The resultant web page physically functions as expected, but my question here is, "Is the practice I'm showing below OK in terms of variable usage?" If not, what approach should I be using? I've tested it out and the variables do populate as expected in the final result, but is it OK for me to do it like this or is there the chance that some of the variables won't be passed properly? Here is what I mean (only the relevant portions of code shown to illustrate): ... <aside> <h3>Three Random Posts</h3> <!-- get the list, then display it --> <?php $itempages = $pages->find("template=my-post"); $shortlist = $itempages->getRandom(3); $shortlist->shuffle(); $itempagezero = $shortlist->eq(0); $itempage1 = $shortlist->eq(1); $itempage2 = $shortlist->eq(2); ?> <?php include("./INC_displaylist.php"); ?> </aside> <?php include("./INC_footer.php"); ?> </body> </html> The possible issue here is that the INC_displaylist.php file outputs field data from $itempagezero, $itempage1, and $itempage2. Is that OK? I wanted to split the variable assignments and the output separately. This is because, based on the exact template I'm using, I will sometimes choose to populate $itempages via different selectors in the $pages->find command in different template files, although all templates will display an identically-formatted list of 3. By contrast, I wouldn't expect any variable issues with including the INC_footer.php file as shown above, since I'm not using any variables in the footer that aren't first referenced in that same footer. So am I doing it OK here or should I be populating these variables somewhere else to ensure they're recognized properly by INC_displaylist.php? If I need to do it somewhere else, where should I populate these?
Hi there! I've got a little, annoying problem at the moment. I'm working on a local Linux web server wich is connected to my Mac via AFP (netatalk). Based on this network configuration the system creates directories with the name ".AppleDouble" in every Directory on the network share. My problem with ProcessWire is, that somewhere in ProcessWire the must be automatic includes. They are including the files in the .AppleDouble directories and this causes a fatal error on ProcessWire. On the error pages I see some cryptic chars (origin must be the content of .AppleDoble directories) and then a 500 Error. In the logs the error: Error: Class 'PagePermissions' not found (line 308 of ..../wire/core/Modules.php) appears. I know, it is NOT a problem of ProcessWire, it's a problem of my network configuration, but I'd like to know, where exactly the automatic includes are, so I maybe can fix it on my own. Any Ideas, where to start? If this problem may concern other users as well, maybe the automatic includes can be filtered to skip such directories? Just an idea. Thanks in advance! Greets!
I wonder how different people handles different "file structures" for templates. I know that you can only put php code inside a template files, and i have thought that when you have to create a lot of unique "pages" with different php code it will take time to create a template file for each page. Not only that, but eventually, if you create a lot of templates, the templates folder would get very crowded. I was looking for a better way to organize my php files and found this solution. Instead of creating a template for each unique page with custom php code, I just create a single template named "include". This template just has two fields: title and include_path. The code of this template is just: <?php include $page->include_path; ?> In the "include_path" field I set the relative path for including other php files, and this method gives me a more organized collection of php files nested in various folders. For example, for a form called "reservation", I would just create a page with the template "include", and the field "include_path" set to "./php/forms/reservation.php". An example of this file structure: site/ --templates/ -----/styles -----/scripts -----/php --------/forms --------/processes --------/catalogs --------/galleries -----head.inc -----foot.inc -----home.php -----blog-post.php -----include.php Do anyone know if there is a better way to handle php files? o anybody would share their file structure approach?