Jump to content

Weird behaviour with appendFile/appendFiles options in $page->render()


EvanFreyer
 Share

Recommended Posts

Hey there!
 
First and foremost: Thanks for making PW. I discovered it lately and I am using it right now to develop a corporate website with different designs and microsites. PW is giving me exactly the type of flexibility and ease-of-use, that I need. It is incredible and it is a CMS as I would develop it, if I have the time (and the skill ;)).
 
I noticed a weird behaviour with the render()-options in my version (2.6.1), that I can not pinpoint exactly. I have some fields in my page, that I want to render with a specific template, so that I can share that template for all the pages, that uses this field. For example, I have a image carousel template, which takes a page with a specific repeater and renders all the items in one template file:

<section class="microsite-section carousel slide" id="carousel-microsite-<?=$page->id?>" data-ride="carousel">
	<ol class="carousel-indicators">
	<?php
	$first = true;
	$i = 0;
	foreach ($page->image_carousel_repeater as $item) {
		echo "<li data-target='#carousel-microsite-".$page->id."' data-slide-to='".$i."'".($first ? " class='active'" : "")."></li>";
		$first = false;
		$i++;
	}
	?>
	</ol>
	<div class="carousel-inner" role="listbox">
	<?php
	$first = true;
	foreach ($page->image_carousel_repeater as $item) {
		// echo "<div class='carousel-item item".($first ? " active" : "")."><img src='".$item->image_carousel->url."' alt=''>";
		
		echo "<div class='carousel-item item".($first ? " active" : "")."' style='background-image:url(".$item->image_carousel->url.")'>";		
		echo "<div class='carousel-caption'>".$item->image_carousel_text."</div></div>";
		$first = false;
	}
	?>
	</div>
	 <!-- Controls -->
  	<a class="left carousel-control" href="#carousel-microsite-<?=$page->id?>" role="button" data-slide="prev">
	    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
	    <span class="sr-only">Previous</span>
	</a>
	<a class="right carousel-control" href="#carousel-microsite-<?=$page->id?>" role="button" data-slide="next">
		<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
		<span class="sr-only">Next</span>
	</a>
</section>

(Please excuse the weird code, it is just a prototype.)

In the main template, I call this template:

$content .= $page->render('microsite-image-carousel.php', array('appendFiles' => array(null)));

There you see, that I use the additional render-options (which are sadly not documented in the API Cheatsheet btw), because I don't want to append any files.

But if I use the appendFile-Option, PW will include the main file nevertheless:

$content .= $page->render('microsite-image-carousel.php', array('appendFile' => null));

Now my guess is, that render('template-file') only renders the page with this file but still with the options connected with the main template, that this page-object is derived from. But why do these two calls behave differently? I thought, they meant the same thing only with the option to append multiple files.

Thanks in Advance!

Cheers

Evan

By the way: Is there a way to configure a template to append multiple files?

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...