Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Smarty Block: How To Query Database On Websites Start Page Rate Topic   - - - - -

 
  • hummer
  • Advanced Member
  • Members
  • Join Date: 23-Jul 20
  • 86 posts

Posted 23 September 2021 - 08:49 AM #1

Dear all!
 
On the home page of the website there is a "Counter" section that displays interesting figures.
 
counter.PNG
 
Currently these numbers are hard coded in HTML (Website > Pages).
 
However, I would like to make them dynamic, i.e. populate the counters from the database. For this purpose there is a table "cscart_my_counter_table" (which would be updated by a CRON job every 10 minutes).
 
Is there a way to query this table? Can this be done with a Smarty Block for example?
 
I am looking forward to your support!
 
Best regards
hummer


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 22247 posts

Posted 23 September 2021 - 01:25 PM #2

Yes, you can use the following code in your template

{$data = "SELECT * FROM ?:my_counter_table"|db_get_array}
{$data|fn_print_r}

second line will output the result


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • hummer
  • Advanced Member
  • Members
  • Join Date: 23-Jul 20
  • 86 posts

Posted 24 September 2021 - 01:25 PM #3

Thank you, eComLabs! Smarty syntax is a bit strange, but it works. :-)