Menus and Node Types

article_Screenshot - 07022012 - 15:05:08.png

You will always require an execution point (url) for your first controller or page. You can obviously turn any page you create into your application or sites landing page. However, here I will be explaining exactly what getting started gets to once you start developing more advanced controllers. When we refer to a script, controller or node, we generally refer to a single PHP file that you created.

Menus with its node types are a way to point to php files that will needs to run when a certain url is executed. PHPDevShell will then do all the security and load that controller in the shell of PHPDevShell. It is like running a php script in its own safe environment. Remember to also check out the Example Plugin for some good examples.

The power of menus

Not only can you create multiple instances of how a script should be executed from the menu system, you can also set exact permission on who can access that menu and also what can he see once he accessed it.

If you have not yet done so, please read getting started so you know how you go about creating a menu for your plugins. You will later learn how to create full installation sets of how you can make your plugin install with all its menus.

Menu node types

When assigning a controller/script to a menu, there are different node options you can select for them, each one means something different and will cause the controller/script to act differently.

Plugin Nodes are always developed the same way as you would develop a normal node (type 1), except they behave differently depending on the node type you choose.

Plugin Nodes

Plugin nodes has a node controller/script that links from the menu item and executes.

(1) Standard Web Page

This is a direct call and execution, this node controller will sit in your plugin folder and will execute and spit out whatever you wrote in PHP. This is generally the default type you will choose. This controller could be linked to something as simple as : plugins/MyPlugin/mysimplenode.php

	echo "Hello World, this is my first script in PHPDevShell.";

Screenshot - 07022012 - 14:18:46.png

(9) Widget Module

This little beauty allows you to call from any other node this node as ajax. So basically you develop this node just like the (1) Standard Web Page, except it is available to call as ajax with a very simple command. The way it will be called will be framed like you expect from a widget, like the example right:

(10) Ajax Call

Exactly like Widget Modules, except it loads the the node without the surrounding widget style border and heading.

(11) Lightbox

The lightbox node also loads from within a normal node, except it will pop up the lightbox type node as a neat lightbox page.

Link Existing Node

These node types links to existing nodes with the idea that it works like symlinks from the Linux file system. What this boils down to is the fact that you can create multiple menu items to a single controller. Each link could send specific information through and could perhaps change the behavior of a controller.

(2) Plain Link

This will create a link to an existing node, when clicked it will load the controller exactly as if it was its own controller.

(3) Jump To Link

Instead of linking to the controller/script directly, this when clicked will load the controller the original menu item links to and will also jump to the level where this menu sits, as if you clicked the original menu item.

(6) Place Holder

Serves no real purpose besides being a parent for a group of similar menu items. Nothing happens when you click on this menu item.

External File

(4) Load External File from outside plugin

In general this should not be used, however in some cases where you want to load a PHP file that has nothing to do with PHPDevShell, you could use this.

HTTP Link

(5) Normal external http link

Just a link to an external http address.

iFrame

(7) Http location inside iframe Height

In general this should not be used, it will create an iframe inside your theme and load the page of the url provided.

Cronjob Node

(8) Automatic cronjob

This very useful node type is created like any other plugin node. When selected as a cronjob node it will configure the node to appear in PHPDevShell cronjob manager. This allows you to manage scripts to execute in a timely fashion without human interaction. PHPDevShell can handle all the cronjob nodes differently and gives you allot of maintenance power.

Calling menus from inside nodes

Not always will you want to use the menu navigation system to access your script, you might want to create a link from your existing script, or you might want to call another node as ajax. Not only this you want it to be the same on all system, independent of friendly URL's being on or off.

When installing menus, an automatic unique menu id is created from the plugin path. This means one can determine what your menu id is going to be on all systems. This is useful for where you want to call a menu item from another controller. As long as the path to the file stays the same, the menu id will be the same on all systems that your plugin will get installed onto.

So lets use our first node type plugins/MyPlugin/mysimplenode.php as the example again. Lets say I want to create a link to the existing "Readme" screen of PHPDevShell, if I view the Menu Manager UI, I can clearly see that the ID for this menu item is 2266433229 which will always be the same on all systems as long as the controller path stays the same.

	echo "

Hello World, this is my first script in PHPDevShell.

"; // Lets create a link to another node. $url = $this->navigation->buildURL('2266433229'); // return example http:/ /somedomain.com/readme.html echo "

Click here to go to Readme.

";

That's not all...

Just touching the tip of the ice berg, this takes into account that you will be using the Menu Manager UI to create menu items. There are more sustainable ways of creating menu items and this is done by the plugin config and installer file. This topic is covered in later documentation page.

PHPDevShell © 2010 - All rights reserved.