Problems, need help? Have a tip or advice? Post it here.
2 posts Page 1 of 1
Hi Couchers!

This is not really Couch specific, but since it's so many talented coders and smart people here I'd figure I just ask and try the luck :)

I'm currently building a one pager website with Couch on which I want one big nice graph chart that displays the current gold price in $USD (and other currencies too eventually). I want it to show for example one weeks price history per default, but that you can select for example 24h, 1 week, 1 month, 6 months, 1 year etc.

I know I could just use some iframe solution using a generated chart from another site etc, but that's not really what I'm after. I want to use one of the kick-ass open source librarys such as http://www.chartjs.org/ or https://plot.ly/javascript/ which looks awesome!

But now to the problem, how can I connect a data source that fetches the latest price and price history? I know little to none about how json and stuff work.. lol


Sorry if this is off-topic!

I wish everyone a terrific weekend!
Hi,

To make JSON do something like:


Code: Select all
<?php require_once( 'couch/cms.php' ); 


[
   <cms:pages masterpage='masterpage.php' >
      {
      "price1":"<cms:addslashes><cms:show field price1/></cms:addslashes>",
      "price2":"<cms:addslashes><cms:show field price2/></cms:addslashes>",
      "price3":"<cms:addslashes><cms:show field price3/></cms:addslashes>"
      }<cms:if "<cms:not k_paginated_bottom/>">,</cms:if>
     
    </cms:pages>
]


<?php COUCH::invoke();?>


This will pull 3 prices from your template in a JSON format

Save the file as your-json.php and point the chart script to this file as the JSON source.
I load frameworks and write bugs on top of them, after that I rearrange the code so that it looks like a cool product.
2 posts Page 1 of 1