Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Changing item templates? ... beyond CSS formatting

edited January 2007 in Vanilla 1.0 Help
Hi everyone, First message on the Lussumo community :) I've already explored adding my own extension which currently adds content to the Panel (ads) and loads an additional CSS File. Fun. I want to change drastically the way items are displayed (discussions page, categories page, etc). Are there template objects I can override from my own extension's default.php file? I want to be able to change the Div order, add more elements, etc. Thanks for letting me know. -mano

Comments

  • (update) I am looking around the files and found what looks like the HTML which gets instantiated for each Category item.: vanilla/themes/categories.php Now... Is it possible for me to override this object from my extension to give it something else to display? I'd rather not mess with the core Vanilla files since the extension framework is so cool...
  • (update - last spam of the day from me) I ended up messing with that file (categories.php) and got what I wanted done :) ... I am still interested to know if there is a way to override those objects from an extension php script. Thanks!
  • I'm pretty sure there isnt but I could be wrong. It would be useful to know for sure.
  • edited January 2007
    Yepp, there is a very ingenious way you can override any object (the context object is the only exception) called throughout vanilla. Its done through a class called ObjectFactory. You can read up on this in the documentation but I'll give you a quick synopsis. Basically, whenever the page wants to instantiate a new class/object/control, it calls a method in ObjectFactory (either NewContextObject, NewObject or NewControl) passing the name of the class it needs to instantiate. ObjectFactory then looks at this name and checks if the class exists, if not it searches through the /library folder for any files with the name of Vanilla.Class.[classname].php (the "Vanilla" part is changed for each of the three folders within library). Why not just do a standard "new ClassName" php call? Well, this is where the beauty of ObjectFactory comes in. It has an array of "references" which can be used to instantiate a replacement class instead of a standard Vanilla class. In your extension you can call the "SetReference" method for ObjectFactory. For instance, a line like this: $ObjectFactory->SetReference("ClassIwantToReplace","ReplacementClass"); EDIT: Before this line, you must include your class (if its not in the default.php file already). This tells ObjectFactory to instantiate ReplacementClass whenever ClassIwantToReplace is called. If you "extend" the ReplacementClass from the ClassIwantToReplace, it will inherit all of its properties/methods and then you can simply override any methods you need to. Hopefully, this all made sense. ObjectFactory really is only meant to be used for extreme scenarios where you need to change something to do with Vanilla's core. As for theme files, simply create a new - "ThemeName" - folder inside the themes folder. Copy the styles from the Vanilla folder. Then for any theme file you need to edit, copy and paste it from the themes folder, into the newly created child "ThemeName" folder. Vanilla searches for theme files in your selected theme folder first and those over ride the ones in the base "themes" folder. This way you only need to copy and paste the files you need changed. Remember to enable your theme through the Settings panel. Hope that helped, Happy New Year!
  • Woah thank you so much valentinp! That's exactly what I needed to know. Thankyouthankyouthankyou. I like the Lussumo community already.
  • Very interesting reading indeed, thanks :)
This discussion has been closed.