Jump to content

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

How To Pass Data To A Custom Template Block Rate Topic   - - - - -

 
  • Lianne-v-O
  • Advanced Member
  • Members
  • Join Date: 05-Oct 16
  • 66 posts

Posted 05 October 2016 - 03:16 PM #1

Hi,

I am making a block to use as a client-service block in the homepage. I found some information in tutorials and forum. So far so good. I want the company's phonenumber in it. I found this in the _settings_objects database table. I managed to get a query running. But I didn't get it to run with a dynamic condition. For later use, I would like it to pass dynamicly. How to do this? What am I missing?

So far I have this:
\app\addons\my_changes\func.php
function fn_get_service_data($name='company_phone')
{
//$company_data = db_get_row("SELECT * FROM ?:settings_objects WHERE name = ?s", $name);
$company_data = db_get_row("SELECT * FROM ?:settings_objects WHERE name = ?s", 'company_phone');
return $company_data;
}

And this:
\design\themes\nrp\templates\addons\my_changes\blocks\static_templates\service_box.tpl
{$data = $param1|fn_get_servi ce_data:$param2}
{$data.value}

And when do I have to use my_changes and when do I need to make a new add_on? What is the difference?



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11325 posts

Posted 05 October 2016 - 04:03 PM #2

Tygh::$app['view']->assign('variable_name', $value);

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • galtinbaeva
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 06-Dec 13
  • 3356 posts

Posted 05 October 2016 - 04:29 PM #3

And when do I have to use my_changes and when do I need to make a new add_on? What is the difference?

 

There is no difference, you can use my_changes add-on for your modification. But, in my opinion, if you have a lot of changes, it is better to create new add-ons. If you put all the changes in one add-on, you can not disable them one by one, you will have to disable them all (the whole add-on). So if you create different add-ons for every feature you would like to have, you can easily manage them.


Simtech Development | sales@simtechdev.com | www.simtechdev.com
CERTIFIED CS-CART PARTNER | LICENSES | DEVELOPMENT | ADD-ONS | DESIGN | UPGRADE

Google Analytics Enhanced Ecommerce - get advanced ecommerce analytics


 
  • Lianne-v-O
  • Advanced Member
  • Members
  • Join Date: 05-Oct 16
  • 66 posts

Posted 05 October 2016 - 05:24 PM #4

Tygh::$app['view']->assign('variable_name', $value);

 

And in which file would I put this? And before of after which part?



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11325 posts

Posted 05 October 2016 - 09:33 PM #5

Depends on which controller your block is following in. You can use an init.post.php controller.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


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

Posted 06 October 2016 - 07:07 AM #6

You can just use the following variable in your SMARTY block:

{$settings.Company.company_phone}

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 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Lianne-v-O
  • Advanced Member
  • Members
  • Join Date: 05-Oct 16
  • 66 posts

Posted 07 October 2016 - 08:37 AM #7

 

You can just use the following variable in your SMARTY block:

{$settings.Company.company_phone}

 

Just that easy! It works! Thanks!



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

Posted 07 October 2016 - 02:10 PM #8

You are welcome! :)


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 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.