I have my own Custom Controls each with their own embedded Templates and Resource files (.ascx, .css). What I need to do is that if there's a Custom Template available inside the ControlTemplates folder of the current Template in use by the page that hosts the Custom Control then have the control use that one instead of the embedded one. Also trying to achieve this for CSS files as well.
For example, using a Custom Control named Test, I would override the LayoutTemplatePath of the Control and check if the file 'App_Data/Sitefinity/WebsiteTemplates/<Current Template>/ControlTemplates/Teste.ascx' existed and if so, return it, otherwise return null, making the control use the LayoutTemplate instead of the LayoutTemplatePath which would cause him to use the embedded .ascx template file.
Is there a way on code-behind to get the current Page Template directory?
I would also need a way to include an external CSS file, if available, otherwise use the embedded one.
For example, on the InitializeControls method I could verify if the file 'App_Data/Sitefinity/WebsiteTemplates/<Current Template>/App_Themes/<Current Theme>/Styles/Test.css' and if so, then include it on the ResourceLinks present on the Custom Control, otherwise include the embedded one.
Is there a way on code-behind to obtain the current Page Theme directory?
Also, is this the correct procedure of achieving this (load external resources, css, ascx, images, if they are available, otherwise load the embedded ones) or is there a more convenient way that I'm missing?
Thanks in advance,