Menu icon Foundation
Get data from csv via json into Panini

Hello,

after a long time i started a web project and found the extremly cool foundation framework and panini. I like the approch and i could solve all my problems until now. I reworked the hompage of our company wich relyed heavily on php. On the hompage we have a lot of tables where the prices where loaded everytime the page was called by a php function from a mySQL databse. As the prices change only once a year i want to shift the generation of the tables to panini. Therfore i have to inject the prices wich i get as .csv tables out of our acess database into panini. I ask more for a general idea as there might be different ways.

For now i am thinking of converting the csv table wich looks like this

product   | price 1 | price 2 | price 3

productA | 10USD | 5USD   | 3USD

... 

to json (with this tool) and then get the different prices of the different products with a custom helper out of the json into the table wich alredy exists as a html table skeleton in panini. So a table entry would look like (pseudo code)

getPrice(productA,pice1)

and then prints 10USD.

This is just an idea that i would like to implement maybe there are other ways. Is there someone who has an idea on this issue. I kow that one can get data into panini with the #each helper but i did not figure out if i could do what i want to do with these already existing helpers.

Thanks four your time Jakob

csvpaniniJSONDatabase

Hello,

after a long time i started a web project and found the extremly cool foundation framework and panini. I like the approch and i could solve all my problems until now. I reworked the hompage of our company wich relyed heavily on php. On the hompage we have a lot of tables where the prices where loaded everytime the page was called by a php function from a mySQL databse. As the prices change only once a year i want to shift the generation of the tables to panini. Therfore i have to inject the prices wich i get as .csv tables out of our acess database into panini. I ask more for a general idea as there might be different ways.

For now i am thinking of converting the csv table wich looks like this

product   | price 1 | price 2 | price 3

productA | 10USD | 5USD   | 3USD

... 

to json (with this tool) and then get the different prices of the different products with a custom helper out of the json into the table wich alredy exists as a html table skeleton in panini. So a table entry would look like (pseudo code)

getPrice(productA,pice1)

and then prints 10USD.

This is just an idea that i would like to implement maybe there are other ways. Is there someone who has an idea on this issue. I kow that one can get data into panini with the #each helper but i did not figure out if i could do what i want to do with these already existing helpers.

Thanks four your time Jakob

Rafi Benkual 4 months ago

That should work. I was going to suggest a JSON API but it seems you have that. So wrapping the table in an @each helper with the variables defined in the table cells sounds right  to me.

Jakob Silbermann 4 months ago

Hello rafi,


Thank you for your answer but can you explain shortly what the difference between #each and @each is ? I tried to find out about this by myself and google but i just found several post which I do not understand*. So I think it might be something fundamental between # and @. Sorry I am on the level one is after watching all of the various you tube introduction videos of you and your colleagues. I really enjoyed them they are very good and it is fun to watch them.

Jakob

* http://foundation.zurb.com/forum/posts/16411-sass-variables-not-working-in-media-queries

Rafi Benkual 4 months ago

Thanks for the kudos!

@each is a function of Sass syntax

{{#each global.nav_items}} for example is a Handlebars syntax for your HTML to iterate through sets of data and print them out. 

You can see an example of it used in Panini here: 

http://zurb.com/university/lessons/steering-you-right-with-panini-s-handlebars-helpers-and-data-ee441dba-f8e5-449b-bbfb-5fb65d655f81

Jakob Silbermann 4 months ago

Hello Rafi,

thank you for the explanation and link. I will work on it and come back if further questions pop up.

Bye Jakob