Jump to content

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

How To Create Own Custom Block Template In Cs Cart Rate Topic   - - - - -

 
  • Sumit
  • Newbie
  • Trial users
  • Join Date: 04-Mar 15
  • 3 posts

Posted 27 March 2015 - 08:14 PM #1


I am new to cs cart so I need cs cart community's help. I need to understand how cs cart existing blocks (eg: product showcase block) are working and need to create custom cs cart reusable block.

Points which are not clear : 1.) what controller or PHP code we'll create. 2.) Controller or PHP code will call to which tpl.Simply how to pass php data to block tpl. 3.) At minimum How many files do we need and what will be there location.

So to sum up I need to develop a custom reusable cs cart block in which I can create logic in php code and design in tpl.

All type of suggestions will be appreciated. Thanks in Advance.


 

Posted 30 March 2015 - 07:38 AM #2

what do you want to put in this block? grouped content like products, categories or something unique?

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

Posted 30 March 2015 - 09:11 AM #3

The simplest way is to create 2 files:

1. design/themes/YOUR_THEME/templates/addons/my_changes/blocks/static_templates/my_template.tpl file with the following content:

{$data = $param1|fn_get_my_custom_data:$param2}

2. app/addons/my_changes/func.php file which will contain the fn_get_my_custom_data function

Then create a new block, select the Template block type and find your custom template there
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    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 

Posted 26 August 2016 - 01:47 PM #4

The simplest way is to create 2 files:

1. design/themes/YOUR_THEME/templates/addons/my_changes/blocks/static_templates/my_template.tpl file with the following content:
 

{$data = $param1|fn_get_my_custom_data:$param2}
2. app/addons/my_changes/func.php file which will contain the fn_get_my_custom_data function

Then create a new block, select the Template block type and find your custom template there

 

 

Hi, just tried this:

created the 2 files:

/design/themes/MYTHEME/templates/addons/my_ingredients/blocks/static_templates/my_ingredients.tpl

/app/addons/my_ingredients/func.php

 

content for the tpl: {$data = $param1|fn_get_my_custom_data:$param2}

content for the php: fn_get_my_custom_data{   echo "Hello World"; }

 

When I now try to create a new block with type Template, my custom template is not there :-/

What am I missing?

 

Thx



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

Posted 26 August 2016 - 02:13 PM #5

All available templates are cached. Just clear cache and make sure that the My ingredients module is activated 


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    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 

Posted 26 August 2016 - 02:30 PM #6

All available templates are cached. Just clear cache and make sure that the My ingredients module is activated 

 

Sorry for asking: where do I activate the module? Thought by creating the files it will be automatically available :-/



 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1451 posts

Posted 26 August 2016 - 03:31 PM #7

You need to have an addon.xml  in /app/addons/my_ingredients/ so that you an install this properly

 

Please follow the guide here http://docs.cs-cart....ello_world.htmland here http://docs.cs-cart....s/advanced.html

Fotis


Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

 

Posted 26 August 2016 - 03:33 PM #8

OK - let's ask this way:

I want to create a new tab for the product details page, so I thought I make my own Block content - see above.

Is there another way to create a custom tab where I pull some information from the database about the product? I want to look up the information by the product code (SKU Number).



 
  • dvsgr
  • Senior Member
  • Authorized Reseller
  • Join Date: 14-Apr 09
  • 1451 posts

Posted 26 August 2016 - 03:38 PM #9

OK - let's ask this way:

I want to create a new tab for the product details page, so I thought I make my own Block content - see above.

Is there another way to create a custom tab where I pull some information from the database about the product? I want to look up the information by the product code (SKU Number).

 

I would go by researching the features tab. ITs lamost waht you want to create


Fotis Kourmadas
Cs-Cart Development - Cs-Cart Authorized Reseller 

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

Posted 29 August 2016 - 07:18 AM #10

Sorry for asking: where do I activate the module? Thought by creating the files it will be automatically available :-/

 

Enable module on the Add-ons -> Manage add-ons page and delete the var/cache directory to clear the whole cache


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    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • abugasiem
  • Newbie
  • Trial users
  • Join Date: 23-Mar 17
  • 6 posts

Posted 09 April 2017 - 06:29 AM #11

Thanks it's working. Can someone explain the syntax of calling the function from smart template : 
 

{$data = $param1|fn_get_my_custom_data:$param2}

{$data = $param1|fn_get_my_custom_data:$param2}



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

Posted 10 April 2017 - 07:21 AM #12

Thanks it's working. Can someone explain the syntax of calling the function from smart template : 
 

{$data = $param1|fn_get_my_custom_data:$param2}

{$data = $param1|fn_get_my_custom_data:$param2}

 

 

It is similar to the following php code

$data = fn_get_my_custom_data($param1, $param2);

where function is


function fn_get_my_custom_data($param1, $param2)
{
    .. some actions here ...
    return $data;
}

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    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • bibicel
  • Newbie
  • Trial users
  • Join Date: 10-May 17
  • 7 posts

Posted 10 May 2017 - 08:26 AM #13

Hello,

I have a problem with my website. I would like to change the appearance of the product page but I can not figure out how to do it. To understand better, I've attached you pictures. 

The first is how it looks now - http://imageshack.co...3959/JWt36V.png

And how I want to look. - http://imageshack.co...3769/w6j5Uk.png

 

Does anyone know how to do it?

Thank you! 

 

 

Attached Thumbnails

  • Untitled.png
  • Untitled1.png


 
  • kyo00710
  • Newbie
  • Trial users
  • Join Date: 25-Dec 19
  • 12 posts

Posted 06 January 2020 - 01:52 AM #14

Hi,

 

Instead of creating block from custom Template, I want to create a block like in banner or blog addon, which block created can configure some setting for each block. I did research but still don't have a correct and clearly tutorial for this. How can I do this?



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

Posted 06 January 2020 - 06:00 AM #15

Use banners addon as example

 

app/addons/banners/schemas/block_manager/blocks.post.php

 

The main key is banners here. So the system will get fn_get_banners function to get data for these block.

 

Settings can be specified in the templates element


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    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 
  • kyo00710
  • Newbie
  • Trial users
  • Join Date: 25-Dec 19
  • 12 posts

Posted 07 January 2020 - 01:13 AM #16

@photo-22131.png?_r=1500465070, thanks a lot