Re: A function like 'Fetch' but only grabs info inside a certain tag.
| From: | WiL Laxa | Date: | Tue, 26 Feb 2002 22:50:10 +0000 |
| Subject: | Re: A function like 'Fetch' but only grabs info inside a certain tag. | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2851@lists.php.net to get a copy of this message | ||
Well I have different template files.
Templates (header footer)which contains the overall theme of the site.
(ie. header and footer design)
----------------------------------------
| header |
----------------------------------------
| body |
| |
| |
| |
| |
| |
| |
| |
| |
----------------------------------------
| footer |
----------------------------------------
Layouts (body) which have different ways to displaying web content.
(ie. picture to the right, text to the left)
( Border will be made of graphics)
----------------------------------------
| | text here |
| | |
| | |
| | |
| picture | |
| | |
| | |
| | |
| | |
----------------------------------------
Borders which are 3rowx3col tables that contains graphics to make a content
block border.
Usually contains artical summaries that link to the full article.
(ie. Border will be made of graphics)
--------------------
| NEWS |
--------------------
| Article Number 1 |
| Article Number 2 |
| Article Number 3 |
| Article Number 4 |
--------------------
--------------------
| SPORTS |
--------------------
| Article Number 1 |
| Article Number 2 |
| Article Number 3 |
| Article Number 4 |
--------------------
All these templates are full html documents (with <title><head> information
even though it's useless) so that designers have the ability to easily edit
them in a wysiwyg editor like dreamweaver without seeing broken tags.
I'm creating a CMS that's extremely customizable.
You won't be limited to 1 layout style for your article.
You can have a different template for each category so maybe sports has a
sports oriented category buttons... Entertainment has entertainment
oriented buttons... etc...
Same for borders... you can customize that way each content block will look
with a different border.
Yes I'd use PREG but I also want to use smarty functions on all the
different type of templates... I just don't want to caputure the body cause
the body has smarty tags that I need to populate.
search.tpl
----------
<HTML>
<HEAD>
<TITLE>Untitled Document</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
{capture name='body'}
<FORM NAME="form1" METHOD="post" ACTION="">
<INPUT TYPE="text" NAME="textfield" VALUE="{$Name}">
<INPUT TYPE="submit" NAME="Submit" VALUE="Search">
</FORM>
{/capture}
</BODY>
</HTML>
template.tpl
--------
<HTML>
<HEAD>
<TITLE>Welcome {$user}</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<img src='header.gif'>
{$body}
<img src='footer.gif'>
</BODY>
</HTML>
index.php
I'm looking for a function that is similar to capture from smarty's built-in
functions
So you can do this...
---------
$smarty = new Smarty;
$smarty->assign('Name',$name);
$body = $smarty->capture('body','search.tpl');
$smarty->clear_all_assign();
$smarty->assign('body',$body);
$smarty->display('template.tpl');
-----Original Message-----
From: mohrt@ns3.ispi.net [mailto:mohrt@ns3.ispi.net]On Behalf Of Monte
Ohrt
Sent: Tuesday, February 26, 2002 6:33 AM
To: smarty@lists.ispi.net
Cc: smarty@lists.ispi.net
Subject: [smarty] Re: A function like 'Fetch' but only grabs info inside
a certain tag.
Just curious, what are you trying to accomplish? Why not create a
separate template like this:
search.tpl
----------
<HTML>
<HEAD>
<TITLE>Untitled Document</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
{include file="body.tpl"}
</BODY>
</HTML>
body.tpl
--------
<FORM NAME="form1" METHOD="post" ACTION="">
<INPUT TYPE="text" NAME="textfield" VALUE="{$Name}">
<INPUT TYPE="submit" NAME="Submit" VALUE="Search">
</FORM>
index.php
---------
$smarty = new Smarty;
$smarty->display('search.tpl');
or, closer to what you want (?):
search.tpl
----------
<HTML>
<HEAD>
<TITLE>Untitled Document</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
{$body}
</BODY>
</HTML>
body.tpl
--------
<FORM NAME="form1" METHOD="post" ACTION="">
<INPUT TYPE="text" NAME="textfield" VALUE="{$Name}">
<INPUT TYPE="submit" NAME="Submit" VALUE="Search">
</FORM>
index.php
---------
$smarty = new Smarty;
$body = $smarty->fetch('body.tpl');
$smarty->assign("body",$body);
$smarty->display("search.tpl");
WiL Laxa wrote:
>
> Question:
>
> I have a template like this: search.htm
>
> <HTML>
> <HEAD>
> <TITLE>Untitled Document</TITLE>
> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;
> charset=iso-8859-1">
> </HEAD>
> <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
> {capture name=body}
> <FORM NAME="form1" METHOD="post" ACTION="">
> <INPUT TYPE="text" NAME="textfield" VALUE="{$Name}">
> <INPUT TYPE="submit" NAME="Submit" VALUE="Search">
> </FORM>
> {/capture}
> </BODY>
> </HTML>
>
> Can I caputure "body" on my script
> Script:
> <?
> $smarty = new Smarty;
> $smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill");
> $body = $smarty->fetch('search.htm');
> ?>
>
> But i don't want to get the whole template... just the {capture} 'body'
> part. And use that to place on my site template.
>
> <?
> $smarty->clear_all_assign();
> $smarty->assign("Body",$body);
> $smarty->display('template.htm');
> ?>
>
> Is it possible to do that?
>
> WiL
>
> ---
> You are currently subscribed to smarty as: wlaxa@blendermedia.com
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
Director of Technology, ispi Inc.
---
You are currently subscribed to smarty as: wlaxa@blendermedia.com
To unsubscribe send a blank email to $subst('Email.Unsub')
Visit Smarty's homepage at http://www.phpinsider.com/php/code/Smarty/