Jump to content

Trying to insert PHP code (Smarty problems)


Recommended Posts

I'm trying to insert a PHP code in some Prestashop pages (I'm trying to put it in footer.tpl).

 

I've described my problem already in the Smarty forum and got some quite helpful answers, but they finally sent me here (you can see the details of my problem and the responses here: http://www.smarty.ne...p?p=85481#85481).

 

It seems like the problem is that I have to first assign the variable in a php file before using it in a template file, but I don't know how to do it and where to put the code (what files should I change and where in that files should I put the code, if the order is important).

 

PS.: I'm new in this forum and not 100% sure if this is the appropriate subforum for this question. If not, please tell me or move it to the appropriate one.

Link to comment
Share on other sites

I'm trying to use http://phpabtest.com in Prestashop.

 

The default code for implementing PHPabtest uses {phpab} tags. I've trying using them without luck (probably because Smarty syntax also uses brackets).

I've also tried using {ldelim}{rdelim} for replacing the phpab tag brackets and putting the {phpab} code between {literal}{/literal}, without any luck too (maybe that solutions could work but I've done something wrong, because I haven't used Smarty before).

 

Then I tried the alternative option for implementing PHPabtest, which is using "normal" PHP code, like the following:

 

 

<?php if($my_test->get_user_segment() == 'first_variation') : ?>
Hello!
<?php elseif($my_test->get_user_segment() == 'second_variation') : ?>
Hi!
<?php else : /* control */ ?>
Hey!
<?php endif; ?>

 

I've tried inserting that code with {php} {/php} tags, but as you've said, it doesn't work.

 

Then I've tried "translating" the PHP code to Smarty syntax, but it doesn't work either (maybe because my "translation" is wrong). The code I've used (inserting it in footer.tpl) was:

 

{if $my_test->get_user_segment() == 'first_variation'} 
Hello! 
{elseif $my_test->get_user_segment() == 'second_variation'} 
Hi! 
{else} 
Hey! 
{/if}

 

So I've tried 3 different options: {phpab} tags, {php} {/php} tags and a "home-made" Smarty translation of the PHP code, all without any luck.

 

Anyone know how what I'm doing wrong or another way to use http://phpabtest.com code in Prestashop?

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...