Jump to content

_main.php AdminThemeUikit - using multi instance


fredbob
 Share

Recommended Posts

Hi!

So I am trying to pull some information from another ProcessWire installation within the admin area (_main.php / page tree from the AdminThemeUikit module).

$pwpath = "/path/";
$pwurl = "https://url.example";
$pw = new ProcessWire($pwpath , $pwurl);

which then gives me this error

Quote

Error: Uncaught Error: Class 'ProcessWire' not found

 

I then read that if it is not already in a ProcessWire environment that I would have to include the core, 

require('/path/to/wire/core/ProcessWire.php'); 

Which I tried, and makes sense that it already says it is included.

 

So what now?

 

Here is my _main.php from the AdminThemeUikit module (work in progress), just for reference

Spoiler

<?php namespace ProcessWire;
/**
 * _main.php: Main markup template file for AdminThemeUikit
 *
 * FileCompiler=0
 *
 */

/** @var Config $config */
/** @var AdminThemeUikit $adminTheme */
/** @var User $user */
/** @var Modules $modules */
/** @var Notices $notices */
/** @var Page $page */
/** @var Process $process */
/** @var Sanitizer $sanitizer */
/** @var WireInput $input */
/** @var Paths $urls */
/** @var string $layout */

if(!defined("PROCESSWIRE")) die();

$adminTheme->renderExtraMarkup('x'); // forces it to cache
if(!isset($content)) $content = ''; ?>
<!DOCTYPE html>
<html class="pw" lang="<?php echo $adminTheme->_('en');
	/* this intentionally on a separate line */ ?>">
<head>
   	<?php 
   	include($config->paths->adminTemplates . '_head.php');
	echo $adminTheme->renderExtraMarkup('head');  
	?>
</head>
<body class='<?php echo $adminTheme->getBodyClass(); ?>'>

	<?php
	if($layout == 'sidenav') {
		include(__DIR__ . "/_sidenav-masthead.php");
		
	} else if($layout == 'sidenav-tree' || $layout == 'sidenav-tree-alt') {
		// masthead not rendered in this frame
		echo $adminTheme->renderNotices($notices);
		echo "<div class='uk-margin-small'></div>";
		
	} else if($layout == 'modal') {
		// no masthead
		echo $adminTheme->renderNotices($notices);
		
	} else {
		include(__DIR__ . "/_masthead.php");
	}
	?>

	<!-- MAIN CONTENT -->
	<main id='main' class='pw-container uk-container uk-container-expand uk-margin uk-margin-large-bottom'>
		<div class='pw-content' id='content'>
			
			<header id='pw-content-head'>
				
				<?php if($layout != 'sidenav' && $layout != 'modal') echo $adminTheme->renderBreadcrumbs(); ?>

				<div id='pw-content-head-buttons' class='uk-float-right uk-visible@s'>
					<?php echo $adminTheme->renderAddNewButton(); ?>
				</div>

				<?php 
				$headline = $adminTheme->getHeadline();
				$headlinePos = strpos($content, ">$headline</h1>");
				if(!$adminTheme->isModal && ($headlinePos === false || $headlinePos < 500)) {
					echo "<h1 class='uk-margin-remove-top'>$headline</h1>";
				}
				?>
				
			</header>
		
			<?php if($page->id == 3): // this is the id to the page that produces the page tree ?>
			<div class="uk-grid-match" uk-grid>
				<div class="uk-width-2-3@m">
					<div>
						<?php echo $content; // page tree ?>
					</div>
				</div>
				<div id="getting-started" class="bp-card uk-visible@m uk-width-1-3@m">
					<div class="uk-card uk-card-default uk-card-body">
						<h3>Getting Started</h3>
						<ul class="uk-list uk-list-striped">
                            <? // ==== Processwire Multi Instance ===== // 
                         	$pwpath = "/path/";
                         	$pwurl = "https://url.example";
                          	$pw = new ProcessWire($pwpath , $pwurl);
							?>
                        </ul>
						<h3>Notices</h3>
					    	<p>Hello and hello</p>
						<h3>Warnings</h3>
					    	<p>Hello and hello</p>
					</div>
				</div>
			</div>
			
          	<!-- Hides #getting-started section if the Page tree is called from the side bar (modal) -->
			<script type="text/javascript">
			if($("body").hasClass("modal")) {
		    	 $("#getting-started").hide();
			}
			</script>
			
			<?php else: ?>
			<div id='pw-content-body'>
				<?php
				echo $page->get('body');
				echo $content;
				echo $adminTheme->renderExtraMarkup('content');
				?>
			</div>
			<?php endif; ?>
			
		</div>
	</main>

	<?php
	if(!$adminTheme->isModal) {
		include(__DIR__ . '/_footer.php');
		if($adminTheme->isLoggedIn && strpos($layout, 'sidenav') !== 0) include(__DIR__ . '/_offcanvas.php');
	}
	echo $adminTheme->renderExtraMarkup('body');
	?>
	
	<script>
		<?php	
		if(strpos($layout, 'sidenav-tree') === 0) {
			echo "if(typeof parent.isPresent != 'undefined'){";
			if(strpos($process, 'ProcessPageList') === 0) {
				echo "parent.hideTreePane();";
			} else {
				echo "if(!parent.isMobileWidth() && parent.treePaneHidden()) parent.showTreePane();";
			}
			if($process == 'ProcessPageEdit' && ($input->get('s') || $input->get('new'))) {
				echo "parent.refreshTreePane(" . ((int) $input->get('id')) . ");";
			}
			echo "}";
		}
		?>
		ProcessWireAdminTheme.init();
	</script>
</body>
</html>

 

 

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...