Coding problem - console error

  • Started
  • Last post
  • 7 Responses
  • Hombre_Lobo

    Heeeey QBN!

    Im working on site that I'm very unfamiliar with, its for a client and they just asked me to take a look, its not a site I built or anything so its a bit of stab in the dark. Its built in Silverstripe CMS.

    They have a search box on one page (where it works fine, no errors) and they want it on another, I found the chunk of code which is simple enough -

    <div class="searchForm">
    $SearchForm
    </div>

    I thought perhaps a simple copy paste would work, pasting it onto the other page they want it on, but no luck.

    I'm getting the following console errors -

    Uncaught TypeError: Cannot read property 'SelectorsAPI' of undefined
    Enumerable.each - prototype.js:345
    breakoutCarousel - main.js:19
    (anonymous function) - main.js:231
    responder - prototype.js:4459
    fire - prototype.js:4620
    _methodized - prototype.js:339
    fireContentLoadedEvent - prototype.js:4668

    Does anyone have any idea what that means?
    I dont know why this would work on one page and not another.

    I do mostly front end dev, with the odd bit of back end stuff, so i haven't gotten this error before :(

    Hope you can help! :D

  • dibec0

    Boy what a mess. You need more code buddy.

    You have created a div with a class called searchForm, and inside that div you are displaying $SearchForm.

    Not gonna work.

    You need something like this ...

    <form>
    First name: <input type="text" name="firstname" /><br />
    Last name: <input type="text" name="lastname" />
    </form>

    You also need to have some script associated with the form field to tell it to write to a database.

    More info here on the HTML side: http://www.w3schools.com/html/ht…

    • I would have thought the search form is being pulled in from elsewhere, as it works on the other page :OHombre_Lobo
  • dibec0

    I start at $175 for development costs. =P

  • vaxorcist0

    It's this Silverstripe CMS?
    http://en.wikipedia.org/wiki/Sil…

    Check at the top of the PHP source code for that page that works, there is some large bit of code that's different from your page that doesn't work.... try comparing the two very carefully.... make a test page with the one that works and keep removing stuff till it doesn't work.... then go back one step and try combining the top of this page with your new page....

    good luck, this can be fun, and yes you probably need a developer....

    <div class="searchForm">
    $SearchForm
    </div>

    is depending on lots of other stuff setup first...

    • Thanks dude!
      Yeh ive looked at the both carefully, expecting to be missing some js, but
      Hombre_Lobo
  • mikotondria30

    There's quite an active dev community at SilverStripe isn't there ?
    I tried it out on a client's site once, and it had quite a hefty learning curve...
    More generically, yes ^.. that $SearchForm is calling a function that lives within a .js file that's being included in the various bits of code that make up your page. If you have TextPad or similar, search for SearchForm in all files, then try to trace how that file or function is being called in the page make up. It might take some time, but it's really the only way to get a handle of the guts of how these CMSs work.. They tend to separate the logic of the page make up from the layout.. The only way to debug is logically, changing one thing at a time. Sorry I can't help more : /

  • dibec0

    boy i missed the boat ...

  • Hombre_Lobo0

    Thanks everyone! Really appreciate the help! :D

    Still not got it working, i expected some missing javascript or something but after matching both pages and making sure all includes and js were the same, still no luck.

    Thanks miko! good point Ill head over to those boards!

  • vaxorcist0

    This sort of thing is either pretty easy or rather hard..... pretty easy once you understand the mindset of the CMS, but often rather hard until you wrap your head around the CMS's way of thinking....

    Also note that some CMS's make most things easier than just coding plain old PHP/mySQL, but sometimes they make certain things even harder than plain-old hand-coded PHP/mySQL because you have to make your code work with all sorts of dependent other stuff....

    so, yes, it's a learning curve thing, and if you find somebody who really knows silverstripe CMS, it may take them 30 seconds, but that's because they know the inner workings of this CMS... it may take you a few weeks to get the inner workings of SIlverstripe, or any similar MVC CMS....

    NOTE: If they're using MVC, or Model View Controller, you may have to modify 3 different files to change something, and you may MESS UP other stuff that depends on the Model or Controller you changed.... so, I'd clone the setup before you start messing around a whole lot....

    Yes, it seems insane at first, but after a while it makes sense...the Model View Controller idea makes some things much easier than coding from scratch, but only if you're doing stuff that the original coders had planned for, if you're doing something completely different, it's like trying to make a submarine fly at 30,000 feet...

    Good luck! Keep the client expectations rational, it really helps!