We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Question, Problem, Configuration

Duplicating Pages and Their Content?

I wondered if there is a way to achieve the following?

I have a site that has some landing pages for Adwords/Bing, ideally I want to track effectiveness of the campaigns. What I would like to do is have separate contact forms for each one so I can see where leads/jobs come from.

Creating the landing pages is fine, and even creating navigation menus specific to Adwords/Bing. But the problem is unless I duplicate every page in the site that occurs from the menu as soon as the go to a page "outside" the landing page the menus will be from the regular site. For example all landing pages have a link to Ordering Information and a Gallery, I dont want to have to recreate those.

So while I know how to create shared content, I don't want to share every bit of content as some pages might have unique content to that landing page.

  1. Is there a way to duplicate an existing page but using a new template that has a different navigation menu (I know how to do that in a template but not how to reuse another page's content).

  2. Or is there a way to reference content from an existing page in a new template?

  3. Or is there a way to share content but keep the original associated with the page it was created in?

Currently the only way I can see to do this is to create from scratch duplicate pages and manually add the same content in which seems daft.

Nigel Coath

Nigel Coath 1 points

  • 1 year ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Or is there a way to reference content from an existing page in a new template?

Use perch_content_custom() with the page option.

Hello Drew, thanks. I spotted that one after I posted.

I wonder, is there an easier way to duplicate a whole page of content? Lets say I have following page content:

<?php include $_SERVER["DOCUMENT_ROOT"] . "/admin/runtime.php"; ?>
<?php perch_layout('head.content'); ?>

<body class="l-body">

<div class="l-header">
<div class="l-header-h">
<?php perch_layout('photo.header'); ?>

<!-- Main Content -->
<div class="l-main">
<div class="l-main-h">

<?php perch_content('Banner Slider'); ?>
<?php perch_content('Introduction'); ?>
<?php perch_content('USP Box Photo'); ?>
<?php perch_content('Product Range Photography'); ?>
<?php perch_content('Additional Info Photography'); ?>


<?php perch_content('Order Photography'); ?>

<!-- End Main Content -->

<!-- End Wrapper -->

<!-- Footer -->
<?php perch_layout('photo.footer'); ?>
<!-- End Footer -->

<a class="w-toplink" href="#"><i class="fa fa-angle-up"></i></a>


I want to duplicate the whole page and simply replace <?php perch_layout('photo.header'); ?> with <?php perch_layout('adwords.header'); ?>

Basically I want to have a different menu system pointing to that subdirectory so that its like a microsite just for PPC visitors?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You're just passing a string into perch_layout(), so the value of that string can be determined by any logic you want to add to the page. It could be something in Perch like a page attribute, or it could be something environmental like the URL of the page. It's really up to you.

So how would I achieve what I want, what I want is a duplicate of a page from the main directory inside a subdirectory. Everything the same apart from the menu <?php perch_layout('photo.header'); ?>

Is there a way to reuse everything inside <!-- Main Content --> <!-- End Main Content -->

and only amend <?php perch_layout('photo.header'); ?> and <?php perch_layout('photo.footer'); ?>

The reason is, the landing page will change, but I dont want them to navigate away to the main site. This way I can track any conversions with more precision.

I know many people use landing pages with no navigation, just contact form but this is not useful for my purposes.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, I think you can achieve what you want.

I have not got a clue how I would do that! Any pointers?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you wanting to switch based on the URL?

In as much as anything within a subdirectory needs to have a different <?php perch_layout('photo.header'); ?> and <?php perch_layout('photo.footer'); ?>

So for example if the subdirectory were /google then I would change those to <?php perch_layout('adwords.header'); ?> and <?php perch_layout('adwords.footer'); ?>

Drew McLellan

Drew McLellan 2638 points
Perch Support

So it sounds like you need to:

  1. Get the current URL
  2. Count the segments in the URL
  3. If the URL starts with /google and has more than 1 segment, include the alternative layout.