Solved

pass var to php from smarty

Posted on 2013-02-06
7
320 Views
Last Modified: 2013-05-11
--- in smarty file

 include {php}include_once("content/somefileicreate.php"){/php}
{$product.id}    --- this will show eg. 125

--- in php file
i try $id = $product.id;
......... and final return $id1

but the result of $id1 is smarty will become "id"

how am i pass a var to php file from this smartyfile??
0
Comment
Question by:john80988
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Author Comment

by:john80988
ID: 38859576
how am i pass variable say $pid to include file of php {php} include("/pathtophp/a-program.php"){/php}
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 38861655
Smarty is very complicated.  Smarty is kind of a compiled template engine.  I never figured out how to change basic PHP statements by themselves.  It's not intended to work that way.  

All I can suggest is that you learn more about it.  http://www.smarty.net/   I won't work on Smarty or Xoops web sites.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 38861780
@john80988 , You are going to have to post a little more code showing how you are doing this.

@DaveBaldwin, I didn't find your post very useful to the OP at all.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38861817
Eddie, I suspect that you have never worked on a Smarty template.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 38861942
Oh, yes, plenty. While I agree with your opinion about Smarty, I can't understand why anyone would want to learn yet another language, I just wouldn't tout it when he already is using Smarty.

Smarty had it's time and place and today there are much better ways of doing things.

john80988 didn't post enough code to give a definitive answer, however.
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 38861960
I second DaveBaldwin's comment.  Smarty is a nightmare, and the best advice any of us could give the OP is to begin migrating away from it.

Smarty is a templating system designed to allow application code to exist in PHP, and the presentation code to exist in HTML.  The two are not supposed to meet up, except by way of the Smarty engine.  In its role as the middle-man, the communication is primarily one-way - the HTML portion of the template normally runs *after* the "standard" PHP has finished its work.  Using Smarty to pass values back to PHP does not make sense in this context, if it is even possible (I'm unsure if it is or not).  

In reality, Smarty merely abstracts the problem of mixing logic with presentation, adding its own middle-man syntax.  When you create a Smarty site, you ARE mixing logic and presentation.  It's just that the logic is now Smarty directives instead of PHP commands.  It adds very little benefit, at the cost of Smarty's learning curve and complexity, and general lack of community support.  All the developers I know shun Smarty like a pedophile at a birthday party.

If you must absolutely use Smarty, I suggest using it as little as possible, and then only as intended - to push finished data into your HTML template.  My primary goal would be to remove Smarty from the equation where ever possible.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 38862162
Then Eddie, if you can help him, I salute you.  I just felt compelled to give him a warning at the very outset.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Loading Self-Hosted Fonts 12 43
How to display get_the_terms within a function 3 38
Which is best Image Resizing Web service 11 41
PHP, Curl and XML 13 14
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question