Jump to content

PW3 - Appending Content


ridgedale
 Share

Recommended Posts

Hi,

I'm trying to append a contact form to the existing contact page content. The existing content for the _main.php page is as follows:

				<div id='content-body'>
					<?=page()->body?>
				</div>

I've created a contact.php page and have included the following code but the form is not being rendered:

<?php namespace ProcessWire; 
// This is the form for the /contact/ page.
?>

<div pw-append="content-body">
	<div id="contact-form">  
	   // ... contact form details here
	</div>

	<p>&nbsp;</p>
</div>

The following is returned in debugging mode which doesn't appear to be of much help:

Quote

3. replace => #content-head ... <h1 id='content-head'></h1>
4. replace => #content-body ... <div id='content-body'></div>
6. replace => #sidebar ... <aside id='sidebar'></aside>

Any thoughts on what I am doing wrong?

Any help appreciated.

 

Link to comment
Share on other sites

pw-append should be a class attribute.

Assuming that you want to append to the div with id content-body, it should be lik this.

<div id="content-body" class="pw-append">
	<div id="contact-form">  
	   // ... contact form details here
	</div>

	<p>&nbsp;</p>
</div>

 

In the config you also need to have set the following:

 

$config->useMarkupRegions = true;
Link to comment
Share on other sites

4 minutes ago, webhoes said:

pw-append should be a class attribute

Not anymore, see: https://github.com/processwire/processwire-issues/issues/238#issuecomment-292906205

quote: The class attributes of the type you mentioned aren't staying, as it seemed like everyone preferred attribute support instead. Here's how you can use that: <img pw-append='sidebar' src='<?=$page->image->url?>'> The pw-append attribute can also be data-pw-append if you prefer it.

Finalized Markup Regions: https://processwire.com/blog/posts/processwire-3.0.62-and-more-on-markup-regions/

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

×
×
  • Create New...