Jump to content

Recommended Posts

Posted

Hi,

I'm in the process of relaunching a site of mine and wanted to build and test it side by side with the current site.

I tried to set the template folder in ready.php for some users with $config→setLocation() to a different folder (as described here):

$userNamesWithDevAccess = ['testuser'];
if(in_array($user->name, $userNamesWithDevAccess)) {
	$config->setLocation('templates', 'site/templates-dev/');

	echo '<pre>';
	var_dump($config->urls->templates);
	var_dump($config->paths->templates);
	echo '</pre>';
}

This seems to work as intended:

string(21) "/site/templates-dev/"
string(54) "/Users/myaccount/mysite/site/templates-dev/"

But when I go to my frontend, there's only a blank page besides my var_dump. (Same blank page when I remove the var_dump test.)

If I go to the backend I get the following error message:

Hey now… Error: Exception: Missing or non-readable template file: site/templates-dev/site/templates/admin.php (in wire/modules/PageRender.module line 584)

#0 wire/core/Wire.php (416): PageRender->___renderPage(Object(HookEvent))
#1 wire/core/WireHooks.php (968): Wire->_callMethod('___renderPage', Array)
#2 wire/core/Wire.php (484): WireHooks->runHooks(Object(PageRender), 'renderPage', Array)
#3 wire/core/WireHooks.php (1094): Wire->__call('renderPage', Array)
#4 wire/core/Wire.php (484): WireHooks->runHooks(Object(DefaultPage), 'render', Array)
#5 wire/modules/Process/ProcessPageView.module (193): Wire->__call('render', Array)
#6 wire/modules/Process/ProcessPageView.module (114): ProcessPageView->renderPage(Object(DefaultPage), Object(PagesRequest))
#7 wire/core/Wire.php (416): ProcessPageView->___execute(true)
#8 wire/core/WireHooks.php (968): Wire->_callMethod('___execute', Array)
#9 wire/core/Wire.php (484): WireHooks->runHooks(Object(ProcessPageView), 'execute', Array)
#10 index.php (55): Wire->__call('execute', Array)
#11 {main}

(I modified the line 584 in PageRender.module to output the whole path.)

So looking at the path (site/templates-dev/site/templates/admin.php), it seems the system prepends the new path to the old path. Which is probably also the reason for the blank pages at the frontend.

Is this a bug, or am I doing something wrong?

Thanks!

ProcessWire 3.0.246

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...