First, there's this article: https://vborg.vbsupport.ru/showthread.php?t=228112 . But I see you've manage to use some vb code, so maybe you either found that article already or you figured it out by looking at existing vb files.
So do I understand correctly, have you put some of your code in templates but can't get the php code to run? You can't put php code in a vb template - maybe that's the problem you're having?