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.

THEMES: What do you do with your page_end.php file?

edited October 2007 in Vanilla 1.0 Help
I'm writing a little cache extension for Vanilla. In the default "vanilla" theme, page_end.php does nothing more than adding "</body></html>" to the html code. So I decided to not cache this basic part, and when I have a cache hit, I just add "manually" this page end "</body></html>". Now if people here tell me that they put interesting things in this file, I'll change my mind. So you "themes guys", do you have heavy modifications to your page_end.php files?

Comments

  • yep, but the other way!
    I have an empty page_end.php, because vanilla output is wrapped in my own, object based, template system (close to the HoP library I recently released).
    So if you force add global closing tags it would brake my markup (if ever you caching extension is compatible with it).

    IMO, you should not make any assertion of the theme file content because this is just the reason they are there: to put customization. I agree that you can avoid caching it but you still need to output its content, as it is.
  • edited October 2007
    Outputing its content would force me to load the framework. No way. I realize now that I just have to cache it. I totally agree with you "this is just the reason they are there", sometimes I'm not sincere with myself. I just wanted some extra motivation! You see, my problem is to insert some stuff just before </body>. The easy solution was to not store </body></html>, echo my stuff, then close the document myself. The only solution I have now is to parse the whole buffer to insert my string at the right place. Or remove the </body></html> tags, add my stuff and close the document. I'll see the php docs tonight... I only have some intermediate skills in html, but I know for sure a document will generaly end with </body></html>. What are the other possibilities? Well I could answer a bit now that I think about it: maybe there is a full xml theme already for Vanilla. mmmh, this is bad news for my "closing document problem"...
  • @grahack: I read in another thread that you need to include a custom string. Extensions are allowed to require a custom theme so you can add you string in this very page_end.php. Customized themes would have to keep it, but that's easy.
    Or am I missing the point?
  • edited October 2007
    Yes, sorry but yes !!!
    I must include a string whatever the theme is (before the closing of the document), and in two very different situations.
    My first solution was to echo it before PageEnd, and then let PageEnd close the document.
    But I think that at the end, I'll let PageEnd do its job (allowing me to cache its output), then torture the buffer for my string insertion before the document closing.

    What I need is to know what kind of document closing I will meet. , \n...
    And how to insert my string before it with no resource waste.
    I just discovered substr_replace, is it quicker than str_replace? substr_replace is not what I want.
  • I was suggesting that your extension REQUIRES that any theme using it should add the needed string (or php bit) in this file.
    Parsing the buffer for closing tag is not, IMO, the way to go. You'll have to account for HTML4 theme XHTML theme or whatever.
  • I'm now using it to grab the output buffer, and re-write it before echoing again. It's a global search and replace tool to allow an installation of Vanilla to work on multiple domains.
  • I tested replacements, it's quite an heavy task to me (I'm not caching files to spend extra resources right after!!!).
    Something like
    $output = str_replace( '</body>', $OptionalContent.'</body>', $buffer ); should do the trick most of the time.
  • DavidKDavidK New
    edited October 2007
    Actually, I've stopped using it and have followed your code example to create this: http://lussumo.com/addons/index.php?PostBackAction=AddOn&AddOnID=328 Dead useful as now I have gzip output too.
This discussion has been closed.