Jump to content
MateThemes

Admin Page without Module

Recommended Posts

Hello everyone!

I have searched the forum for quite a long time and I tried some solutions for my topic but nothing seems to work.

I need to create a Settings Page and for a native feeling I want to create it under the main navigation on top. The settings page should hold the Main Logo, some styling and other settings. As I said nothing seems to work for me. I tried to create a Page under Admin with Admin Template and ProcessPageEdit but then I can't assign an image field. 

I don't want to write a module because it is to much work for only 3 settings.

I hope someone of the forum could help me out!

Have a nice day!

Share this post


Link to post
Share on other sites

You only need to create a hidden page with blank template let say settings, then put all settings in that page:

$page->rootParent()->child('template=settings, include=hidden');

or put it in _init.php:

$mySettings = $page->rootParent()->child('template=settings, include=hidden');

Share this post


Link to post
Share on other sites
18 hours ago, bernhard said:

Hi,

it would be helpful for everybody to list what you've tried and what did not work and why 😉 

What about https://modules.processwire.com/modules/settings-factory/ ?

As I described in short, I tried it with a custom settings page (with a blank template) under admin. But then no Fields were assigned. I tried it this way because I want to have a native feeling for the settings and the page should appear under the main navigation.

Is there any detailed tutorial for my purpose? I didn't find any.

I didn't know the module "settings factory" I will give it a try.

Share this post


Link to post
Share on other sites

Hi ... Jonathan Lahijani has a great tutorial on youtube that can help you

Simply put, you need to create an option template,
then add 2 pages, one in the page tree named options, to which you choose the option template, and under the admin add another page and change the name, for example (admin_options), so that the names are not identical. Choose a process named ProcessPageEdit and save the page ...
in admin.php paste the code

// Custom Options Page
if( page()->name == 'admin_options' ) input()->get->id = pages()->get('options')->id;

Finally, you can add some css to hide the options page in the page tree.

/** Hook Admin Custom CSS */
$wire->addHookAfter('Page::render', function($event) {
	if(page()->template != 'admin') return; // Check if is Admin Panel
	$value  = $event->return; // Return Content
	$templates = urls()->templates; // Get Template folder URL
	$style = "<link rel='stylesheet' href='{$templates}assets/css/admin.css'>"; // Add Style inside bottom head
	$event->return = str_replace("</head>", "\n\t$style</head>", $value); // Return All Changes
});

You can also download the profile that has the option page created and see how you can create your own options page
https://github.com/rafaoski/site-minimal

 

  • Like 2

Share this post


Link to post
Share on other sites
18 hours ago, rafaoski said:

Hi ... Jonathan Lahijani has a great tutorial on youtube that can help you

Simply put, you need to create an option template,
then add 2 pages, one in the page tree named options, to which you choose the option template, and under the admin add another page and change the name, for example (admin_options), so that the names are not identical. Choose a process named ProcessPageEdit and save the page ...
in admin.php paste the code


// Custom Options Page
if( page()->name == 'admin_options' ) input()->get->id = pages()->get('options')->id;

Finally, you can add some css to hide the options page in the page tree.


/** Hook Admin Custom CSS */
$wire->addHookAfter('Page::render', function($event) {
	if(page()->template != 'admin') return; // Check if is Admin Panel
	$value  = $event->return; // Return Content
	$templates = urls()->templates; // Get Template folder URL
	$style = "<link rel='stylesheet' href='{$templates}assets/css/admin.css'>"; // Add Style inside bottom head
	$event->return = str_replace("</head>", "\n\t$style</head>", $value); // Return All Changes
});

You can also download the profile that has the option page created and see how you can create your own options page
https://github.com/rafaoski/site-minimal

 

Hello!!!

Thank you for the share. This is what I need!!!

What is the best way to get the fields in the template if you want to access them? 

Share this post


Link to post
Share on other sites

The easiest way is to set the options page in the _init.php file:

$siteOptions = $pages->get('/options/');

// If you set setFunctionsAPI ( $config->useFunctionsAPI = true;  ) to true in the configuration file, you can display them in the template in this way

$siteOptions = pages()->get('/options/');

//or
$siteOptions = pages('/options/');

Then in the template just display the fields:

<h1><?= $siteOptions->site_name ?></h1>

<?php
// In the field settings you should select to display a single image
if ($siteOptions->logo): ?>

	<img src="<?= $siteOptions->logo->url ?>" width='100' alt="<?= $siteOptions->logo->description ?>">

<?php endif ?>

Or add new “Unique” status for pages https://processwire.com/blog/posts/pw-3.0.127/
Add this status to the Options page and in the _init.php file get this way:

$siteOptions = pages()->get('options');

// or
$siteOptions = pages('options');

 

 

  • Like 1

Share this post


Link to post
Share on other sites
On 7/31/2019 at 7:54 AM, rafaoski said:

The easiest way is to set the options page in the _init.php file:


$siteOptions = $pages->get('/options/');

// If you set setFunctionsAPI ( $config->useFunctionsAPI = true;  ) to true in the configuration file, you can display them in the template in this way

$siteOptions = pages()->get('/options/');

//or
$siteOptions = pages('/options/');

Then in the template just display the fields:


<h1><?= $siteOptions->site_name ?></h1>

<?php
// In the field settings you should select to display a single image
if ($siteOptions->logo): ?>

	<img src="<?= $siteOptions->logo->url ?>" width='100' alt="<?= $siteOptions->logo->description ?>">

<?php endif ?>

Or add new “Unique” status for pages https://processwire.com/blog/posts/pw-3.0.127/
Add this status to the Options page and in the _init.php file get this way:


$siteOptions = pages()->get('options');

// or
$siteOptions = pages('options');

 

 

Hello!!!

Thank you very much for your help!!! It works now like a charm!

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By alanxptm
      Hi, first time here.
      I've been working on my first site with PW and it has been a pleasure, I'm around 75% of structure and logic completion I think, and polishing some things now.
      My question is: I have a parent 'category' page that musn't be editable by the author role, but they must be able to add children 'post page' to the 'category'.
      I've been playing with the settings and can just let the author create childs if is able too to edit the parent category, so.. How can I do it?
       
       
    • By Noel Boss
      👋 PW Pros…
      I have some hooks that I need to bind at the init phase (or even __construct) and I was wondering, and I couldn't find a good and simple way to determine if I'm in the admin. Would be nice if there is a reliable short option to do so, but I can't seem to find one… Is there a coherent way to tell this no matter where I am?
      Right now, I use the following method inside one of my modules:
      public function isAdmin($page = null) { if ( strpos($this->input->url, $this->urls->admin) !== false || $this->process instanceof ProcessPageList || $this->process instanceof ProcessPageEdit || ($page instanceof Page && $page->rootParent->id == $this->config->adminRootPageID) ) { return true; } return false; } @ryan wouldn't it be nice to have something like wire()->isAdmin(); like wire()->user->isLoggedin(); to tell if we are in admin – very early on (probably even in __construct() phase of modules?
    • By Noel Boss
      Admin Theme Boss
      A light and clear theme based on Uikit 3
      Features
      Five unique color options Beautifully redesigned login screens Modern typography using Roboto Condensed Extended breadcrumb with edit links Extends AdminThemeUikit, so you can continue using all current and future AdminThemeUikit features Option to activate theme for all users Compatibility with AdminOnStreoids and other third party modules   Updated and Releases
      There is a shiny new release page where you can subscribe to updates for new releases of AdminThemeBoss.   Color Variants:
      ProcessWire Blue


       
      Dark Black


       
      Vibrant Blue

       
      Happy Pink

      Smooth Green *new with 0.6.1*

       
      Requirements
      Requires a current ProcessWire version with AdminThemeUikit installed and activated.
      Installation
      Make sure AdminThemeUikit is activated Go to “Modules > Site > Add New“ Paste the Module Class Name “AdminThemeBoss“ into the field “Add Module From Directory“ Click “Download And Install“ On the overview, click “Download And Install“ again… On the following screen, click “Install Now“

      Manual Installation
      Make sure the above requirements are met Download the theme files from GitHub or the ProcessWire Modules Repository. Copy all of the files for this module into /site/modules/AdminThemeBoss/ Go to “Modules > Refresh” in your admin Click “Install“ on the “AdminThemeBoss“ Module
    • By Clément Lambelet
      Hey!
      I've been working on a Processwire installation (3.0.123) for a few days now and I must have made a big mistake this morning because the links in the admin's main menu no longer appear.
      This is not related to the admin theme, because the bug occurs with all themes (Default, Reno, Uikit).
      I tried to reinstall with the dev version (3.0.136), but the problem is still there. I also uninstalled all the modules I had added, without success. There is no error in the js console. 
      I still can access/view/edit the pages  by going through the admin/page list.
      Thanks in advance for your help!


    • By BitPoet
      Inspired by this thread with a little nugget based on AOS by @benbyf to visually distinguish development systems from production ones, I wrote a small module that does the same and lets you adapt colors and text.
      Link to the github repo:
      AdminDevModeColors
      Version 0.0.1 is still very alpha and only tested on PW 3.0.124.
      Description
      This module lets you change the color for the top toolbar and add a small piece of text for development systems, so you are immediately you aren't working on production (and vice versa). The adaptions are made through pure CSS and applied if either the "Enable DEV mode" checkbox in the module's configuration is checked or the property $config->devMode is set to true in site/config.php.
      Works with Default, Reno and Uikit admin themes (though probably needs a lot of testing with different versions still).
      Since a screenshot says more than thousand words...
      Production system (unchanged):

      Dev system (Default admin theme):

      Dev system (Reno admin theme):

      Dev system (Uikit admin theme):

      Feel free to leave any feedback here and report any problems either in this thread or the github issue tracker.
       
×
×
  • Create New...