File Structure

From Nephtali Documentation

Jump to: navigation, search

Nephtali provides complete freedom in terms of the directory structure of your website. Additionally, the markup for dynamic pages is located in the same location as markup for static pages: within the public directory of your website.

Add functionality by file

To add functionality to an existing web page, merely create a Nephtali file in the nsite directory of Nephtali that matches the file path of the markup page.

For instance, the Nephtali homepage (index.php) has a Nephtali file (nsite/index.php) that provides all of the functionality to the homepage. If you had a file in an admin directory (http://yoursite.com/admin/passwords.php), you'd merely add the Nephtali file nsite/admin/passwords.php. Simple! You are in complete control of your directory structure and file naming.

Add functionality by directory

The admin example does bring to light one possibility: What if you want to include functionality across several pages by directory?

Nephtali accommodates this through its nregister.php file. If you'd like to include a script that checks for an auth token (in this case, a session var), simply include the code you would in a normal Nephtali file and check to see if the current path matches the one you're adding functionality for:

Here's code to add to the nregister.php file that redirects requests without the necessary session var:

if (n\url\current_path($paths = array('/admin')))
{
	n\pipe\register(
		$name = 'auth', 
		$function = function($markup)
		{
                        if (!isset($_SESSION)) session_start();
	
	                if (!isset($_SESSION['is_member']))
		        n\url\redirect('https://yourwebsite.com/login.php');
		}
	);
}