Include A Php File To .tpl


reading ways to include a php file to a .tpl file.


without hope..

eComLabs writes - to add a new file at blocks/static_templates folder, then will appear, when going to 'add a block' (clear cache + enable my

tbirnseth writes - Smarty PHP tags {php}code{/php}.

nothing worked :(

any tip?


php tags are disabled in more recent versions of cs-cart templater. Why do you want to include a php file?

It would be better practice and style to include your file from (for instance) app/addons/my_changes/func.php and then reference whatever functions you want to call via "smarty modifiers". I.e.

{assign var="my_tpl_var" value="arg1_str"|my_function:"arg2_str"}

And if you're trying to perfom some action ouside the template, just create a function and do your include and processing in there.

But remember, the templates are in the UI layer and you're calling to the Business layer. While it works, it is bad style.

eComLabs writes - to add a new file at blocks/static_templates folder, then will appear, when going to 'add a block' (clear cache + enable my

Where did we write it? I do not believe :)

Tony provided you with the good solution

But if you describe us your task, possibly we will find another solution for you here

Im at work for the moment, at ~6h I will reply you the actual URL, that you mention, what I said^.

actually, Im native PHP coder, never used a CMS to do a website, a client of mine, needs a search mechanism (which read the product categories from CSCART mysql.tables).

The car_search.php :


as you can understand, each combo filled by previous combo selection, when select the last combo (Accessory2) run at http://dispatch=categories.view(greets to eComLabs for the previous tip).

^All done by jQ (ajax) + PHP in a file car_search.php (I fill the first combo, for sure I can make it HTML and use an ajax call to fill it)

the flow :
when combo1_change event fired make a ajax call to car_search_models.php to fill the 2nd combo
when combo2_change event fired make a ajax call to car_search_accessories.php..

now the client needs this^ to be merge @ homepage :)

thats why Im searching on how to include... \

I would like to know, how this mechanism can plugged to main page.

@tbirnseth thanks for quick reply, seems that the option you provided me isnt fit to my senario^^^,

@tbirnseth & @eComLabs looking forward for your solutions based on my needs. :)

thank you.



so, I got the JSON result of, this query :


select cscart_category_descriptions.category as category,cscart_category_descriptions.category_id as category_id from cscart_categories
left join cscart_categories as bb on bb.parent_id = cscart_categories.category_id
left join cscart_category_descriptions on cscart_category_descriptions.category_id = bb.category_id
where cscart_categories.category_id=? and lang_code=‘el’
order by cscart_category_descriptions.category


//car_search.php (aka index.php)

 $('#accessories').on('change', function() {
			url : 'ask_accessory.php',
			dataType : 'json',
			type : 'POST',
			data : {
				"accessory" : $("#accessories").val(),
			success : function(data) {

				var recs = "";
				$.each(data.recs, function(key, val) {
					recs+="" + val.category + "";

thats all!

btw is any addon that can be customized to do the same work ?

I would create an addon for your extended search and then simply look for your parameters in an index.pre.php controller in the addon and process accordingly (redirecting after the search).


Thank you. Yes, blocks with static templates work in this way. But we did not say that these blocks will accept php tags

seems that using a "new html/smarty block" I can embed JS code proper... which allows me to get the json from php..

source -


hi there,

finally I created a new block type of HTML/Smarty

using {literal} tag allows me to use custom JS, sample :



all wokring nicely.

Thank you tbirnseth & eComLabs.

Thank you for sharing this information