navigation.php

File structure

This file contains links that should be added to navigation bars. It does not contain the actual link names (those are stored in language files).

$navigation = array(
	'cp_top' => array( // navigation list
		'plugins/articles' => array( // unique link keyword
			'parent' => 'plugins', // parent link keyword
			'url' => 'plugins/articles', // link URL
			'name' => 'articles', // reference to language item (in the 'system_navigation' section)
			'attr' => '{"class":"articles"}', // json encoded link attributes
			'order_id' => 0 // order ID
		),
		'plugins/articles/manage' => array( // unique link keyword
			'parent' => 'plugins/articles', // parent link keyword
			'url' => 'plugins/articles', // link URL
			'name' => 'articles_manage', // reference to language item
			'attr' => '',
			'order_id' => 1 // order ID
		),
		'plugins/articles/fields' => array( // unique link keyword
			'parent' => 'plugins/articles', // parent link keyword
			'url' => 'system/fields/articles', // link URL
			'name' => 'system_fields', // reference to language item
			'attr' => '',
			'order_id' => 2 // order ID
		),
		'plugins/articles/settings' => array( // unique link keyword
			'parent' => 'plugins/articles', // parent link keyword
			'url' => 'system/config/articles', // link URL
			'name' => 'system_settings', // reference to language item
			'attr' => '',
			'order_id' => 3 // order ID
		)
	),
	'site_top' => array( // navigation list
		'site/articles' => array(
			'parent' => '',
			'url' => 'articles',
			'name' => 'articles',
			'attr' => '{"class":"articles"}',
			'order_id' => 3
		)
	),
	'site_user' => array( // navigation list
		'user/articles' => array(
			'parent' => '',
			'url' => 'articles/manage',
			'name' => 'my_articles',
			'attr' => '{"class":"nav articles"}',
			'order_id' => 5
		)
	)
);

The above code will add links to 3 different navigation bars: in the control panel main navigation, main site navigation (front end) and user navigation (when logged in). Drop down box under the "plugins" tab in the control panel will now have "articles" link. And when you navigate to it, you will see 3 more links right under the main navigation bar:

  • Manage articles - points to 'cp/plugin/articles'.
  • Custom fields - points to 'cp/system/fields/articles'.
  • Settings - points to 'cp/settings/config/articles'.

Note that for the control panel links we did not have to include "cp" in the link URL, it's added automatically by the system.

Lists are saved into the "core_navigation" table in the database.

Language file

Language file "languages/english.php" will contain code like this:

$navigation = array(
	'ca' => array( // front end of the site and control panel
		'articles' => "Articles",
		'articles_new' => "New articles",
		'my_articles' => "My articles"
	),
	'cp' => array( // control panel only
		'articles_manage' => "Manage articles"
	)
);

Note that we don't have language items for "system_fields" and "system_settings" in the file. That's because they already exist in the "system" software plugin so we don't need to include them again, unless we want to name them differently, for example:

$navigation = array(
	'ca' => array( // front end of the site and control panel
		'articles' => "Articles",
		'articles_new' => "New articles",
		'my_articles' => "My articles"
	),
	'cp' => array( // control panel only
		'articles_manage' => "Manage articles",
		'system_fields' => 'Customize fields',
		'system_settings' => 'Update settings'
	)
);