How To Create Own Custom Block Template In Cs Cart

[size=4]

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.[/size][size=4]

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.[/size][size=4]

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.[/size][size=4]

All type of suggestions will be appreciated. Thanks in Advance.[/size]

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

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

The simplest way is to create 2 files:

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

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

Then create a new block, select the [b]Template [/b]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

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

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 :-/

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.com/4.0.x/addons/tutorials/hello_world.htmland here http://docs.cs-cart.com/4.0.x/addons/tutorials/advanced.html

Fotis

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).

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

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

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}

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;
}

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.com/a/img922/3959/JWt36V.png

And how I want to look. - http://imageshack.com/a/img922/3769/w6j5Uk.png

Does anyone know how to do it?

Thank you!

Untitled.png

Untitled1.png

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?

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

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