Simple Custom Add-on TPLs do not work

I searched the forum for help but couldn’t find anything that way. Forgive me if I’m just asking a dumb question. It seems obvious to me I must be missing something. I’m new to CS Cart and trying to develop for a client.

I tried to create a very simple add-on using a TPL hook. It’s just a DIV with some text in it. The add-on shows up in admin and can be installed and activated, but the template add-on stuff just does not appear.

Some of the documentation was a little baffling to me. For example, there are contradictory instructions about where the add-on TPL file goes (whether under var or not). The documentation also says that the tpl filename root must be the name of the hook, but in one of the tutorial examples they show the filename root as the hook category, not the hook name (‘index’ in this case).

I went through the ‘advanced_addon’ tutorial verbatim just to see if I was screwing something up in my simpler attempt, but this also just did not work.

At this point I’m baffled and not finding any definitive answers.

Can anyone at least point me in the right direction? I’m especially surprised the tutorial doesn’t work.

Hi!

This tutorial is currently broken and doesn’t work. I really hope it will be updated soon.

Could you please let me know what you are trying to achieve and what has already been done so I can give you some advice?

Hi. If you are working with templates, check that the file path is correct. Especially if you work with TPL hooks. And if there is no hook, you need to override the template. Roughly speaking, copy and remake. Another sign that the template is not editable may be because it was overridden somewhere. Then you will have to search through the files.

Thanks for the response! I was just trying to show something on a TPL hook inside a product detail template. A marketing person kindly happened to give me a link to an online course for CS Cart development, and the information in there was much more clear. What I wasn’t getting from the official documentation was that the TPL hook category is a subdirectory I needed to create inside my add-on template file structure, and under that, the filename is based on the hook name.

In other words, for a TPL hook like this…
{hook name=“product:main_info_title”}

The add-on TPL file would need to be under a directory named “product,” and the filename is then, for example, main_info_title.pre.tpl (for something added before the hook, hence pre).

All the documentation says is that the file should be named for the hook name, but doesn’t specify the hook category directory must enclose that file.

1 Like

Thank you for your answer!

Yes, current documentation for the developers require some grooming. Something similar is described in the following article:
https://docs.cs-cart.com/latest/developer_guide/addons/hooking/tpl_hooks.html

However it is not that detailed as your message :slight_smile:

1 Like