PrestaShop Forums: [Solved] Smarty for code to tpl in modules - PrestaShop Forums

Jump to content


Welcome to the PrestaShop Forum! We hope you'll share your comments and suggestions with us. We ask that you please post in English to the main sections of the PrestaShop Forum. If you want to write in another language, please post in the corresponding PrestaShop Community section below.

Please note that PrestaShop Community sections are largely self-moderated. PrestaShop team members may or may not participate in non-English sections. To improve the chances of receiving feedback to your question or comment, please post it in English to the main sections of our Forum.

NYC

Vous parlez français ? par ici !


[Solved] Smarty for code to tpl in modules


[Solved] Smarty for code to tpl in modules

#1 disarci

    PrestaShop Fanatic

  • 08 Sep 2008
  • Moderators
  • 1982 posts
  • Location:Dijon

Posted 02 October 2008 - 07:58 PM

Hi,
We are creating a module for skype,
no problems the module works very well if I pass only the account name as smarty.

But if I want to pass all the skype code I have a problem:
<script type="text/javascript"
in tpl file arrive:
<script type="text/javascript"

I tried different encoding (html, utf-8)
I thought I have to use {$foo|noescape} but I can't.

How can I pass an html code from module php to tpl.
I take the code from a form in configure.

Thanks

#2 Paul C

    PrestaShop Fanatic

  • 02 Aug 2008
  • Members
  • PipPipPipPip
  • 1003 posts
  • Location:Dundee, Scotland, United Kingdom

Posted 02 October 2008 - 10:21 PM

Doesn't work. Do you really need the template file? Could you not just echo the code you need from inside the module instead?

e.g.

function hookLeftColumn($params) {

$output = '

Some html in here to do what you want without smarty getting in the way

';

return $output;

}

Paul
Free Prestashop modules and developer resources

Latest Prestashop Developer articles:
* 1.4 Plugins Revisited – Part 1
* 1.4 Plugins Revisited – Part 2

Latest News:
Prestashop Module and Theme Developers can now Advertise on eCartService.net

#3 disarci

    PrestaShop Fanatic

  • 08 Sep 2008
  • Moderators
  • 1982 posts
  • Location:Dijon

Posted 03 October 2008 - 11:47 AM

Yes,
I saw different example,
but the friends ho asked us in italian's forum,
want a tpl for following the templates.

Thanks
Christian

#4 Paul C

    PrestaShop Fanatic

  • 02 Aug 2008
  • Members
  • PipPipPipPip
  • 1003 posts
  • Location:Dundee, Scotland, United Kingdom

Posted 03 October 2008 - 12:10 PM

Another thought that struck me.... what validation is being done on the data that's entered into the form? I must confess I gave up and used the above when I was faced with this! It certainly has something to do with the cart's internal validation somewhere, and if not via smarty, then certainly within the object classes.

I'm still unclear as to why a template is required though, you can surely include css classes and styles consistent with the template in the configure box?

Maybe I'm just not getting what you're trying to do, but the existence of a tpl file doesn't influence the application of the current template's "style". Any html placed on the page will be styled using the theme, whether in a tpl file or not.

I guess you may want to add extra "wrapper" code around the value you're passing, but that could surely be included within the module.

Paul
Free Prestashop modules and developer resources

Latest Prestashop Developer articles:
* 1.4 Plugins Revisited – Part 1
* 1.4 Plugins Revisited – Part 2

Latest News:
Prestashop Module and Theme Developers can now Advertise on eCartService.net

#5 disarci

    PrestaShop Fanatic

  • 08 Sep 2008
  • Moderators
  • 1982 posts
  • Location:Dijon

Posted 03 October 2008 - 12:24 PM

Yes,
it's true it is not necessary.

I'll prefer to have,
because we are going to make a module for skype,
but if it's a templates, everyone can use as the want, change the title bar and so on.

I'll use with php-live...other with messenger...

thanks
Christian

#6 disarci

    PrestaShop Fanatic

  • 08 Sep 2008
  • Moderators
  • 1982 posts
  • Location:Dijon

Posted 03 October 2008 - 12:41 PM

The problem was in the form...

From Vino al Vino translated:
The Function:

Configuration::updateValue('COD_SKYPE', $gai);

static void updateValue( string $key, mixed $values, [boolean $html = false])

Update configuration key and value into database (automatically insert if key does not exist)
Tags:

* access – public
Parameters:

* string $key – Key * mixed $values – $values is an array if the configuration is multilingual, a single string else. * boolean $html – Specify if html is authorized in value

MUST BE:
Configuration::updateValue('COD_SKYPE', $gai, true);


#7 Paul C

    PrestaShop Fanatic

  • 02 Aug 2008
  • Members
  • PipPipPipPip
  • 1003 posts
  • Location:Dundee, Scotland, United Kingdom

Posted 03 October 2008 - 01:31 PM

Ah, excellent. That'll makes things easier! Top marks for the solution, and posting it back to the forum.

Paul
Free Prestashop modules and developer resources

Latest Prestashop Developer articles:
* 1.4 Plugins Revisited – Part 1
* 1.4 Plugins Revisited – Part 2

Latest News:
Prestashop Module and Theme Developers can now Advertise on eCartService.net

#8 disarci

    PrestaShop Fanatic

  • 08 Sep 2008
  • Moderators
  • 1982 posts
  • Location:Dijon

Posted 03 October 2008 - 04:17 PM

So to pass the code:
I create a form
I store the variable in
function getContent()

with:
Configuration::updateValue('COD_SKYPE', $gai, true);

the true mean that he can accept html value
then I pass the content with a smarty without any encoding:

Quote

$smarty->assign('skype',$skypecod);


that's all.

You can found the alfa version of the skype module in italian forum:

http://www.prestasho...ltomodulo_skype

#9 Paul C

    PrestaShop Fanatic

  • 02 Aug 2008
  • Members
  • PipPipPipPip
  • 1003 posts
  • Location:Dundee, Scotland, United Kingdom

Posted 04 October 2008 - 11:44 AM

I was confused as when I looked back at older versions of some of my code I discovered I'd tried this (for the addstuff module) and still couldn't get it to work.

I think I know why. In the module configuration form I used a textarea to accept multi-line input (the html to add to the page). Unfortunately what happens is that the html tags seem to get stripped by the textarea input control. I use htmlentities when displaying the stored value, and that's fine, but initially there seems to be a problem. I'll need to go and investigate solutions, as this is the final piece in the puzzle I need to fix (a standard, single-line text control doesn't have the same issues).

It seems I was looking for solutions in the wrong place!!!

Paul
Free Prestashop modules and developer resources

Latest Prestashop Developer articles:
* 1.4 Plugins Revisited – Part 1
* 1.4 Plugins Revisited – Part 2

Latest News:
Prestashop Module and Theme Developers can now Advertise on eCartService.net

#10 disarci

    PrestaShop Fanatic

  • 08 Sep 2008
  • Moderators
  • 1982 posts
  • Location:Dijon

Posted 04 October 2008 - 04:12 PM

This is the module for skype that use smarty and the code:

I'll try with single line....

Thanks

http://www.prestasho...viewthread/5992

#11 ejectcore

    PrestaShop Addict

  • 08 Apr 2008
  • Members
  • PipPipPip
  • 827 posts
  • Location:UK

Posted 04 October 2008 - 04:49 PM

Very nice & easy to install :)
http://www.skype.com/share/buttons/

Just added a 1 line to the end of the SKYPE code.


To make this even easier if thats possible.
I would add an extra field in the admin for username then you don't have to copy & paste the code from skype, just a suggestion.
Probably going to look into this when I get more free time ;)
Filter Search 2.1 Enterprise Edition Now Available

Available Soon
Filter Search 2.1 Lite Edition

Follow us on twitter

#12 droso

    PrestaShop Newbie

  • 07 Dec 2008
  • Members
  • Pip
  • 5 posts

Posted 08 December 2008 - 07:03 AM

From 1222973890:

Hi,
We are creating a module for skype,
no problems the module works very well if I pass only the account name as smarty.

But if I want to pass all the skype code I have a problem:
<script type="text/javascript"
in tpl file arrive:
<script type="text/javascript"

I tried different encoding (html, utf-8)
I thought I have to use {$foo|noescape} but I can't.

How can I pass an html code from module php to tpl.
I take the code from a form in configure.

Thanks


I have a similar problem too.

I need to insert in product description a module like this:


<head>
[removed]
function check(x)
{
document.getElementById("glow").bgColor=x
}
[removed]
</head>
<body>

What's your favorite browser:


<form>
<input type="radio" name="name">Blue

<input type="radio" name="name">Red

<input type="radio" name="name">Yellow

<input type="radio" name="name">White

<input type="radio" name="name">gray










slfhsljdfslfhsljdf
ajlsfhjksdsjdfhsdf

</form>
</body>Table row "glow" is highlighted whatever color you select.

I need to show my visitors some properties of the products by switching the background color.

I try to paste as HTML in "complete description" field, it appears but it do nothing when radio buttons are clicked.


Ca anyone help me with this problem.

Thanx





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users