How do you return a full url onto a page from a perch template?
PerchSystem::set_var('page', perch_page_url(array( 'include-domain' => true, ), true));
then
<perch:content id="page" type="text" />
That doesn't seem to work? And it is also adding a text field in the control panel in that region too.
Fatal error: Call to undefined function perch_page_url()
Are you running an old version?
This site was out of date and is now updated to the latest. That fixed the error on the front end but it still is not spitting out the url as well as it is showing a text area in the admin.
What does <perch:showall /> give you?
<perch:showall />
Here is a link where you can see the show all tag output.
https://perch.uisandbox.es/snipcart/brandon.php
So it's being set, but with no value. Can you show me the code you've got in your page?
<div style="float:left;"> <div style="width:200px; background-color:#eee; border:1px solid #ccc; float:right; margin: 20px; text-align:center; display:inline; "> <p>$<perch:content id="price" type="text" label="Item Price" order="3" /></p> <a href="#" class="snipcart-add-item" data-item-name="<perch:content id="name" type="text" label="Item Name" order="1" />" data-item-id="<perch:content id="sku" type="text" label="Item Sku" order="2" />" data-item-price="<perch:content id="price" type="text" label="Item Price" order="3" />" data-item-url="<perch:content id="page" type="text" />"> Add to Cart</a> <br /> </div> <perch:content type="textarea" id="details" label="Product Details" markdown="true" editor="markitup" order="3" /> </div> <perch:showall />
<?php include('../admin/runtime.php'); ?> <?php PerchSystem::set_var('page', perch_page_url(array( 'include-domain' => true, ), true)); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title><?php perch_pages_title(); ?></title> <link id='snipcart-theme' type='text/css' href='https://app.snipcart.com/themes/base/snipcart.css' rel='stylesheet' /> </head> <body> <br /> <div style="width:900px; margin:0 auto;"> <div style="float:left; background-color:whitesmoke; padding:10px;"> <div style="width:200px; float:left;"> <p><strong>Sub Pages</strong></p> <?php perch_pages_navigation(array( 'from-path' => '/snipcart', 'levels' => 0, 'hide-extensions' => false, 'hide-default-doc' => true, 'flat' => false, 'template' => 'item.html', 'include-parent' => false, 'skip-template' => false, 'siblings' => false, 'only-expand-selected' => false, 'add-trailing-slash' => false, 'navgroup' => false, 'include-hidden' => false, )); ?> </div> <div style="width:550px; float:right; background-color: #fff; padding-left: 20px;"> <div style="float:left;"> <h1><?php perch_pages_title(); ?></h1> <?php perch_content('Details'); ?> </div> </div> </div> </div> <script src='//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js' type='text/javascript'></script> <script type='text/javascript' id='snipcart' data-api-key='OGU5ODljYmItZDYxYy00ZmI3LThiZmMtZmQ4MDk3NDIzYzEx' src='https://app.snipcart.com/scripts/snipcart.js'></script> </body> </html>
I see no reason why that shouldn't work. What does this output?
<?php perch_page_url(array( 'include-domain' => true, )); ?>
It spits out this which is correct.
Ok, progress! How about this:
<?php $out = perch_page_url(array( 'include-domain' => true, ), true); echo $out; ?>
looks to be the same result
Ok, great. I wonder if the 'page' variable name is being trampled over somewhere (PHP is bad for this).
Give this a go:
PerchSystem::set_var('full_page_url', perch_page_url(array( 'include-domain' => true, ), true));
and then in your template
<perch:content id="full_page_url" type="text" />
Nope you can view the page and see that "full_page_url" is empty.
Is this this region you're using?
perch_content('Details');
if so:
perch_content_custom('Details', array());
Okay I added it to that page.
And the perch_content_custom() change?
perch_content_custom()
yes
<?php include('../admin/runtime.php'); ?> <?php PerchSystem::set_var('full_page_url', perch_page_url(array( 'include-domain' => true, ), true)); ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title><?php perch_pages_title(); ?></title> <link id='snipcart-theme' type='text/css' href='https://app.snipcart.com/themes/base/snipcart.css' rel='stylesheet' /> </head> <body> <br /> <div style="width:900px; margin:0 auto;"> <div style="float:left; background-color:whitesmoke; padding:10px;"> <div style="width:200px; float:left;"> <p><strong>Sub Pages</strong></p> <?php perch_pages_navigation(array( 'from-path' => '/snipcart', 'levels' => 0, 'hide-extensions' => false, 'hide-default-doc' => true, 'flat' => false, 'template' => 'item.html', 'include-parent' => false, 'skip-template' => false, 'siblings' => false, 'only-expand-selected' => false, 'add-trailing-slash' => false, 'navgroup' => false, 'include-hidden' => false, )); ?> </div> <div style="width:550px; float:right; background-color: #fff; padding-left: 20px;"> <div style="float:left;"> <h1><?php perch_pages_title(); ?></h1> <?php perch_content_custom('Details', array()); ?> </div> </div> </div> </div> <script src='//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js' type='text/javascript'></script> <script type='text/javascript' id='snipcart' data-api-key='OGU5ODljYmItZDYxYy00ZmI3LThiZmMtZmQ4MDk3NDIzYzEx' src='https://app.snipcart.com/scripts/snipcart.js'></script> </body> </html>
Puzzling. Can you try rearranging:
<?php PerchSystem::set_var('full_page_url', perch_page_url(array( 'include-domain' => true, ), true)); perch_content_custom('Details', array()); ?>
then
That doesn't seem to work? And it is also adding a text field in the control panel in that region too.
Fatal error: Call to undefined function perch_page_url()
Are you running an old version?
This site was out of date and is now updated to the latest. That fixed the error on the front end but it still is not spitting out the url as well as it is showing a text area in the admin.
What does
<perch:showall />
give you?Here is a link where you can see the show all tag output.
https://perch.uisandbox.es/snipcart/brandon.php
So it's being set, but with no value. Can you show me the code you've got in your page?
I see no reason why that shouldn't work. What does this output?
It spits out this which is correct.
https://perch.uisandbox.es/snipcart/brandon.php
Ok, progress! How about this:
looks to be the same result
https://perch.uisandbox.es/snipcart/brandon.php
Ok, great. I wonder if the 'page' variable name is being trampled over somewhere (PHP is bad for this).
Give this a go:
and then in your template
Nope you can view the page and see that "full_page_url" is empty.
https://perch.uisandbox.es/snipcart/brandon.php
Is this this region you're using?
if so:
Okay I added it to that page.
https://perch.uisandbox.es/snipcart/brandon.php
And the
perch_content_custom()
change?yes
Puzzling. Can you try rearranging: