Jump to content
Macrura

Simple Built-In Docs

Recommended Posts

This is a very simple way to display some instructions to the admin users.

Before starting, you need to write some docs; they can be a hidden branch of your page tree, using basic-page, or a different template of your choosing. You should make each subject it's own page under the docs so you can output each one under an accordion trigger.

Required Module: Admin Custom Pages

1.) Follow all instructions to install the module; Also add the ACP_scripts_and_styles field to the admin template.

2.) Make a new page under admin, called Docs or whatever; assign the process as described in the module instructions.

3.) Make a template in your themes directory to generate the output of the docs page.

4.) Select that template from the page select in the admin custom page you created.

5.) also make a folder to keep your admin custom pages scripts and styles;

6.) create a css file to use for the display output and some basic styles (like ol, ul li etc..)

7.) Add the custom css file to your ACP_scripts_and_styles field.

You can use any output you want, but i'm using a nested accordion, which is provided here:

http://tympanus.net/codrops/2013/03/29/nested-accordion/

this is the content of the admin custom page:

<?php

    $docs = $pages->get(4259);

?>
<div id="docs">
    <ul id="cbp-ntaccordion" class="cbp-ntaccordion">
        <?php foreach($docs->children as $doc) { ?>
            <li>
                <h3 class="cbp-nttrigger"><?php echo $doc->title ?></h3>
                <div class="cbp-ntcontent">
                    <?php echo $doc->body;?>                        
                </div>
            </li>
        <?php } ?>
    </ul>
</div>

    <script src="<?php echo $config->urls->templates ?>_admin_custom/js/jquery.cbpNTAccordion.min.js"></script>
    <script>
        $( function() {
            $( '#cbp-ntaccordion' ).cbpNTAccordion();
        } );
    </script>

you'll also want to add the provided css, js and fonts that come with the Nested Accordion;

in the css file you'll need to point the fonts to the actual font directory, for example:

/site/templates/_admin_custom/fonts/icomoon_arrows/icomoon.eot

it should come out looking something like this:

*if you are using Reno theme, you can customize the icon, like for example fa-book, which is used in this example:

post-136-0-48074900-1416935874_thumb.png

--

Thanks & Credits to Diogo for originally creating the ACP module, and for Nico for getting it to work with the new admin theme system...

  • Like 18

Share this post


Link to post
Share on other sites

if you want to go further, you can use the nested accordion which allows for child accordions of the main topic;

you would need to create child pages for each main subject; in that case your template might look like this:

<?php

    $docs = $pages->get(4259);

?>
<div id="docs">
    <ul id="cbp-ntaccordion" class="cbp-ntaccordion">
        <?php foreach($docs->children as $doc) { ?>
            <li>
                <h3 class="cbp-nttrigger"><?php echo $doc->title ?></h3>
                <div class="cbp-ntcontent">
                    <?php echo $doc->body;?>
                    <?php if($doc->children->count()) { ?>    
                        <ul class="cbp-ntsubaccordion">
                            <?php foreach($doc->children as $child) { ?>    
                                <li>    
                                    <h4 class="cbp-nttrigger"><?php echo $child->title?></h4>
                                    <div class="cbp-ntcontent">
                                        <?php echo $child->body?>
                                    </div>
                                </li>
                            <?php } ?>
                        </ul>
                    <?php } ?>                         
                </div>
            </li>
        <?php } ?>
    </ul>
</div>

    <script src="<?php echo $config->urls->templates ?>_admin_custom/js/jquery.cbpNTAccordion.min.js"></script>
    <script>
        $( function() {
            $( '#cbp-ntaccordion' ).cbpNTAccordion();
        });
    </script>

in this code the sub-accordion is shown if there are child pages, and then it outputs the body of each child page in a sub-accordion, and it will end up looking something like this:

post-136-0-50302100-1417016126_thumb.png

a more advanced implementation with edit links and an add new doc for superusers:

<?php 

	$docs = $pages->get(4259); 

?>
<div id="docs">
	<ul id="cbp-ntaccordion" class="cbp-ntaccordion">
		<?php foreach($docs->children as $doc) { ?>
			<li>
				<h3 class="cbp-nttrigger"><?php echo $doc->title ?></h3>
				<div class="cbp-ntcontent">
					<?php echo $doc->body;?>
					<?php if($user->hasRole('superuser')) { ?>
					<div style="float:right;font-size:11px;">
					<a href="<?php echo $config->urls->admin?>page/edit/?id=<?php echo $doc->id?>">Edit: "<?php echo $doc->title?>"</a> 
					</div><?php } ?>
					<?php if($doc->children->count()) { ?>	
						<ul class="cbp-ntsubaccordion">
							<?php foreach($doc->children as $child) { ?>	
								<li>	
									<h4 class="cbp-nttrigger"><?php echo $child->title?></h4>
									<div class="cbp-ntcontent">
										<?php echo $child->body?>
										<?php if($user->hasRole('superuser')) { ?>
										<div style="float:right;font-size:11px;">
										<a href="<?php echo $config->urls->admin?>page/edit/?id=<?php echo $child->id?>">Edit: "<?php echo $child->title?>"</a> 
										</div><?php } ?>
									</div>
								</li>
							<?php } ?>
						</ul>
					<?php } ?> 						
				</div>
			</li>
		<?php } ?>
	</ul>
	<?php if($user->hasRole('superuser')) { ?>
	<div style="float:right;font-size:13px;">
		<a href="<?php echo $config->urls->admin?>page/add/?parent_id=4259">
			<button class="ui-button ui-widget ui-corner-all head_button_clone ui-state-default" name="button" value="Add New" type="button"><span class="ui-button-text"><i class="fa fa-plus-circle"></i> Add New Doc</span></button>
		</a> 
	</div><?php } ?>
</div>

	<script src="<?php echo $config->urls->templates ?>_admin_custom/js/jquery.cbpNTAccordion.min.js"></script>
	<script>
		$( function() {
			$( '#cbp-ntaccordion' ).cbpNTAccordion();
		});
	</script>

  • Like 3

Share this post


Link to post
Share on other sites

This is very practical. It can be used also to leave info

about the edits you did/do on a site.

Share this post


Link to post
Share on other sites

@changwuf31:

it is possible to print, but might require some additional code; for example you could do a printable pop up window;

for now i'm hoping that my clients save a tree and use these built in docs for reference..

this is a huge thing, especially psychologically and from a perspective of workflow; because now my clients know that there are docs, and consequently will probably check there first before contacting me; and on the flipside if they ask me a question that is already covered in the docs, i can bounce back with 'did you read the docs?'

Share this post


Link to post
Share on other sites

Using this module, in combination with the Template Select module, it is easily possible to show inline related documentation on the edit page.

Same setup as above, but adding the template select field on the doc template.

could also be further modified to support showing a doc only on a specified page, or children of a page, using selector fieldtype..

example module

https://gist.github.com/outflux3/3e76a1338b61d708157c

post-136-0-51288600-1422901251_thumb.png

  • Like 2

Share this post


Link to post
Share on other sites

For thoose how work with AdminCustomFiles Module:

https://processwire.com/talk/topic/7588-admin-custom-files/

You could easy get this both together just setup the docs - but instead of loading via ACP_scripts_and_styles field and on the admin template you could use this two files to get all the things right up...unzip the package in your "AdminCustomFiles" Folder and use it only with the output generating php stuff in the admin template like above:

<?php
    //only load the doc pages without js or css all done via AdminCustomFiles for ProcessAdminCustomPages
    $docs = $pages->get(1149);
?>

<div id="docs">
    <ul id="cbp-ntaccordion" class="cbp-ntaccordion">
        <?php foreach($docs->children('include=all') as $doc) { ?>
            <li>
                <h3 class="cbp-nttrigger"><?php echo $doc->title ?></h3>
                <div class="cbp-ntcontent">
                    <?php echo $doc->body;?>                        
                </div>
            </li>
        <?php } ?>
    </ul>
</div>

post-2327-0-35176000-1425994658_thumb.pn

Thanks to Macura for this great idea!

Regards mr-fan

ProcessAdminCustomPages.zip

  • Like 1

Share this post


Link to post
Share on other sites

hey mr-fan - good idea, makes it easier to setup;

hoping at some point to improve this whole thing, including how it displays (needs more styling for the text), and bundle it with the page docs tab, as a module...

  • Like 2

Share this post


Link to post
Share on other sites

This weekend i'm in short trip to Hamburg for vacation...

But you could write me a pm if i could help....not really fit with module creating but good with a helping hand and testing if needed?

Best regards mr-fan

Share this post


Link to post
Share on other sites

@mr-fan, thanks! with my current workload, i think i would start developing the module slowly and project it to be done by end of May or June; so i'll get back in touch!

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 cosmicsafari
      Hi all,
      I have been asked by a client whether we can setup load balancing for their existing Processwire site.
      From my investigations on Google and within these forums, it definitely seems possible but as a newbie with a basic understanding of the subject im a bit lost.
      Does anyone know of any existing tutorials for settings up load balancing with PW?
      What items would need to be changed on their current stand alone install, is there a list of best practices worth consulting etc?
      As I understand it we would need to have some sort of copying mechanism (rsync script most likely) in order to make sure any uploaded assets are shared between the main server and the fallback ones, other than that im not sure what else would need to be ammended.
      Any thoughts/help would be greatly appreciated.
    • By Sten
      Hello,
      I'd like to participate to a documentation about the page flow in PW. I am still a beginner and still have difficulties to see the big picture but I could help to the writing.
      What is the flow when a page is displayed or created ? It would be fine to draw a scheme with every stage in which one can add hooks. Something to describe the flow in time.
      May be it exists.
      page
      |
      fields
      |
      template
      What do you think ?
    • By EyeDentify
      Simple example for loading template specific CSS file.
      This example asumes that you have your CSS file in a directory relative to template root.
      Like:
      templates/css/my_template_specific.css
      Also i use in the template a simple text field to hold the name of the CSS file i want to load.
      I call this field 'css_file'
      Use what you feel comfortable with.
      So in your header section of the DOM notice the "page specific CSS" part?
      Thats were the magic happens. What happens is that we check to see if the file exists in the CSS dir relative to template root.
      And if it does we load it. Simple and effective.
      I load all other CSS that is used all over the site in global_styles.css first.
      And make sure you load template specific last, because then you can easily override CSS in global.
       
      DOM header example:
      <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title><?PHP echo($page->title); ?></title> <!-- main CSS --> <link rel="stylesheet" href="<?PHP echo($config->urls->templates); ?>css/global_styles.css"> <!-- page specific CSS --> <?PHP /* Use relative path in file_exists() */ if(file_exists('css/' . $page->css_file)) { echo("<link rel=\"stylesheet\" href=\"{$config->urls->templates}css/{$page->css_file}\">"); } ?> </head> <body> Thats my way of doing it. I am sure there is plenty of more ways to do it. This is for the newbies or anyone that wants more options.
      Good luck with your CSS out there in Cyberspace.
      Cheers from EyeDentify
    • By ARG
      Hello, I am completely new at PW, (and Php) coming from another CMS.  I decided to try to understand the beast, before crafting anything.
      So, I started  from the beginning: the simple web site tutorial.
      I am trying to output the Home page with Head and footer included in. 
      Here is my Home page code:
      include("./includes/head.inc.php"); echo "<h1>{$page->title}</h1>"; include("./includes/scripts.inc.php"); include("./includes/foot.inc.php"); Here is my  Head.inc.php code:
      <?php require_once("./includes/functions.inc.php"); ?> <!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="description" content="<?php echo $pages->get("/site-settings/")->site_meta_description; ?>"> <title><?php echo $pages->get("/site-settings/")->site_meta_description;?></title> <link rel="stylesheet" href="<?php echo $config->urls->templates?>css/simplegrid.css" /> <link rel="stylesheet" href="<?php echo $config->urls->templates?>css/site.css" /> </head> <body> And this the message I got, when I try to view my page:
      Compile Error: require_once(): Failed opening required 'C:/wamp64/www/processwire-master/site/templates/includes/includes/functions.inc.php' (include_path='.;C:\php\pear') (line 1 of C:\wamp64\www\processwire-master\site\assets\cache\FileCompiler\site\templates\includes\head.inc.php)
      Any advice would be helpful
      Thank you for your time.
       
    • By benbyf
      HELLO ALL!
      Context: I use serverpilot to setup and administrate my server patches for my hosted sites. As with many other serving companies, they write tutorials to setup software on their service. I asked them to provide a PW installation instruction and they have obliged however hitting on the following issue on installation with their default linux user:
      Issue:
       
      Basically at the end of the installation there is a warning to secure your config file which could have been done already by the system, I believe they're saying. Is there anything we can do with this, or should i ask them to carry on with the caveat that they should but in a bit of text saying this warning is normal and can be sorted in teh follow ways etc...?
      Interested in people's opinion.
×
×
  • Create New...