Forum PrestaShop

Il Forum di PrestaShop è lo spazio in cui puoi condividere con la comunità di PrestaShop consigli pratici sull'e-commerce e trovare la risposta a tutte le domande tecniche e funzionali.

Forum PrestaShop

Jump to content

[Solved] Smarty for code to tpl in modules

11 replies to this topic
#1
disarci

    PrestaShop Fanatic

  • Moderators
  • 2043 posts
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

  • Members
  • PipPipPipPip
  • 1005 posts
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

  • Moderators
  • 2043 posts
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

  • Members
  • PipPipPipPip
  • 1005 posts
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

  • Moderators
  • 2043 posts
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

  • Moderators
  • 2043 posts
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

  • Members
  • PipPipPipPip
  • 1005 posts
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

  • Moderators
  • 2043 posts
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

  • Members
  • PipPipPipPip
  • 1005 posts
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

  • Moderators
  • 2043 posts
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

  • Members
  • PipPipPip
  • 827 posts
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

  • Members
  • Pip
  • 5 posts

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