Forum
Sharing content across pages
After failing with the list/detail two page setup I have decided to take this back to a basic test, and it's just not working.
I have index.php in the root folder. A simple region created using the text_block template filled in with "Just some text"
<?php include('perch/runtime.php'); ?>
<!DOCTYPE html>
<html lang='en'>
<title>Test</title>
<head>
</head>
<body>
<?php perch_content('Intro'); ?>
<script></script>
</body>
</html>
This display "Just some text" — All good.
I have then created another.php again in the root folder
<?php include('perch/runtime.php'); ?>
<!DOCTYPE html>
<html lang='en'>
<title>Test</title>
<head>
</head>
<body>
<?php
perch_content_custom('Intro', array(
'page'=>'index.php',
'template'=>'text_block.html',
'count'=>1
));
?>
<script></script>
</body>
</html>
It displays nothing. A var_dump returns NULL
I had a similar issue with my footer's region which I only resolved by making the region shared, which doesn't seem right to me.
Debug returns this. I'm guessing it's page path options?
SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Intro' AND (regionPage='index.php' OR regionPage='*') No matching content regions found. Check region name (Intro) and page path options.
Problem partially solved. It's a root directory issue, which I think is covered in the getting started docs. I wrongly presumed my subfolder with perch in it would be considered to be the root, but it's not.
So /foldername/index.php works.
echoing $_SERVER['REQUEST_URI'] on my index page gave me a clue and the debug was useful.
Now to try and address the root folder/subfolder issue
I believe I have now fixed the root folder issue. Initially I avoided the virtualhost recommendation, because I suspected it would open a whole can of worms, which it did. Quite a bit of time and trial and error to get something working.
I'm using xampp and to the uninitiated like myself I fixed it as follows:
In C:\xampp\apache\conf\httpd.conf search for 'listen'. You will find something like 'Listen 80'
Add another listen port underneath, for instance Listen 8080 and save
In C:\xampp\apache\conf\extra\httpd-vhosts.conf
Add the following
<VirtualHost *:8080> DocumentRoot "C:/xampp/htdocs/projectfolder" ServerName localhost:8080 </VirtualHost>
Obviously replace projectfolder with your project folder name and 8080 with the port number you chose
Lastly in perch\config\config.php change define('PERCH_LOGINPATH', '/projectfolder/perch');
to
define('PERCH_LOGINPATH', '/perch');
you should now be able to use localhost:8080/index.php instead of localhost/projectfolder/index.php and /index.php will now work in perch_content_custom
If this is bad advice then obviously please do correct me. It's only what I managed to source from stackoverflow and the like.