0

I'm building a cryptocurrency website (don't judge) on Wix, and am creating hundreds of dynamic pages to highlight each currency. What I need also is to have a html widget from TradingView on each page showing the trading chart of each crypto. For example on the Bitcoin dynamic page, have the BTC trading chart widget, on the Ethereum page, have the ETH chart displayed etc. The widget is linked here: https://uk.tradingview.com/widget/advanced-chart/

Now, just for reference, I'm not sure if Wix builds Dynamic pages like everywhere else, as I'm new to coding (hence using a web builder), but it works with Javscript, and when a dynamic dataset is created on a Wix page it's iD is #dynamicDataset, and the html widget box iD is #html1.

The closest help on the internet I've found to this is via this link: https://www.wix.com/velo/forum/community-discussion/solution-html-iframes-connected-to-a-dataset-on-a-dynamic-page

However, after following all of the steps to a tee, I'm getting this error message when I publish the site Wix code SDK error: The url parameter that is passed to the src method cannot be set to the value . It must be of type url.

This is my code:

    $w.onReady(function () {
 >to load the page before running the code
    $w("#dynamicDataset").onReady(function () { 
    >to load the dynamic dataset's data before running the following code
        $w("#html1").scrolling = "no"; 
                 >so that scroll bars, if any, do not appear on our page. 
                         >if you want you can keep them!
        let widget = $w('#dynamicDataset').getCurrentItem().widgetURL; 
                 >we create a variable called "widget" and set its value to the URL we have  
                         >put in our data collection.
        $w("#html1").src = widget; 
                 >we set the dynamic page's HTML element's URL value to that of "widget", 
                         >which is actually the URL from our data collection.
    })
});

I would massively appreciate any help on this, and have a feeling this code is almost correct? If anyone could point me in the right direction, I'd be forever grateful. I've searched for 3 days now and no luck.

Console.log:

{"image":"wix:image://v1/da0ce5_be9fb686611249f19c63f3cb3a98ca9b~mv2.jpg/Ethereum%2 0300.jpg#originWidth=300&originHeight=300", "description": "Ethereum is a decentralized open-source blockchain system that features its own cryptocurrency, Ether. ETH works as a platform for numerous other cryptocurrencies, as well as for the execution of decentralized smart contracts.", "_id": "00000000-0000-0000-0000-000000000002", "_owner": "da0ce518-6ee8-4595-b155-afccd4b15aa0", "_createdDate": "Tue Feb 16 2021 21:30:26 GMT+0000 (Greenwich Mean Time)", "_updatedDate": "Sat Feb 20 2021 18:02:20 GMT+0000 (Greenwich Mean Time)", "smallTitle": "Ethereum (ETH)", "graph": "https://www.helpmebuybitcoin.com/ethereum-1", "title": "Ethereum", "link-cryptocurrencies-title": "/cryptocurrencies/ethereum", "link-cryptocurrencies-all": "/cryptocurrencies/" } ''''

cja
  • 47
  • 1
  • 11
  • Based on the error message, it looks like the widgetURL property of the current item is empty. Can you console.log the widget variable or maybe the whole currentItem object so we can see what the value is? – Sam Feb 24 '21 at 06:53
  • Hi @Sam I'm not sure how to do that. I've googled it but not sure if I can do that via Wix? Would screenshots of the dynamicdatabase and code help? I'm new to this so apologies for being a n00b! – cja Feb 24 '21 at 19:26
  • Before this line $w("html1").src = widget; add this line console.log($w('#dynamicDataset').getCurrentItem()); When you preview, that new line will print something out in the developer console at the bottom of the window. Copy that (make sure to expand it out all the way) and post it in your question. – Sam Feb 26 '21 at 05:25
  • I've posted it in there, but couldnt get the formatting right for code - annoying! – cja Feb 28 '21 at 20:55
  • That explains it. You don't have a field named widgetURL in the collection that your dataset connects to. So when you do this: `$w("#html1").src = widget;` you are setting the value of html component's src to `undefined`. – Sam Mar 01 '21 at 12:40

0 Answers0