Before you pull your extra time to read this article, let us make sure you are reading the right article for your problem.This article address the best approach of customizing the site defintion/templates and gives an insight how sharepoint defines,structures site templates.
CaseStudy: I've a requirement to create some custom sharepoint site definition,just to add some custom links/look to existing templates.So we have two approaches that can be followed here:
1. Edit onet.xml(present in 12 hive folder) of the base site defintion to add customizations - Read here
2. Use feature stapling concept to do it - Best approach
Lets see how the best approach(feature stapling) works, step by step;
feature stapling does need 2 features to accomplish our work.
One feature, staplee that really adds the customizations to our OOTB or custom site defintion
and the other feature, stapler that binds associates the above feature with the site definiton. Bascially we dont need not go into risk of editing onet.xml of site definiton neither stapling does. Thats simple and clean. Did you get a doubt how/when it adds cusotmizations? When ever a site is created based on this site template then the customizations defined in the staplee feature get added to the site .
Create a stapler :
Stapler will have 2 xml files, feature.xml and a manifest xml(here elements.xml)
Here the ID represent the staplee feature where customizations are defined or coded.
TemplateName is the OOTB template name along with config id(optional) or the cusotm name you have given. Say if you want the feature to be associated with all the site templates(different config id's) that are defined under a single template name then just name would be enough with no id.To apply the feature to entite site templates in the farm/sharepoint set TemplateName = Global#0