Buy
Filters

Overview

Filters enable the admin to modify/hook into certain aspects of the task being done. There are several Filters in SitePad that you can take advantage of.

Note : Filters have been added since SitePad version 1.0.7

The following guide will show you how the Server Admin can configure Filter Functions to customize the domains list and several other events.

  • SSH to your server and go to the following path:
/usr/local/sitepad/hooks/
  • You can see the file filter.txt.
  • Rename the file to make it a PHP file as filter.php.
  • Uncomment the function that matches your requirement, add the code inside the function as per your requirements and save the file.
  • That's it you have configured your filter.

insert_filter

  • We make use of insert_filter function to trigger a specific filter.
insert_filter(string $tag, string $function_to_add, int $priority, int $accepted_args);

Parameters

ParamTypeDescription
$tagstring/RequiredAction name that triggers the specific function.
$function_to_addstring/RequiredName of the function to be triggered.
$priorityint/optionalPriority in which you want the filter to be triggered. (Default is 10)
$accepted_argsint/optionalNumber of arguments accepted by the filter function. (Default is 1)

Example 
Following is the example describing how a filter is triggered by an action:

If you would like to make some changes to the user's domains list in SitePad, you will have to rename the file filter.txt to filter.php and uncomment the following part and add the code in my_domains_list() function.

insert_filter('domains_list', 'my_domains_list', 1, 1);

function my_domains_list($domains){
	// Add your custom code here
	
	$domains['my.domain.com'] = '/home/username/public_html/mydomain/';
	
	return $domains;
}

insert_filter adds the data added by you to SitePad and when the appropriate event is triggered your respective function is called. For eg., in the above example, whenever the event domains_list occurs, function my_domains_list is called and the code inside the same is executed. 

domains_list

Description 
The domains_list filter will trigger your function with the list of domains fetched by SitePad using the control panel API. You can use this filter to modify the list of domains as per your preference.

Note : The parameter in this function will be an array which will have the domain name as the key and the full path to the domain as the value.

Usage 
Uncomment the following part inside filter.php and add your code inside the function my_domains_list:

insert_filter('domains_list', 'my_domains_list', 1);
function my_domains_list($domains){
	// Add your custom code here	
	$domains['my.domain.com'] = '/home/username/public_html/mydomain/';
	
	return $domains;
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list