Jump to content

_main.php AdminThemeUikit - using multi instance


xfroggy
 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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By Robin S
      This module lets you add some custom menu items to the main admin menu, and you can set the dropdown links dynamically in a hook if needed.
      Sidenote: the module config uses some repeatable/sortable rows for the child link settings, similar to the ProFields Table interface. The data gets saved as JSON in a hidden textarea field. Might be interesting to other module developers?
      Custom Admin Menus
      Adds up to three custom menu items with optional dropdowns to the main admin menu.
      The menu items can link to admin pages, front-end pages, or pages on external websites.
      The links can be set to open in a new browser tab, and child links in the dropdown can be given an icon.
      Requires ProcessWire v3.0.178 or newer.
      Screenshots
      Example of menu items

      Module config for the menus

      Link list shown when parent menu item is not given a URL

      Advanced
      Setting child menu items dynamically
      If needed you can set the child menu items dynamically using a hook.
      Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); if($menu_number === 1) { $colours = $event->wire()->pages->findRaw('template=colour', ['title', 'url', 'page_icon']); $children = []; foreach($colours as $colour) { // Each child item should be an array with the following keys $children[] = [ 'icon' => $colour['page_icon'], 'label' => $colour['title'], 'url' => $colour['url'], 'newtab' => false, ]; } $event->return = $children; } }); Create multiple levels of flyout menus
      It's also possible to create multiple levels of flyout submenus using a hook.

      For each level a submenu can be defined in a "children" item. Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); if($menu_number === 1) { $children = [ [ 'icon' => 'adjust', 'label' => 'One', 'url' => '/one/', 'newtab' => false, ], [ 'icon' => 'anchor', 'label' => 'Two', 'url' => '/two/', 'newtab' => false, 'children' => [ [ 'icon' => 'child', 'label' => 'Red', 'url' => '/red/', 'newtab' => false, ], [ 'icon' => 'bullhorn', 'label' => 'Green', 'url' => '/green/', 'newtab' => false, 'children' => [ [ 'icon' => 'wifi', 'label' => 'Small', 'url' => '/small/', 'newtab' => true, ], [ 'icon' => 'codepen', 'label' => 'Medium', 'url' => '/medium/', 'newtab' => false, ], [ 'icon' => 'cogs', 'label' => 'Large', 'url' => '/large/', 'newtab' => false, ], ] ], [ 'icon' => 'futbol-o', 'label' => 'Blue', 'url' => '/blue/', 'newtab' => true, ], ] ], [ 'icon' => 'hand-o-left', 'label' => 'Three', 'url' => '/three/', 'newtab' => false, ], ]; $event->return = $children; } }); Showing/hiding menus according to user role
      You can determine which menu items can be seen by a role by checking the user's role in the hook.
      For example, if a user has or lacks a role you could include different child menu items in the hook return value. Or if you want to conditionally hide a custom menu altogether you can set the return value to false. Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); $user = $event->wire()->user; // For custom menu number 1... if($menu_number === 1) { // ...if user does not have some particular role... if(!$user->hasRole('foo')) { // ...do not show the menu $event->return = false; } } });  
      https://github.com/Toutouwai/CustomAdminMenus
      https://processwire.com/modules/custom-admin-menus/
    • By sambadave
      Hi there
      Short version of question
      Let's say I have a page in the admin that contains a field... Is it possible to output the content from that field on another page in the admin? Almost like a reference.
      Longer version of question (with example)
      A house builder with multiple (60+) developments. They want to be able to create notices/messages that can be added to one or many developments. Handy for things like regional covid lockdowns or temporary office closures due to bad weather.
      My approach for the admin editing options:
      Add each message to each development
      Pros: You edit the message on the development page in context
      Cons: Very time consuming and repetitive if the same message needs to be applied to 60+ developments
        Control all the messages from one admin page and say which development each message should be applied to
      Pros: Easier to add/remove messages to more than one development at a time. Control all messages from one place.
      Cons: Content is not added on development page, which is where typical admin users may expect to find it I went for option 2 due to flexibility, and created a page within the admin for global development notices. This contains a repeater with:
      Field for message to display Checkbox list of all developments. The user can select which ones to apply each message to It's working really well but the only thing is that if the user goes to a specific development in the admin, the relevant messages aren't displayed in context (as they aren't edited on that page and instead on the global development notices page)... which may cause confusion when a new staff member / content admin tries to edit the text but there is no field when they go to the development admin page where they expect to see it...
      Solution???
      I don't require the message(s) to also be editable on the development page, but I wondered if there was a nice way to show it/them somehow. I feel like I am missing something really simple as I'm sure ProcessWire will have a nice way of achieving this, or maybe there are field settings that allow this kind of thing to happen?
      Any ideas on approaches or similar experiences would be much appreciated, even if it is just a much simpler example with the content from one field being shown on another admin page to get the ball rolling.
      Thanks in advance for any advice :)
    • By humanafterall
      Hi,
      I would like to set an admin template to 'https only' as recommended in the Processwire security docs.
      However if I do this it forces this setting locally too, resulting in https://localhost requests which result in an error page.
      Is there a simple way round this? Setting https for templates in the config?
      Thanks!
    • By DanielKit
      Hi. I'm currently stuck at the login page in my project. Once I enter my admin username and my password and press login, nothing happens. The page just reloads. However, the URL changes from http://myipaddress/processwire to http://myipaddress/processwire/?login=1. I've checked all of my server settings, and to my knowledge, all seems to be fine there. I don't know where to go from here.. Thanks in advance!
    • By modifiedcontent
      Small annoyance: I get a horizontal scrollbar in UIkit admin area - or actually Admin Theme Boss based on Uikit 3. I tried to fix it with CSS, but had trouble isolating/targeting it and don't want to mess with module or core files. I think this issue has been reported before. Is there a recommended fix? 
×
×
  • Create New...