Re: Get smarty to write standart code in every template ?
| From: | Monte Ohrt | Date: | Fri, 23 Mar 2001 19:29:14 +0000 |
| Subject: | Re: Get smarty to write standart code in every template ? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-421@lists.php.net to get a copy of this message | ||
oops, change that version to 1.3.1pl1.
taliku@balcab.ch wrote:
>
> thx it worked!
>
> damn, smarty is great :)
>
> ----- Original Message -----
> From: "Monte Ohrt" <monte@ispi.net>
> To: <taliku@balcab.ch>
> Cc: "Smaty ML" <smarty@lists.ispi.net>
> Sent: Friday, March 23, 2001 7:04 PM
> Subject: [smarty] Re: Get smarty to write standart code in every template ?
>
> > try this:
> >
> > add these two variables to the smarty class:
> >
> > var $version = "3.0.1pl1"; // Smarty version
> > number
> > var $show_info_header = true; // display info header
> > at top of page output
> >
> >
> > then modify the fetch() function in Smarty.class.php to this:
> >
> > /*======================================================================*\
> > Function: fetch()
> > Purpose: executes & returns or displays the template results
> > \*======================================================================*/
> > function fetch($tpl_file, $cache_id = null, $display = false)
> > {
> > global $HTTP_SERVER_VARS;
> >
> > if ($this->caching) {
> > // cache name = template path + cache_id
> > $cache_tpl_md5 =
> > md5(realpath($this->template_dir.'/'.$tpl_file));
> > $cache_id_md5 = md5($cache_id);
> > $cache_id_dir = substr($cache_id_md5, 0, 2);
> > $cache_file =
> >
> $this->cache_dir."/$cache_tpl_md5/$cache_id_dir/{$cache_tpl_md5}_$cache_id_m
> d5.cache";
> >
> > if (file_exists($cache_file) &&
> > ($this->cache_lifetime == 0 ||
> > (time() - filemtime($cache_file) <=
> > $this->cache_lifetime))) {
> > $results = $this->_read_file($cache_file);
> > $results = $this->_process_cached_inserts($results);
> > if ($display) {
> > echo $results;
> > return;
> > } else
> > return $results;
> > }
> > }
> >
> > // compile files
> > $this->_compile($this->template_dir);
> > //assemble compile directory path to file
> > $_compile_file = $this->compile_dir."/".$tpl_file.".php";
> >
> > extract($this->_tpl_vars);
> >
> > if($this->show_info_header)
> > $info_header = '<!-- Smarty '.$this->version.'
> > '.strftime("%Y-%m-%d %H:%M:%S").' -->'."\n\n";
> > else
> > $info_header = "";
> >
> > // if we just need to display the results, don't perform output
> > // buffering - for speed
> > if ($display && !$this->caching) {
> > echo $info_header;
> > include($_compile_file);
> > }
> > else {
> > ob_start();
> > echo $info_header;
> > include($_compile_file);
> > $results = ob_get_contents();
> > ob_end_clean();
> > }
> >
> > if($this->caching) {
> > $this->_write_file($cache_file, $results, true);
> > $results = $this->_process_cached_inserts($results);
> > }
> >
> > if ($display) {
> > if(isset($results)) { echo $results; }
> > return;
> > } else {
> > if(isset($results)) { return $results; }
> > }
> > }
> >
> >
> >
> > taliku@balcab.ch wrote:
> > >
> > > Yeah, that's what i want. Where di i have to implement this code?
> > >
> > > thx
> > > taliku
> > >
> > > ----- Original Message -----
> > > From: "Monte Ohrt" <monte@ispi.net>
> > > To: <taliku@balcab.ch>
> > > Cc: "Smaty ML" <smarty@lists.ispi.net>
> > > Sent: Friday, March 23, 2001 6:14 PM
> > > Subject: [smarty] Re: Get smarty to write standart code in every
> template ?
> > >
> > > > Yes, this can be done. Interesting idea, we'd know that the site was
> > > > built with Smarty, and know when the page was last generated, and
> > > > whether cached or not. We would have to be careful that only mime
> types
> > > > of text/html are affected, we don't want this showing up in other
> > > > formats of output.
> > > >
> > > > How configurable would this need to be?
> > > >
> > > > Just a simple:
> > > > $smarty_html_headers = true;
> > > >
> > > > or more configurable:
> > > > $smarty_headers = array( "text/html" => "<!-- Smarty %v %d
> (%c) -->" );
> > > >
> > > > %v = version
> > > > %d = date
> > > > %c = cache flag
> > > >
> > > > Other thoughts?
> > > >
> > > > taliku@balcab.ch wrote:
> > > > >
> > > > > Hello Everyone!
> > > > >
> > > > > Is it possible to edit a smarty-function (fetch?) to get smarty
> > > > > write a standart text on the beginning of every output
> > > > > like Vignette V/5 it does (http://www.vignette.com):
> > > > >
> > > > > Example: In every Site generated by Vignette V/5 (also known as
> > > StoryServer)
> > > > > on top is written the System and the time of generation:
> > > > >
> > > > > <!-- Vignette V/5 Fri Mar 23 16:59:47 2001 -->
> > > > >
> > > > > Is it possible? Will smarty then work slower?
> > > > > I don't want to write this on top of every .php file...
> > > > >
> > > > > thanks in advance
> > > > >
> > > > > taliku
> > > > > Sorry for my bad english :) --> Switzerland :)
> > > > >
> > > > > ---
> > > > > 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>
> > > > http://www.ispi.net/
> > > >
> > > > ---
> > > > You are currently subscribed to smarty as: taliku@balcab.ch
> > > > 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>
> > http://www.ispi.net/
> >
> > ---
> > You are currently subscribed to smarty as: taliku@balcab.ch
> > 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>
http://www.ispi.net/