Theme Modifications

I wish to modify a behaviour from products page. When clicking on vendor name, to redirect to external domain. Till now I have understood that, if the file contains {hook}{/hook}, I can modify the behaviour by adding a separate hook file (pre,post,override).

I am working on a custom theme, and the file, where I want modifications, doesn't have hooks in it. So, the modification that I expect, I have to manually code,

-> first by adding {hook}...

-> then creating a (post,pre,override) file.

Problem that I might run into is, if the theme will have upgrades in future, my custom codes/modifications will be lost.

So, my question is what is the best approach to work on modifications?

I want to follow the approach of creating a separate addon and don't modify the files that exists in the theme, and no matter for upgrades, my changes will reflect, but this way, I can't seem to find a way, how to do it.
Please suggest me

If you mean redirect from the vendor page, you can catch this request in the companies.pre.php controller in your addon

If you mean redirect from the vendor page, you can catch this request in the companies.pre.php controller in your addon

From vendor page is just an example. In fact, I have multiple places from where, I have to redirect to external domain for every vendors. I needed a better understanding of how to apply modifications in themes, because after theme upgrades, my custom changes would be lost.

Can you please share about how can I make modifications such that the changes would remain even after theme upgrade.


From vendor page is just an example. In fact, I have multiple places from where, I have to redirect to external domain for every vendors. I needed a better understanding of how to apply modifications in themes, because after theme upgrades, my custom changes would be lost.

Can you please share about how can I make modifications such that the changes would remain even after theme upgrade.

To be specific, I am working on vivashop theme.

You can find find useful information about templates here

https://docs.cs-cart.com/latest/developer_guide/addons/hooking/tpl_hooks.html

If you mean redirect from the vendor page, you can catch this request in the companies.pre.php controller in your addon

I tried to catch request from

companies.view?company_id=`$company_id`

in companies.pre.php, at mode=view.

-> but, everytime, the link redirects to "companies.products", and I have to match it's SEO name to match and open vendor link.

-> another problem i am facing is, i can't figure out a way to open the link in new tab.

currently, my code is as:

$company_id = (int) $_REQUEST['company_id'];

$company_data = !empty($company_id) ? fn_get_company_data($company_id) : [];

header("HTTP/1.1 301 Moved Permanently");

header("Location: " . $company_data['url']);

exit();

can you help me to oepn the url in new tab please.

I am not allowed to modify the existing theme, so I am trying to make changes by creating a custom addon

You should use either the my_changes addon or create a new one.

If there are no hooks in the theme file from Vivashop, you can either:

1 - ask them to add the hook so it will appear in future releases of theirs

2 - Use an override. Copy the file to the override location in your addon and edit away

can you help me to oepn the url in new tab please.

New tab can be opened with few lines of javascript in controller

You should use either the my_changes addon or create a new one.

If there are no hooks in the theme file from Vivashop, you can either:

1 - ask them to add the hook so it will appear in future releases of theirs

2 - Use an override. Copy the file to the override location in your addon and edit away

i needed only to customize a selected div and not the whole file.
is it possible if there is no hooks attatched?

i needed only to customize a selected div and not the whole file.
is it possible if there is no hooks attatched?

No. Suggest you contact the theme vendor to ask if they will add it to their standard product or you can add it yourself and then be cognizant when you upgrade the theme to a newer version. Obviously best to have the vendor adopt your requested change.