Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Theme Related Questions

XarcellXarcell North Carolina
edited July 2012 in Vanilla 2.0 - 2.8

When I add javascript(jQuery) to the "default.master.tpl" file I get a bonk error. Is it improper in vanilla themeing to add javascript to that file? What would you suggest?

Anyone know what the code is that the "new Discussion" button? I added a "+" that is fixed to the bottom of the page now I just need to link it.

Comments

  • Options
    KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    I myself always add JS through through the default.master.tpl file. You can add it through theme hooks aswel though. Could you perhaps post the error you get when adding JS through said file?

    The New Discussion button is simply a link that in most cases has an href attribute like this: href="/post/discussion". I say "in most cases" as it varies depending on the structure of your installation.

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • Options
    peregrineperegrine MVP
    edited July 2012

    Yes - you can add js via default.master.tpl

    my suggestion is to look for what to do when you get a bonk message. e.g. how to add debugging to determine error.

    then you will probably need to set the correct permissions on the cache folder, etc. that shows up as the error in your debug info.

    http://vanillaforums.org/discussion/20604/todd-suggestion-for-bonk-page-replacement

    http://www.google.com/search?q=site:vanillaforums.org+smarty+cache

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    XarcellXarcell North Carolina

    the error is:

    Bonk

    Something funky happened. Please bear with us while we iron out the kinks.

        <script type="text/javascript">
        $(function() {
    
            // grab the initial top offset of the navigation 
            var sticky_navigation_offset_top = $('#sticky_navigation').offset().top;
    
            // our function that decides weather the navigation bar should have "fixed" css position or not.
            var sticky_navigation = function(){
                var scroll_top = $(window).scrollTop(); // our current vertical position from the top
    
                // if we've scrolled more than the navigation, change its position to fixed to stick to top, otherwise change it back to relative
                if (scroll_top > sticky_navigation_offset_top) { 
                    $('#sticky_navigation').css({ 'position': 'fixed', 'top':0, 'left':0 });
                } else {
                    $('#sticky_navigation').css({ 'position': 'relative' }); 
                }   
            };
    
            // run our function on load
            sticky_navigation();
    
            // and run it again every time you scroll
            $(window).scroll(function() {
                 sticky_navigation();
            });
    
            // NOT required:
            // for this demo disable all links that point to "#"
            $('a[href="#"]').click(function(event){ 
                event.preventDefault(); 
            });
    
        });
        </script>
    

    Any ideas?

  • Options
    XarcellXarcell North Carolina
    edited July 2012

    I don't see an error log for vanilla. Am I missing something?

  • Options
    XarcellXarcell North Carolina

    kasperisager said:

    The New Discussion button is simply a link that in most cases has an href attribute like this: href="/post/discussion". I say "in most cases" as it varies depending on the structure of your installation.

    Right, but if a person is within a category, it doesn't add the category to the URL. What is the php version of the link if you have it?

  • Options
    peregrineperegrine MVP
    edited July 2012

    Xarcell said:
    I don't see an error log for vanilla. Am I missing something?

    Yes
    - read my reply again on what to do if you get a bonk.

    If you didn't understand that message read this one and click the links within.

    http://vanillaforums.org/discussion/comment/164031/#Comment_164031

    :)

    http://vanillawiki.homebrewforums.net/index.php/Bonk_Errors

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    XarcellXarcell North Carolina

    I added this to my configuration file, explained via vanilla.wiki, and uploaded.

    $Configuration['Garden']['Errors']['MasterView'] = 'deverror.master.php';

    Nothing has changed, I still see the user-friendly error(bonk).

  • Options
    peregrineperegrine MVP
    edited July 2012

    which file did you add it to, the more specific you are the faster you are going to resolve it.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    XarcellXarcell North Carolina

    peregrine said:
    which file did you add it to, the more specific you are the faster you are going to resolve it.

    conf/config.php

  • Options
    peregrineperegrine MVP
    edited July 2012

    try adding both of these

    $Configuration['Garden']['Errors']['MasterView'] = 'deverror.master.php';
    $Configuration['Garden']['Debug'] = TRUE;
    

    reload your pages.
    erase all of the ini files in
    vanilla/cache

    what server is the server os?

    change permissions so

    cache/Smarty/compile is 777

    if you get no bonk it is advisable to remove the diagnostic configs below from your config.php.

    $Configuration['Garden']['Errors']['MasterView'] = 'deverror.master.php';
    $Configuration['Garden']['Debug'] = TRUE;

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    XarcellXarcell North Carolina

    peregrine said:
    try adding both of these

    $Configuration['Garden']['Errors']['MasterView'] = 'deverror.master.php';
    $Configuration['Garden']['Debug'] = TRUE;
    

    reload your pages.
    erase all of the ini files in
    vanilla/cache

    what server is the server os?

    change permissions so

    cache/Smarty/compile is 777

    if you get no bonk it is advisable to remove the diagnostic configs below from your config.php.

    $Configuration['Garden']['Errors']['MasterView'] = 'deverror.master.php';
    $Configuration['Garden']['Debug'] = TRUE;

    By erase you mean delete?

    Server Information: http://www.xarchology.com/phpinfo.php

    I did as you suggested and I see no change. I even hard refreshed, cleared browing data, and even tried another browser. All the same...

    On my server stats, it says 'Apache 2.2", but I think it's using nginx, with a reverse proxy which shows Apache.

    My cache directory permissions were already set to 777(but i checked again anyway), because I was getting bonk error after installing themes. Changing those permissions from 755 to 777 fixed that.

  • Options
    peregrineperegrine MVP
    edited July 2012

    copy this to your vanilla directory and name it configdisplayer.php

    <?php
        $filename = "conf/config-defaults.php";
        $fp = fopen($filename, "r");
        if($fp)
        {
        while(!feof($fp))
        {
        $line = fgets($fp);
        if ((!preg_match('/Database/',$line))&&(!preg_match('/Authenticator/',$line)) &&(!preg_match('/mail/',$line)) &&(!preg_match('/Smtp/',$line)) &&(!preg_match('/Captcha/',$line)) &&(!preg_match('/Salt/',$line)) && (!preg_match('/SupportName/',$line)) && (!preg_match('/Last edited/',$line)))
        {
        echo "$line<br />";
        }
        }
        }
        ?>
    

    and post the results

    also you might want to go back to default theme.

    $Configuration['Garden']['Theme'] = 'default';

    you should probably get into to the dashboard.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    XarcellXarcell North Carolina
    edited July 2012

    Ok, I figured out the problem. I put a error.master.php file in the theme directory and forgot to remove it. So, I have removed that file and uploaded the config file with this code added:

    $Configuration['Garden']['Errors']['MasterView'] = 'deverror.master.php';
    $Configuration['Garden']['Debug'] = TRUE;
    

    Anyway, I see the error now, but I don't understand why it would be giving me an error:

    Smarty error: [in /home/xarcell/public_html/xarchology.com/themes/Sky/views/default.master.tpl line 7]: syntax error: unrecognized tag 'var' (Smarty_Compiler.class.php, line 590)

    Why does it say the javascript variable is an unrecognized tag? perhaps I would be better off linking to a js file, instead of embedding the code

  • Options
    peregrineperegrine MVP
    edited July 2012

    Yes.
    I would do something like this in the tpl

    <script type="text/javascript" src="/vanilla/themes/Sky/js/helpme.js"></script>
    
    
    I would use this for page loads
    
    jQuery(document).ready(function($) {
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    422422 Developer MVP

    @Xarcell you may be suffering from cumulative error syndrome.

    There was an error rendering this rich post.

  • Options
    peregrineperegrine MVP
    edited July 2012

    Lol - been there, done that.

    It hits all of us eventually. some of us at an earlier age than other depending on your lifestyle.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Options
    422422 Developer MVP

    Me too ... been working on a new site for 3 days, and yesterday added sh*t loads of functionality. Only to realise the version i deleted page_old.php was in fact cached and I deleted page_new.php > all my work gorn ! Argghh .

    Backtracking sorted it out, but so blinking frustrating. Esp. when i usually am so vigilant.

    There was an error rendering this rich post.

  • Options
    XarcellXarcell North Carolina

    The issue has been resolved. Thanks @peregrine

  • Options
    KasperKasper Scholar of the Bits Copenhagen Vanilla Staff
    edited July 2012

    ...and if you want to add JS directly in the .tpl master view, you'll need to use the {literal} tag like this:

    {literal}
        <script type="text/javascript">
            ...
        </script>
    {/literal}
    

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • Options

    nice

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.