Hello,
I am trying to work out how to have smarty use a string's contents as the
display-> template..
ie:
$smarty->display($buffe r);
obviously $buffer isn't a filename, but a smarty template inside a string
variable. Take this example:
<snip>
<?php
ob_start('ob_ca llback');
$smarty = new smartyLocal();
$smarty->assign('var1 ', 'test');
ob_callback($bu ffer) {
$smarty->display($buffe r);
}
?>
<html><head><ti tle>page</title></head>
<body>
{$var1}
</body>
</html>
EOF
What do you guys think? Anyway to do this? 4 15472
I know, that should have been "function ob_callback($bu ffer)", I just meant
it as an example.
"Brian" <cpnmscg02 (@) sneakemail.com> wrote in message
news:pvJEb.4026 10$Dw6.1250589@ attbi_s02... Hello,
I am trying to work out how to have smarty use a string's contents as the display-> template.. ie: $smarty->display($buffe r);
obviously $buffer isn't a filename, but a smarty template inside a string variable. Take this example:
<snip> <?php ob_start('ob_ca llback'); $smarty = new smartyLocal(); $smarty->assign('var1 ', 'test'); ob_callback($bu ffer) { $smarty->display($buffe r); } ?>
<html><head><ti tle>page</title></head> <body> {$var1} </body> </html>
EOF
What do you guys think? Anyway to do this?
Brian <cpnmscg02 (@) sneakemail.com> wrote: Hello,
I am trying to work out how to have smarty use a string's contents as the display-> template.. ie: $smarty->display($buffe r);
obviously $buffer isn't a filename, but a smarty template inside a string variable.
Looks like a RTFM to me: http://smarty.php.net/manual/en/temp....elsewhere.php
<q>
Templates from other sources
You can retrieve templates using whatever possible source you can access
with PHP: databases, sockets, LDAP, and so on. You do this by writing
resource plugin functions and registering them with Smarty.
</q>
--
Daniel Tryba
Hi Brian,
You can use eval to parse your template code before outputting.
For example if you have a variable $buffer in php file
$buffer =
'<html><head><t itle>page</title></head>
<body>
{$var1}
</body>
</html>';
$smarty->assign('var1 ', 'test');
$smarty->assign('buffer ', $buffer);
You can code your smarty template file as follows
{eval var=$buffer assign="parsedB uffer"}
{$parsedBuffer}
-- Rahul
"Brian" <cpnmscg02 (@) sneakemail.com> wrote in message news:<qwJEb.402 615$Dw6.1250605 @attbi_s02>... I know, that should have been "function ob_callback($bu ffer)", I just meant it as an example.
"Brian" <cpnmscg02 (@) sneakemail.com> wrote in message news:pvJEb.4026 10$Dw6.1250589@ attbi_s02... Hello,
I am trying to work out how to have smarty use a string's contents as the display-> template.. ie: $smarty->display($buffe r);
obviously $buffer isn't a filename, but a smarty template inside a string variable. Take this example:
<snip> <?php ob_start('ob_ca llback'); $smarty = new smartyLocal(); $smarty->assign('var1 ', 'test'); ob_callback($bu ffer) { $smarty->display($buffe r); } ?>
<html><head><ti tle>page</title></head> <body> {$var1} </body> </html>
EOF
What do you guys think? Anyway to do this?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Brian |
last post by:
I have an application that uses an array of values as a "lookup" table and
smarty as a template engine.
$lookup = "label";
$lookup = "label2";
$lookup = "label";
$lookup = "label2";
In my application I can easily use this array to find the values I need.
|
by: Daan |
last post by:
Hello all,
I'm having a little problem with Smarty. Getting it to work in a simple
case went fine, but now I have the following situation:
/
/smarty
/templates
template.tpl
/templates_c
|
by: Richard |
last post by:
I need help. I have a smarty based program that I am modifying. I
have a smarty template file that consists of smarty and HTML.
I need to integrate some PHP database calls into it. My problem is I
cannot figure out how to pass value between smarty and PHP. Going
from php to smarty I've tried this:
{php}
$smarty = new Smarty;
$smarty->assign("x", 100);
|
by: Conrad |
last post by:
Hi, I'm very new to Smarty Template Engine and I'm using PHP 5.0.4 on
the Windows XP Professional platform and I have the following question:
When I change the 7th line of the script to use a new name and refresh
the browser, it maintains the old value instead of updating to the new
value. Both index.php and SmartySetup.class.php appear below:
index.php:
|
by: J Huntley Palmer |
last post by:
Whenever I put in a smarty variable in a link definition as :
<a href="{$foo->bar}">foo</a>,
it shows up as a literal as above in the link and not the contents of
the variable itself. Everywhere else in the template .. variable
substitution works fine.
Any help appreciated.
| |
by: Man-wai Chang |
last post by:
1. How could concatenate two values into a string in the template?
{section name=j start=0 loop=10 step=1}
{section name=k start=0 loop=10 step=1}
{assign var=xx value=concat($smarty.section.j,$smarty.section.k)}
{xx}
{/seection}
{/section}
2. How could I address/use associative array in the template? I could do
|
by: Gene |
last post by:
i'm newcomer in using smarty and i have problem like this:
i want to have one template file (e.g. index.tpl) in this file section
which use variable {$content}.
and two files *.php which are using the same template index.tpl and
only change the content.
for example:
/*index.php*/
$smarty = new MySmarty();
$smarty->assign('content','INDEX');
|
by: grezlik |
last post by:
Hi!
I have major problems with cakephp & smarty, (cake ver is 1.2 and smarty 2.6.18 )
there is a code (from cake/libs/view/view.php
class SmartyView {
..
..
..
|
by: K. |
last post by:
Hello!
I have a problem with using php on smarty web page
I would like to use a php code from this web page:
http://www.money.pl/webmaster/#
i.e.. <?php readfile ('http://cw.money.pl/wiadomosci_banki.html', true) ?>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |