Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

pass var to php from smarty

Posted on 2013-02-06
7
Medium Priority
?
322 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 84

Accepted Solution

by:
Dave Baldwin earned 1500 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 84

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 51

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 84

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn how to count occurrences of each item in an array.

715 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