ThemeShaper Forums » Thematic

[closed]

Adding more Javascripts

(15 posts)
  • Started 11 years ago by mmeisner
  • Latest reply from emilie
  • This topic is resolved
  1. mmeisner
    Member

    Hi,

    I've been using Thematic for a while now and love it. However, with the recent release I am having trouble loading .js files.

    In the past I'd simply insert them into the wp_head() and they worked flawlessly. Not so anymore. I thought I'd open up "scripts.php" in the Extensions folder and try adding them there. Followed the same syntax, but no luck. Is scripts.php meant to only control the supplied scripts? I imagine we should be able to put the calls there...
    I've tried:

    <script src="<?php bloginfo('template_directory'); ?>/js/coda-slider.js" type="text/javascript" charset="utf-8"></script>

    <?php wp_enqueue_script('submenu', get_bloginfo('template_url') . '/js/submenu.js' ?>

    ..and adding just the script name in Scripts.php like so:
    $scripts .= $scriptdir_start . 'coda-slider.js' . $scriptdir_end . "\n";

    I'm at a loss and really need this to work. I'm sure I'm missing something easy...

    Posted 11 years ago #
  2. Hey,

    don't know if I got it right.

    I reproduced your first example using the following code in my child theme's functions.php:

    function childtheme_scripts() {?>
    	<?php echo "\n\t" ?><script type="text/javascript" charset="utf-8" src="<?php bloginfo('template_directory'); ?>/js/coda-slider.js"></script><?php echo "\n" ?>
    <?php }
    add_action('wp_head', 'childtheme_scripts');

    This code snippet will insert the script line but it won't work with a child theme 'cause 'template_directory' will create http://www.yourdomain.com/wp-content/themes/thematic/ instead of http://www.yourdomain.com/wp-content/themes/yourchildtheme/. To get the right URL at any time you need to use bloginfo('stylesheet_directory').

    Anyway without any further details I don't know if this was your problem or not.

    Cheers,

    Chris

    Posted 11 years ago #
  3. mmeisner
    Member

    Thanks for your great support on this forum Chris.

    I understand what you're saying, and how it works/doesn't work in a child theme context. I'm simply editing the main files. Though I probably should create a child theme...

    In any case, I can see the scripts are called in the source so I'm not sure what the problem is but thanks for your help and I'll report back with any news.

    Posted 11 years ago #
  4. mmeisner
    Member

    Thanks for your great support on this forum Chris.

    I understand what you're saying, and how it works/doesn't work in a child theme context. I'm simply editing the main files. Though I probably should create a child theme...

    In any case, I can see the scripts are called in the source so I'm not sure what the problem is but thanks for your help and I'll report back with any news.

    Posted 11 years ago #
  5. Could you please drop a link to your blog?!

    Cheers,

    Chris

    Posted 11 years ago #
  6. mmeisner
    Member

    Hi Chris,

    I can't link it because it's being locally developed.

    However, I'm pretty sure the problem has to do with the jQuery; Firebug tells me there's an error and reports that "$ is not a function" so I'm inclined to think it's a conflict with another script. That's still strange though, as I haven't loaded Prototype or anything else. It comes bundled with jQuery...

    The basic question I had was, instead of insterting scripts into the header, like I normally do, should I be referencing them from another file within Thematic.

    Posted 11 years ago #
  7. That error has nothing to do with from where you load your scripts .. a couple of things for you to check:

    Open your browser
    open you local blog
    open your browser's source view
    search for each single script / library
    copy the script / library address into a new browser window and see if it loads

    If you get a 404 the address for this script / library either the address is wrong or you're missing a file. Fix it and see what happens.

    If every script / library loads .. the error could be caused by using different libraries / frameworks. For example using jQuery and MooTools won't work without further magic :-)

    Cheers,

    Chris

    Posted 11 years ago #
  8. mmeisner
    Member

    Chris,

    I uploaded the local test version Live. If you want you can view it here:
    http://mikemeisner.com/sandbox/

    I did what you said, and all the .js loads in a new window. Also, I don't get a conflict with the "$" anymore. What I'm trying to do is build the featured slider a la http://www.gomediazine.com/tutorials/design-elegant-featured-content-slider-wordpress/ which, as you can see, is not working quite yet. I am not sure why; the .js does load, so that's not an issue anymore.

    If you have a moment would you mind taking a look and letting me know your thoughts? I'm itching to finish the design but I always get hung up on things like this.

    One more question. Do you think it's prudent to move the CSS and Images to a Child Theme? I susptect I know the answer.

    Thanks

    Posted 11 years ago #
  9. As you said, you know my answer! :-)

    Posted 11 years ago #
  10. Ok .. need some time to run through the whole thing and create a proper how-to for this.

    Posted 11 years ago #
  11. Hey Mike, you have problems with jQuery! Firebug returns an error like "$ is not a function"... maybe you have to change the content of the file to make it running in NoConflict mode...

    Posted 11 years ago #
  12. mmeisner
    Member

    Thanks Chris ;)

    Dannydamnboy - I actually tried running the noConflict function and changing the $ to jQuery but nothing. Plus, I don't have any prototype or moo stuff in there. Just the good ol' scripts that come packaged, and the ones above that I added.

    For now, I'm off to start it in a child theme. I'll return once I find an answer as to why the .js was not working.

    Posted 11 years ago #
  13. mmeisner
    Member

    Well, I built a child theme, and deactivated the included .js in the scripts folder. Then I simply called the scripts I wanted in the head; also ended up changing all the "$" in the coda-slider-condensed.js file to "jQuery" which seemed to get rid of that stupid error.

    And the final oversight ended up being careless one. I did not update some of the custom fields that were tied into the navigation, so now it actually has items to scroll to. I think before it only had one scroll item in the nav, and thus, nowhere else to scroll.

    Phew. I'll hope to have a cool child theme to spread around shortly.

    Posted 11 years ago #
  14. Good to hear, that this is working ..

    I decided not to use this tutorial to write an own one .. there're to many bugs, errors and so on to fix.

    Posted 11 years ago #
  15. emilie
    Member

    hello,

    i have a problem that i already solved but it seems that suddenly it appears again.
    I have an error that said '$ is not a function', whereas i m in jquery no conlict mode, i have updated the plugins which needed to but it still eosn't work, the coda-slider i m using to show the thumbnails in one line is not working, and i don't have anymore ideas to fix it.

    Your help will be very nice.
    Here a link to the website : http://www.fellah-hotel.com
    Thank you,

    emilie

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.