php functioning / dynamically add categories and templates