In this article we will show how you can easily create a clickable code snippet in a dashboard. Our snippet will display a number of customers in Customers table and clicking anywhere in snippet area will take us to the Customers table in question.
PHP
$header = "Number of customers";$number = DB::DBLookup("select count(*) from customers");echo "Customers in the database: ".$number;
C#
dynamic number = null;header = new XVar("Number of customers");number = XVar.Clone(DB.DBLookup(new XVar("select count(*) from customers")));MVCFunctions.Echo(MVCFunctions.Concat("Customers in the database: ", number));
2. Build and run your application. Proceed to the dashboard page, right click on that snippet and choose ‘Inspect’. What we are looking for an ID of the DIV that encloses our code snippet. In our case it will be dashelement_cloudflare_snippet1.
$( "#dashelement\_cloudflare\_snippet1" ).bind( "click", function() { location.href = Runner.pages.getUrl("customers","list");});
This is it. Enjoy!